File: test_bench

package info (click to toggle)
netclient 0.91-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,096 kB
  • ctags: 1,539
  • sloc: ml: 8,808; sh: 527; makefile: 203
file content (148 lines) | stat: -rwxr-xr-x 3,165 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#! /bin/sh

usage () {
    cat <<'EOF' 1>&2
usage: test_bench [options] 
   or: test_bench [options] testname ...

Performs all or the enumerated tests and compares the result of the tests
with the expected results.

-init:            Initializes the file containing the expected result with the
	          actual result.
-help:            Print this message
EOF
}


run_test () {
    if [ -f specs/$1.sh ]; then
	echo -n "Running test $1..."
	rm -f client.out
	rm -f server.out
	touch client.out
	touch server.out
	h=`sh specs/$1.sh`
	if [ -f specs/$1.out ]; then
	    g=`cat specs/$1.out`
	    if [ "x$h" = "x$g" ]; then
		echo " successful"
	    else
		echo " failure"
		exitcode=1
	    fi
	else
	    if [ -n "$INIT" ]; then
		echo "$h" >specs/$1.out
		echo " initialized"
	    else
		echo " no result to check against"
		echo "Result: $h"
	    fi
	fi
	mkdir -p log
	cp server.out log/$1.server
	cp client.out log/$1.client
	echo "$h" >log/$1.out 
    else
	echo "Test $1 does not exist"
    fi
}

x=1
while [ -n "$x" ]; do
    case "$1" in
	-init)     INIT=1
	           shift
	           ;;
	-h|-help)  usage
		   exit 0
		   ;;
	-*)
		   usage
		   exit 2
		   ;;
	*)
		   x=""
		   ;;
    esac
done

exitcode=0

export SHELLOPTS

if [ "$#" = "0" ]; then
    # Run all tests...
    INIT=""
    run_test simple
    run_test simple-nocr
    run_test simple-ci
    run_test simple-extra-sp
    run_test simple-extra-tab
    run_test simple-cont-sp
    run_test simple-cont-tab
    run_test simple-cont-2sp
    run_test simple-cont-2tab
    run_test simple-cont-sptab
    run_test simple-cont-early
    run_test simple-multi
    run_test simple-phantasy
    run_test framed
    run_test framed-big
    run_test framed-8bitclean
    run_test chunked
    run_test chunked-ci
    run_test chunked-ext
    run_test chunked-big
    run_test chunked-footer
    run_test error-404
    run_test unframed-is-unframed
    run_test unframed-request
    run_test framed-basicauth
    run_test framed-basicauth-fails
    #run_test framed-digestauth    # cnonce cannot be predicted!
    run_test framed-proxyauth
    run_test framed-proxy+basicauth
    run_test three-messages
    run_test three-messages-incl-simple
    run_test continue
    run_test continue-extra
    run_test continue-handshake
    run_test continue-handshake-timeout
    run_test continue+error-404
    run_test three-continued-messages
    run_test three-very-continued-messages
    run_test three-big-messages
    run_test early-error
    run_test pipeline-phantasy
    run_test nopersistency-1.0
    run_test nopersistency-close
    run_test reconnect-1
    run_test framed-brokenpipe
    run_test pe-get11
    run_test pe-put11
    run_test pe-multiput11
    run_test pe-trashput11
    run_test pe-put10
    run_test illegal-status
    run_test too-many-errors
    run_test limited-drift
    run_test unix-error
    run_test framed-no-persistency
    run_test timeout
    run_test bad-request
    run_test head
    run_test head-extra
    run_test proxypersistency-1.0
else
    while [ "$#" -gt 0 ]; do
	run_test "$1"
	shift
    done
fi

# Exit with 1 only if a specified test fails.
exit $exitcode