clean it up even more
[freeradius.git] / src / tests / runtests.sh
1 #!/bin/bash
2
3 PORT=12340
4 HOME_PORT=12350
5
6 rm -f verbose.log
7 RCODE=0
8
9 rm -rf .cache
10 mkdir .cache
11
12 #
13 #  Bootstrap the tests
14 #
15 for NAME in $@
16 do
17   TOTAL=`grep TESTS $NAME | sed 's/.*TESTS//'`
18
19   #
20   #  Each test may have multiple variants.
21   #
22   for NUMBER in `echo $TOTAL`
23   do
24     cp $NAME .request
25
26     #
27     #  Add the name of the test, and the variant to the request
28     #
29     echo "Test-Name = \"$NAME\"," >> .request
30     echo 'Test-Number = ' $NUMBER >> .request
31
32     mv .request .cache/$NAME:$NUMBER
33   done
34 done
35
36 echo "Running tests..."
37
38 (cd .cache;ls -1  > ../.foo)
39 rm -f .bar
40 for x in `cat .foo`
41 do
42    echo "-f .cache/$x" >> .bar
43 done
44
45 ../main/radclient `cat .bar` -xFd . 127.0.0.1:$PORT auth testing123 > radclient.log 2>&1
46
47 for x in `cat .foo`
48 do
49   RESULT=`egrep ^\\.cache/$x radclient.log | sed 's/.* //'`
50   if [ "$RESULT" = "2" ]; then
51       echo "$x : Success"
52     else
53       echo "$x : FAILED"
54       RCODE=1
55   fi
56 done
57
58
59 if [ "$RCODE" = "0" ]
60 then
61     rm -f radiusd.log radclient.log 
62     echo "All tests succeeded"
63 else
64     echo "See radclient.log for more details"
65 fi
66
67 exit $RCODE