Added
Link Here
|
1 |
--- Testing/test.sh.orig 2020-12-10 01:30:11 UTC |
2 |
+++ Testing/test.sh |
3 |
@@ -1,4 +1,4 @@ |
4 |
-#!/bin/bash |
5 |
+#!/bin/sh |
6 |
|
7 |
################################## |
8 |
# set CREATE_EXP_FILE=1 if you want this script to create the Expected Results for the regression tests |
9 |
@@ -8,7 +8,7 @@ CREATE_EXP_FILE=0 |
10 |
echoerr() { echo "$@" 1>&2; } |
11 |
|
12 |
BASEDIR=$(dirname $0) |
13 |
-pushd $BASEDIR > /dev/null |
14 |
+cd $BASEDIR |
15 |
|
16 |
LISTOPTION=1 |
17 |
JSONOPTION=1 |
18 |
@@ -34,14 +34,12 @@ echo "TLSH_PROG=$TLSH_PROG" |
19 |
if test ! -f $TLSH_PROG |
20 |
then |
21 |
echoerr "error: (127), you must compile $TLSH_PROG" |
22 |
- popd > /dev/null |
23 |
exit 127 |
24 |
fi |
25 |
|
26 |
if test ! -f $SIMP_PROG |
27 |
then |
28 |
echoerr "error: (127), you must compile $SIMP_PROG" |
29 |
- popd > /dev/null |
30 |
exit 127 |
31 |
fi |
32 |
|
33 |
@@ -104,7 +102,6 @@ runit() { |
34 |
if test ! -f $TMP/example_data.out |
35 |
then |
36 |
echoerr "error: (1), $TMP/example_data.out does not exist" |
37 |
- popd > /dev/null |
38 |
exit 1 |
39 |
fi |
40 |
EXPECTED_OUT=exp/example_data.$HASH.$CHKSUM.$XLEN.out_EXP |
41 |
@@ -114,7 +111,6 @@ runit() { |
42 |
if test $CREATE_EXP_FILE = 0 |
43 |
then |
44 |
echoerr "error: (1), Expected Result file $EXPECTED_OUT does not exist" |
45 |
- popd > /dev/null |
46 |
exit 1 |
47 |
else |
48 |
echo "cp $TMP/example_data.out $EXPECTED_OUT" |
49 |
@@ -126,7 +122,6 @@ runit() { |
50 |
if test $CREATE_EXP_FILE = 0 |
51 |
then |
52 |
echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" |
53 |
- popd > /dev/null |
54 |
exit 1 |
55 |
else |
56 |
echo "cp $TMP/example_data.err $EXPECTED_ERR" |
57 |
@@ -137,7 +132,6 @@ runit() { |
58 |
if test ! $diffc = 0 |
59 |
then |
60 |
echoerr "error: (1), diff $TMP/example_data.out $EXPECTED_OUT" |
61 |
- popd > /dev/null |
62 |
exit 1 |
63 |
fi |
64 |
|
65 |
@@ -145,7 +139,6 @@ runit() { |
66 |
if test ! $diffc = 0 |
67 |
then |
68 |
echoerr "error: (1), diff $TMP/example_data.err $EXPECTED_ERR" |
69 |
- popd > /dev/null |
70 |
exit 1 |
71 |
fi |
72 |
|
73 |
@@ -160,7 +153,6 @@ runit() { |
74 |
if test ! $diffc = 0 |
75 |
then |
76 |
echoerr "error: (1), diff $TMP/example_data.json_out $EXPECTED_OUT" |
77 |
- popd > /dev/null |
78 |
exit 1 |
79 |
fi |
80 |
echo "passed" |
81 |
@@ -194,7 +186,6 @@ runit() { |
82 |
if test $CREATE_EXP_FILE = 0 |
83 |
then |
84 |
echoerr "error: (1), Expected Result file $EXPECTED_SCO does not exist" |
85 |
- popd > /dev/null |
86 |
exit 1 |
87 |
else |
88 |
echo "cp $TMP/example_data.scores $EXPECTED_SCO" |
89 |
@@ -206,7 +197,6 @@ runit() { |
90 |
if test $CREATE_EXP_FILE = 0 |
91 |
then |
92 |
echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" |
93 |
- popd > /dev/null |
94 |
exit 1 |
95 |
else |
96 |
echo "cp $TMP/example_data.err2 $EXPECTED_ERR" |
97 |
@@ -218,14 +208,12 @@ runit() { |
98 |
if test ! $diffc = 0 |
99 |
then |
100 |
echoerr "error: (2), diff $TMP/example_data.scores $EXPECTED_SCO" |
101 |
- popd > /dev/null |
102 |
exit 2 |
103 |
fi |
104 |
diffc=`diff --ignore-all-space $TMP/example_data.err2 $EXPECTED_ERR | wc -l` |
105 |
if test ! $diffc = 0 |
106 |
then |
107 |
echoerr "error: (2), diff $TMP/example_data.err2 $EXPECTED_ERR" |
108 |
- popd > /dev/null |
109 |
exit 2 |
110 |
fi |
111 |
|
112 |
@@ -260,7 +248,6 @@ runit() { |
113 |
if test $CREATE_EXP_FILE = 0 |
114 |
then |
115 |
echoerr "error: (3), Expected Result file $EXPECTED_SCO does not exist" |
116 |
- popd > /dev/null |
117 |
exit 1 |
118 |
else |
119 |
echo "cp $TMP/example_data.scores.2 $EXPECTED_SCO" |
120 |
@@ -272,7 +259,6 @@ runit() { |
121 |
if test ! $diffc = 0 |
122 |
then |
123 |
echoerr "error: (3) diff $TMP/example_data.scores.2 $EXPECTED_SCO" |
124 |
- popd > /dev/null |
125 |
exit 3 |
126 |
fi |
127 |
|
128 |
@@ -304,7 +290,6 @@ runit() { |
129 |
if test $CREATE_EXP_FILE = 0 |
130 |
then |
131 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" |
132 |
- popd > /dev/null |
133 |
exit 1 |
134 |
else |
135 |
echo "cp $TMP/example_data.xref.scores $EXPECTED_SCO" |
136 |
@@ -315,7 +300,6 @@ runit() { |
137 |
diff --ignore-all-space $TMP/example_data.xref.scores $EXPECTED_SCO > /dev/null 2>/dev/null |
138 |
if [ $? -ne 0 ]; then |
139 |
echoerr "error: ($testnum), diff $TMP/example_data.xref.scores $EXPECTED_SCO" |
140 |
- popd > /dev/null |
141 |
exit $testnum |
142 |
fi |
143 |
|
144 |
@@ -334,7 +318,6 @@ runit() { |
145 |
diff --ignore-all-space $TMP/example_data.xref.json_scores $EXPECTED_SCO > /dev/null 2>/dev/null |
146 |
if [ $? -ne 0 ]; then |
147 |
echoerr "error: ($testnum), diff $TMP/example_data.xref.json_scores $EXPECTED_SCO" |
148 |
- popd > /dev/null |
149 |
exit $testnum |
150 |
fi |
151 |
echo "passed" |
152 |
@@ -370,7 +353,6 @@ runit() { |
153 |
if test $CREATE_EXP_FILE = 0 |
154 |
then |
155 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" |
156 |
- popd > /dev/null |
157 |
exit 1 |
158 |
else |
159 |
echo "cp $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" |
160 |
@@ -381,7 +363,6 @@ runit() { |
161 |
diff --ignore-all-space $TMP/example_data.scores.2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null |
162 |
if [ $? -ne 0 ]; then |
163 |
echoerr "error: ($testnum) diff $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" |
164 |
- popd > /dev/null |
165 |
exit $testnum |
166 |
fi |
167 |
echo "passed" |
168 |
@@ -398,7 +379,6 @@ runit |
169 |
if test "$1" = "_go" |
170 |
then |
171 |
echo "passed all example data tests (for go implementation)" |
172 |
- popd > /dev/null |
173 |
exit 0 |
174 |
fi |
175 |
runit "-xlen" |
176 |
@@ -428,7 +408,6 @@ then |
177 |
if test $CREATE_EXP_FILE = 0 |
178 |
then |
179 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_TESTLEN does not exist" |
180 |
- popd > /dev/null |
181 |
exit 1 |
182 |
else |
183 |
echo "cp $TMP/testlen.out $EXPECTED_TESTLEN" |
184 |
@@ -439,7 +418,6 @@ fi |
185 |
diff --ignore-all-space $TMP/testlen.out $EXPECTED_TESTLEN > /dev/null 2>/dev/null |
186 |
if [ $? -ne 0 ]; then |
187 |
echoerr "error: ($testnum) diff $TMP/testlen.out $EXPECTED_TESTLEN" |
188 |
- popd > /dev/null |
189 |
exit $testnum |
190 |
fi |
191 |
echo "passed" |
192 |
@@ -467,7 +445,6 @@ for file in small small2 ; do |
193 |
if test $CREATE_EXP_FILE = 0 |
194 |
then |
195 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_TLSH does not exist" |
196 |
- popd > /dev/null |
197 |
exit 1 |
198 |
else |
199 |
echo "cp $TMP/$file.tlsh $EXPECTED_TLSH" |
200 |
@@ -478,7 +455,6 @@ for file in small small2 ; do |
201 |
diff --ignore-all-space $TMP/$file.tlsh $EXPECTED_TLSH |
202 |
if [ $? -ne 0 ]; then |
203 |
echoerr "error: ($testnum) $TMP/$file.tlsh $EXPECTED_TLSH" |
204 |
- popd > /dev/null |
205 |
exit $testnum |
206 |
fi |
207 |
done |
208 |
@@ -511,14 +487,12 @@ then |
209 |
if test ! -f $EXPECTED_SCO |
210 |
then |
211 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" |
212 |
- popd > /dev/null |
213 |
exit 1 |
214 |
fi |
215 |
|
216 |
diff --ignore-all-space $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null |
217 |
if [ $? -ne 0 ]; then |
218 |
echoerr "error: ($testnum) diff $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO" |
219 |
- popd > /dev/null |
220 |
exit $testnum |
221 |
fi |
222 |
|
223 |
@@ -533,7 +507,6 @@ then |
224 |
diff --ignore-all-space $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null |
225 |
if [ $? -ne 0 ]; then |
226 |
echoerr "error: ($testnum) diff $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO" |
227 |
- popd > /dev/null |
228 |
exit $testnum |
229 |
fi |
230 |
|
231 |
@@ -563,14 +536,12 @@ then |
232 |
if test ! -f $EXPECTED_RES |
233 |
then |
234 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_RES does not exist" |
235 |
- popd > /dev/null |
236 |
exit 1 |
237 |
fi |
238 |
|
239 |
diff --ignore-all-space $TMP/example_data.Week3.split.tlsh $EXPECTED_RES > /dev/null 2>/dev/null |
240 |
if [ $? -ne 0 ]; then |
241 |
echoerr "error: ($testnum) diff $TMP/example_data.Week3.split.tlsh $EXPECTED_RES" |
242 |
- popd > /dev/null |
243 |
exit $testnum |
244 |
fi |
245 |
|
246 |
@@ -598,7 +569,6 @@ then |
247 |
if test $CREATE_EXP_FILE = 0 |
248 |
then |
249 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_STEST does not exist" |
250 |
- popd > /dev/null |
251 |
exit 1 |
252 |
else |
253 |
echo "cp $TMP/simple_unittest.out $EXPECTED_STEST" |
254 |
@@ -609,13 +579,10 @@ fi |
255 |
diff --ignore-all-space $TMP/simple_unittest.out $EXPECTED_STEST > /dev/null 2>/dev/null |
256 |
if [ $? -ne 0 ]; then |
257 |
echoerr "error: ($testnum) diff $TMP/simple_unittest.out $EXPECTED_STEST" |
258 |
- popd > /dev/null |
259 |
- exit -1 |
260 |
+ exit 255 |
261 |
fi |
262 |
|
263 |
echo "passed all example data tests" |
264 |
- |
265 |
-popd > /dev/null |
266 |
|
267 |
echo |
268 |
echo "If you have made changes to the Tlsh python module, build and install it, and run python_test.sh" |