forked from juliusknorr/http_extend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-all.sh
executable file
·51 lines (44 loc) · 1.09 KB
/
test-all.sh
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
#!/bin/bash
FAILED_TESTS=""
assertSuccess(){
CMD="$1"
echo "+ $CMD";
echo -n ">>>"
eval "$CMD 2>&1"
RET="$?"
echo "<<<"
if [ "$RET" != "0" ];then
echo "=> ERROR: execution failed (returncode $RET)"
FAILED_TESTS="$FAILED_TESTS#assertSuccess => $CMD"
return 100
fi
}
assertFail(){
CMD="$1"
echo "+ $CMD";
echo -n ">>>"
$CMD
RET="$?"
echo "<<<"
if [ "$RET" == "0" ];then
echo "=> ERROR: execution successful (returncode $RET)"
FAILED_TESTS="$FAILED_TESTS#assertFail => $CMD"
return 100
fi
}
echo "*** TESTS"
assertSuccess './http_extend -v -s -u http://www.google.de -r "(.*body.*)"'
assertSuccess './http_extend -s -u http://www.google.de -r "(.*body.*)"'
assertSuccess './http_extend -m -u http://www.google.de -r "(.*body.*)"'
assertFail './http_extend -t 1 -m -u http://www.google.de -r "(.*body.*)"'
assertFail './http_extend -m -u http://www.google.de -r "(.*bodyAAA.*)"'
echo
echo "*** SUMMARY"
if [ -z "$FAILED_TESTS" ];then
echo "ALL TESTS PASSED"
exit 0
else
echo "THE FOLLOWING TESTS FAILED"
echo "$FAILED_TESTS"|tr '#' '\n'|sed '~s,^, ,'
exit 1
fi