root/branches/mls/testall.sh

Revision 1863, 2.1 kB (checked in by gboyst, 1 year ago)

changed testall.sh so is command line param

  • Property svn:executable set to *
Line 
1 #!/bin/bash
2
3 STARTDIR=`pwd`
4
5 BUILD=1
6 INFO=0
7 SEMANTIC=0
8 POLHEADERS=0
9
10 for PARAM in $@; do
11     case $PARAM in
12        
13         ("-i")
14         shift;
15         BUILD=0;
16         INFO=1;;
17        
18         ("-r")
19         shift;
20         BUILD=0;;
21        
22         ("-s")
23         shift;
24         POLHEADERS="$1";
25         shift;
26         SEMANTIC=1;;
27        
28         ("-h")
29         echo
30         echo Usage: $0
31         echo -i display info about each test
32         echo -r run only - do not rebuild compiler
33         echo "-s <path> also run semantic diff <path - path to reference policy header - with cdsframework support files>"
34         echo -h help;
35         echo;
36         exit;
37         ;;
38     esac
39 done;
40
41 if [ $BUILD -eq 1 ]; then
42     echo Compiling
43 # build command line test program if it doesn't exist
44 #if [ ! -e build/com/tresys/framework/compiler/Compiler.java ]; then
45 #       make -C libapoljava
46     make --quiet -C framework-plugin/libselinuxjava
47     ant -q -f compilerbuild.xml compile
48 #fi;
49 fi;
50
51 #check to make sure that support for semantic diff has been set up
52 if [ $SEMANTIC -eq 1 ]; then
53     if [ $POLHEADERS ]; then
54         if [ ! -f $POLHEADERS/support/cdsframework.spt ]; then
55             echo "Missing CDS Framework support file in headers"
56             SEMANTIC=0
57         fi
58     else
59         echo "POLHEADERS environment variable not set, will not perform semantic diff"
60         SEMANTIC=0
61     fi
62 fi
63
64 LIBSELINUX=`pwd`/framework-plugin/libselinuxjava/libselinuxjava.so
65
66 # list of all tests
67 ALLTESTS=`ls test | egrep test[0-9]{4}`
68 declare -a ERRORTESTS
69
70 # loop through each test directory
71 for TEST in $ALLTESTS; do
72     DIR=test/$TEST
73     echo -n Test: $TEST " "
74    
75     if [ $INFO -eq 0 ]; then
76         if [ ! -e $DIR/test.sh ]; then
77             echo - skipping test
78             ERRORTESTS[${#ERRORTESTS[*]}]=$TEST
79             continue
80         fi;
81        
82         cd $DIR
83         source test.sh
84         cd $STARTDIR
85         if [ $RESULT -ne 0 ]; then
86             ERRORTESTS[${#ERRORTESTS[*]}]=$TEST
87         fi;
88     fi;
89     if [ $INFO -eq 1 ]; then
90         echo -n ",\""
91         if [ -e $DIR/README ]; then
92             cat $DIR/README
93         else
94             echo -n Missing!
95         fi;
96         echo  -n "\""
97         echo
98     fi;
99 done;
100
101 if [ $INFO -eq 0 ]; then
102     echo
103     echo
104         # report each test that failed
105     if [ ${#ERRORTESTS} -gt 0 ]; then
106         echo The following tests have errors
107         echo ${ERRORTESTS[@]}
108     else
109         echo All tests ran successfully
110     fi;
111 fi;
Note: See TracBrowser for help on using the browser.