This doesn't need bash. SH is more portable
[freeradius.git] / src / tests / runtests.sh
1 #!/bin/sh
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 echo "Running tests:"
12 for NAME in $@
13 do
14   TOTAL=`grep TESTS $NAME | sed 's/.*TESTS//'`
15
16   #
17   #  Each test may have multiple variants.
18   #
19   for NUMBER in `echo $TOTAL`
20   do
21     cp $NAME .request
22     BASE=`echo $NAME | sed 's,.*/,,'`
23
24     #
25     #  Add the name of the test, and the variant to the request
26     #
27     echo "Test-Name = \"$BASE\"," >> .request
28     echo 'Test-Number = ' $NUMBER >> .request
29
30     rm ./radclient.log > /dev/null 2>&1
31     $BIN_PATH/radclient -f .request -xF -D ./ 127.0.0.1:$PORT auth $SECRET 1> ./radclient.log
32     if [ "$?" = "0" ]; then
33       echo "${BASE}_${NUMBER} : Success"
34     else
35       echo "${BASE}_${NUMBER} : FAILED"
36       cat ./radclient.log
37       RCODE=1
38     fi
39   done
40 done
41
42
43 if [ "$RCODE" = "0" ]
44 then
45     rm -f radiusd.log radclient.log
46     echo "All tests succeeded"
47 else
48     echo "See radclient.log for more details"
49 fi
50
51 exit $RCODE