source: tests/scctestlib

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 3.4 KB
Line 
1#!/bin/bash
2# (C)2009 DatuX - Released under GPL
3
4# Testlibrary voor SCC, gebruikt webinject.pl hiervoor.
5# Zie testscripts voor voorbeelden
6
7WEBINJECTDIR="webinject"
8TESTFILE="$WEBINJECTDIR/scctest_tmp.xml"
9TESTID=0;
10
11
12#Roep eerst scc_new aan om een nieuwe test te beginnen
13#Variabellen voor scc_add:
14# IP=IP adress
15# PAGE=op te vragen SCC pagina.
16# DESCRIPTION1= omschrijving
17# METHOD= get (standaard) of post
18# POSTBODY= post-data
19# IGNOREERROR=1 negeer fouten van de SCC (fatal errors oningevulde velden)
20# VERIFYPOSITIVE= tekst voor goed resultaat
21# VERIFYNEGATIVE= tekst voor negatief resultaat
22# VERIFYRESPONSECODE= http reponsecode moet hier aan voldoen
23#Roep hierna scc_run aan om te tests uit te voeren.
24
25#voeg losse test toe
26scc_add()
27{
28        (( TESTID++ ))
29        echo "<case " >> $TESTFILE
30       
31        echo "id='$TESTID'" >> $TESTFILE
32       
33        if [ "$METHOD" == "post" ]; then
34                echo -e "description1='### scctest: $DESCRIPTION1 ( POST $POSTBODY naar $SCC/$PAGE )'" >> $TESTFILE
35        else
36                echo -e "description1='### scctest: $DESCRIPTION1 ( GET $SCC/$PAGE )'" >> $TESTFILE
37        fi
38        DESCRIPTION1=
39       
40        if [ "$METHOD" ]; then
41                echo "method='$METHOD'" >> $TESTFILE
42                METHOD=
43        fi     
44       
45        echo "url='$SCC/$PAGE'" >> $TESTFILE
46       
47        #deze aanpassen als error-handling in de scc anders word:
48        if [ "$IGNOREERROR" != "1" ]; then
49                echo "verifynegative3='error'" >> $TESTFILE
50        fi
51        IGNOREERROR=
52       
53        if [ "$VERIFYPOSITIVE" ]; then
54                echo "verifypositive='$VERIFYPOSITIVE'" >> $TESTFILE
55                VERIFYPOSITIVE=         
56        fi
57       
58        if [ "$VERIFYPOSITIVE2" ]; then
59                echo "verifypositive2='$VERIFYPOSITIVE2'" >> $TESTFILE
60                VERIFYPOSITIVE2=               
61        fi
62       
63        if [ "$VERIFYNEGATIVE" ]; then
64                echo "verifynegative='$VERIFYNEGATIVE'" >> $TESTFILE
65                VERIFYNEGATIVE=
66        fi
67
68        if [ "$VERIFYRESPONSECODE" ]; then
69                echo "verifyresponsecode='$VERIFYRESPONSECODE'" >> $TESTFILE
70                VERIFYRESPONSECODE=
71        fi
72       
73        if [ "$POSTBODY" ]; then
74                echo "postbody='$POSTBODY'" >> $TESTFILE
75                POSTBODY=
76        fi
77       
78        if [ "$PARSERESPONSE" ]; then
79                echo "parseresponse='$PARSERESPONSE'" >> $TESTFILE
80                PARSERESPONSE=
81        fi
82
83        echo "/>" >> $TESTFILE
84       
85}
86
87#maak nieuwe testreeks aan.
88#nieuwe tests moe tje toevoegen met scc_add
89scc_new()
90{
91        echo "<testcases repeat='1'>" > $TESTFILE
92        TESTID=0
93
94
95       
96#       DESCRIPTION1="Afbreken eventueel vorige taken..."
97#       IGNOREERROR=1
98#       PAGE="login/login.php?lock_abort=1";
99#       scc_add
100
101        DESCRIPTION1="Inloggen op $SCC met password $SCCPASSWD..."
102        VERIFYPOSITIVE="redirect=.https"
103        #IGNOREERROR=1
104        METHOD="post"
105        PAGE="login/login.php";
106        POSTBODY="new_name=root&new_passwd=$SCCPASSWD"
107        scc_add
108}
109
110#voert de huidge testreeks uit. returned 1 bij failed tests
111scc_test()
112{
113
114
115        #beeindig testset eerst:
116        echo "</testcases>" >> $TESTFILE
117
118
119        if ! [ "$TIMEOUT" ]; then
120                TIMEOUT=3600
121        fi
122
123        cd $WEBINJECTDIR || return 1
124       
125        #maak config
126        echo "<globalhttplog>yes</globalhttplog>" > config.tmp.xml
127        echo "<timeout>$TIMEOUT</timeout>" >> config.tmp.xml
128       
129       
130
131        #voer test uit:
132        echo "Running webinject tests:"
133        RET=0
134        if ! ./webinject.pl -c config.tmp.xml scctest_tmp.xml; then
135            echo "tip: controleer laatste logregels met:"
136            echo "cat webinject/http.log |egrep -v '^ $'|less"
137            RET=1
138        fi
139        cd ..
140        if grep FAILED $WEBINJECTDIR/results.xml &>/dev/null; then
141                echo "There where failed tests!";
142                RET=1
143        fi
144       
145        TIMEOUT=
146       
147        #deze is klaar, begin een nieuwe test
148        scc_new
149        return $RET
150}
151
152
153scc_new
154
155#Voorbeeld:
156# DESCRIPTION1=""
157# PAGE=""
158# VERIFYNEGATIVE=""
159# VERIFYPOSITIVE=""
160# METHOD="post"
161# POSTBODY=""
162# scc_add
Note: See TracBrowser for help on using the repository browser.