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