Annotation of parser3/tests/httpd/code-cache/run_tests.sh, revision 1.2

1.1       moko        1: #!/bin/sh
                      2: # the code caching for httpd mode records and then replays the compilation using the cached methods (feature #1302)
                      3: 
                      4: PARSER=`pwd`/../../../src/targets/cgi/parser3
                      5: PORT=8101
                      6: 
                      7: class_file() { # file, class, method, text
                      8:        printf '@CLASS\n%s\n\n@%s[]\n%s\n' "$2" "$3" "$4" > "$1"
                      9: }
                     10: 
                     11: get() { # the response body of the test @name in site/tests.p
                     12:        printf 'GET /?%s HTTP/1.0\r\n\r\n' "$1" | nc localhost $PORT | tr -d '\r' | sed '1,/^$/d'
                     13:        echo
                     14: }
                     15: 
                     16: run() { # httpd mode, code cache: on or off
                     17:        echo "=== $1, code cache $2"
                     18:        class_file site/changing.p Changing version before
                     19:        no_cache=; [ $2 = off ] && no_cache=1
                     20: 
1.2     ! moko       21:        # not in a subshell: on FreeBSD $! is the subshell then, the killed one is not the server
        !            22:        cd site
        !            23:        TEST_HTTPD_MODE=$1 TEST_NO_CODE_CACHE=$no_cache CGI_PARSER_CONFIG=`pwd`/config.p $PARSER -p $PORT &
1.1       moko       24:        server=$!
1.2     ! moko       25:        cd ..
1.1       moko       26:        # wait for the server listens
                     27:        for i in 1 2 3 4 5; do nc -z localhost $PORT 2>/dev/null && break; sleep 0.2; done
                     28: 
                     29:        echo "fields are fresh in each request:"; get fresh; get fresh
                     30:        echo "an error in the cached code:"; get failed
                     31:        echo "^use of a cached file:"; get use_cached
                     32:        echo "a cached partial class extended by the file named in ^process[...][$.file[...]] of the config:"; get extended
                     33:        echo "a file compiled into a cached class takes its options:"; get options
                     34:        echo "a cached class already defined:"; get defined
                     35:        echo "a cached partial class extending one not marked as partial:"; get not_partial
                     36:        echo "a cached class with the undefined base:"; get no_base
                     37:        echo "a cached file changed after the start:"; get changing
                     38:        class_file site/changing.p Changing version after; get changing
                     39:        if [ $2 = on ]; then
                     40:                chmod a-r site/cached.p
                     41:                echo "a cached file unreadable after the start:"; get use_cached
                     42:                chmod a+r site/cached.p
                     43:        fi
                     44: 
                     45:        kill $server; wait $server 2>/dev/null
                     46: }
                     47: 
                     48: {
                     49: run sequental on
                     50: run parallel on
                     51: run threaded on
                     52: run sequental off
                     53: } >tests.log 2>&1
                     54: 
                     55: rm -f site/changing.p site/parser3.log
                     56: diff -u ok.log tests.log

E-mail: