aboutsummaryrefslogtreecommitdiffstats
path: root/test/auto/autotest.sh
blob: 0fb7565af6e9e2d78a5cf0c37e00072a8dfcf605 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash

arr[1]="TEST 1: svn and standard compilation"
arr[2]="TEST 2: cppcheck"
arr[3]="TEST 3: compile seccomp disabled, chroot disabled, bind disabled"
arr[4]="TEST 4: rvtest"
arr[5]="TEST 5: expect test as root, no malloc perturb"
arr[6]="TEST 6: expect test as user, no malloc perturb"
arr[7]="TEST 7: expect test as root, malloc perturb"
arr[8]="TEST 8: expect test as user, malloc perturb"


# remove previous reports and output file
cleanup() {
	rm -f out-test
	rm -f output*
	rm -f report*
	rm -fr firejail-trunk
}

print_title() {
	echo
	echo
	echo
	echo "**************************************************"
	echo $1
	echo "**************************************************"
}

while [ $# -gt 0 ]; do    # Until you run out of parameters . . .
    case "$1" in
    --clean)
    	cleanup
    	exit
	;;
    --help)
    	echo "./autotest.sh [--clean|--help]"
    	exit
    	;;
    esac
    shift       # Check next set of parameters.
done

cleanup
# enable sudo
sudo ls -al

#*****************************************************************
# TEST 1
#*****************************************************************
# - checkout source code
# - check compilation
# - install
#*****************************************************************
print_title "${arr[1]}"
svn checkout svn://svn.code.sf.net/p/firejail/code-0/trunk firejail-trunk
cd firejail-trunk
./configure --prefix=/usr 2>&1 | tee ../output-configure
make -j4 2>&1 | tee ../output-make
sudo make install 2>&1 | tee ../output-install
cd src/tools
gcc -o rvtest rvtest.c
cd ../..
cd test
sudo ./configure > /dev/null
cd ../..
grep warning output-configure output-make output-install > ./report-test1
grep error output-configure output-make output-install >> ./report-test1
cat report-test1 > out-test1

#*****************************************************************
# TEST 2
#*****************************************************************
# - run cppcheck
#*****************************************************************
print_title "${arr[2]}"
cd firejail-trunk
cp /home/netblue/bin/cfg/std.cfg .
cppcheck --force . 2>&1 | tee ../output-cppcheck
cd ..
grep error output-cppcheck > report-test2
cat report-test2 > out-test2

#*****************************************************************
# TEST 3
#*****************************************************************
# - disable seccomp configuration
# - check compilation
#*****************************************************************
print_title "${arr[3]}"
# seccomp
cd firejail-trunk
make distclean
./configure --prefix=/usr --disable-seccomp 2>&1 | tee ../output-configure-noseccomp
make -j4 2>&1 | tee ../output-make-noseccomp
cd ..
grep warning output-configure-noseccomp output-make-noseccomp > ./report-test3
grep error output-configure-noseccomp output-make-noseccomp >> ./report-test3
# chroot
cd firejail-trunk
make distclean
./configure --prefix=/usr --disable-chroot 2>&1 | tee ../output-configure-nochroot
make -j4 2>&1 | tee ../output-make-nochroot
cd ..
grep warning output-configure-nochroot output-make-nochroot >> ./report-test3
grep error output-configure-nochroot output-make-nochroot >> ./report-test3
# bind
cd firejail-trunk
make distclean
./configure --prefix=/usr --disable-bind 2>&1 | tee ../output-configure-nobind
make -j4 2>&1 | tee ../output-make-nobind
cd ..
grep warning output-configure-nobind output-make-nobind >> ./report-test3
grep error output-configure-nobind output-make-nobind >> ./report-test3
# save result
cat report-test3 > out-test3

#*****************************************************************
# TEST 4
#*****************************************************************
# - rvtest
#*****************************************************************
print_title "${arr[4]}"
cd firejail-trunk
cd test
../src/tools/rvtest test.rv 2>/dev/null | tee ../../output-test4 | grep TESTING
cd ../..
grep TESTING output-test4 > ./report-test4
grep ERROR report-test4 > out-test4


#*****************************************************************
# TEST 5
#*****************************************************************
# - expect test as root, no malloc perturb
#*****************************************************************
print_title "${arr[5]}"
cd firejail-trunk/test
sudo ./test-root.sh 2>&1 | tee ../../output-test5 | grep TESTING
cd ../..
grep TESTING output-test5 > ./report-test5
grep ERROR report-test5 > out-test5

#*****************************************************************
# TEST 6
#*****************************************************************
# - expect test as user, no malloc perturb
#*****************************************************************
print_title "${arr[6]}"
cd firejail-trunk/test
./test.sh 2>&1 | tee ../../output-test6 | grep TESTING
cd ../..
grep TESTING output-test6 > ./report-test6
grep ERROR report-test6 > out-test6



#*****************************************************************
# TEST 7
#*****************************************************************
# - expect test as root, malloc perturb
#*****************************************************************
print_title "${arr[7]}"
export MALLOC_CHECK_=3
export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
cd firejail-trunk/test
sudo ./test-root.sh 2>&1 | tee ../../output-test7 | grep TESTING
cd ../..
grep TESTING output-test7 > ./report-test7
grep ERROR report-test7 > out-test7

#*****************************************************************
# TEST 8
#*****************************************************************
# - expect test as user, malloc perturb
#*****************************************************************
print_title "${arr[8]}"
cd firejail-trunk/test
./test.sh 2>&1 | tee ../../output-test8| grep TESTING
cd ../..
grep TESTING output-test8 > ./report-test8
grep ERROR report-test8 > out-test8

#*****************************************************************
# PRINT REPORTS
#*****************************************************************
echo
echo
echo
echo
echo "**********************************************************"
echo "TEST RESULTS"
echo "**********************************************************"

wc -l out-test*
rm out-test*
echo




exit