Added
Link Here
|
1 |
--- Testing/test.sh.orig 2020-02-16 01:55:44 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 |
@@ -10,26 +10,23 @@ echoerr() { echo "$@" 1>&2; } |
10 |
## Set LD_LIBRARY_PATH so that tlsh can pick up the tlsh shared library |
11 |
export LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH |
12 |
BASEDIR=$(dirname $0) |
13 |
-pushd $BASEDIR > /dev/null |
14 |
+cd $BASEDIR |
15 |
|
16 |
if test ! -f ../bin/tlsh |
17 |
then |
18 |
echoerr "error: (127), you must compile tlsh" |
19 |
- popd > /dev/null |
20 |
exit 127 |
21 |
fi |
22 |
|
23 |
if test ! -f ../bin/simple_unittest |
24 |
then |
25 |
echoerr "error: (127), you must compile ../bin/simple_unittest" |
26 |
- popd > /dev/null |
27 |
exit 127 |
28 |
fi |
29 |
|
30 |
if test ! -f ../bin/tlsh_version |
31 |
then |
32 |
echoerr "error: (127), you must compile ../bin/tlsh_version" |
33 |
- popd > /dev/null |
34 |
exit 127 |
35 |
fi |
36 |
|
37 |
@@ -91,7 +88,6 @@ runit() { |
38 |
if test $CREATE_EXP_FILE = 0 |
39 |
then |
40 |
echoerr "error: (1), Expected Result file $EXPECTED_OUT does not exist" |
41 |
- popd > /dev/null |
42 |
exit 1 |
43 |
else |
44 |
echo "cp $TMP/example_data.out $EXPECTED_OUT" |
45 |
@@ -103,7 +99,6 @@ runit() { |
46 |
if test $CREATE_EXP_FILE = 0 |
47 |
then |
48 |
echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" |
49 |
- popd > /dev/null |
50 |
exit 1 |
51 |
else |
52 |
echo "cp $TMP/example_data.err $EXPECTED_ERR" |
53 |
@@ -115,7 +110,6 @@ runit() { |
54 |
if test ! $diffc = 0 |
55 |
then |
56 |
echoerr "error: (1), diff $TMP/example_data.out $EXPECTED_OUT" |
57 |
- popd > /dev/null |
58 |
exit 1 |
59 |
fi |
60 |
|
61 |
@@ -123,7 +117,6 @@ runit() { |
62 |
if test ! $diffc = 0 |
63 |
then |
64 |
echoerr "error: (1), diff $TMP/example_data.err $EXPECTED_ERR" |
65 |
- popd > /dev/null |
66 |
exit 1 |
67 |
fi |
68 |
|
69 |
@@ -154,7 +147,6 @@ runit() { |
70 |
if test $CREATE_EXP_FILE = 0 |
71 |
then |
72 |
echoerr "error: (1), Expected Result file $EXPECTED_SCO does not exist" |
73 |
- popd > /dev/null |
74 |
exit 1 |
75 |
else |
76 |
echo "cp $TMP/example_data.scores $EXPECTED_SCO" |
77 |
@@ -166,7 +158,6 @@ runit() { |
78 |
if test $CREATE_EXP_FILE = 0 |
79 |
then |
80 |
echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" |
81 |
- popd > /dev/null |
82 |
exit 1 |
83 |
else |
84 |
echo "cp $TMP/example_data.err2 $EXPECTED_ERR" |
85 |
@@ -178,14 +169,12 @@ runit() { |
86 |
if test ! $diffc = 0 |
87 |
then |
88 |
echoerr "error: (2), diff $TMP/example_data.scores $EXPECTED_SCO" |
89 |
- popd > /dev/null |
90 |
exit 2 |
91 |
fi |
92 |
diffc=`diff --ignore-all-space $TMP/example_data.err2 $EXPECTED_ERR | wc -l` |
93 |
if test ! $diffc = 0 |
94 |
then |
95 |
echoerr "error: (2), diff $TMP/example_data.err2 $EXPECTED_ERR" |
96 |
- popd > /dev/null |
97 |
exit 2 |
98 |
fi |
99 |
|
100 |
@@ -218,7 +207,6 @@ runit() { |
101 |
if test $CREATE_EXP_FILE = 0 |
102 |
then |
103 |
echoerr "error: (3), Expected Result file $EXPECTED_SCO does not exist" |
104 |
- popd > /dev/null |
105 |
exit 1 |
106 |
else |
107 |
echo "cp $TMP/example_data.scores.2 $EXPECTED_SCO" |
108 |
@@ -230,7 +218,6 @@ runit() { |
109 |
if test ! $diffc = 0 |
110 |
then |
111 |
echoerr "error: (3) diff $TMP/example_data.scores.2 $EXPECTED_SCO" |
112 |
- popd > /dev/null |
113 |
exit 3 |
114 |
fi |
115 |
|
116 |
@@ -259,7 +246,6 @@ runit() { |
117 |
if test $CREATE_EXP_FILE = 0 |
118 |
then |
119 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" |
120 |
- popd > /dev/null |
121 |
exit 1 |
122 |
else |
123 |
echo "cp $TMP/example_data.xref.scores $EXPECTED_SCO" |
124 |
@@ -270,7 +256,6 @@ runit() { |
125 |
diff --ignore-all-space $TMP/example_data.xref.scores $EXPECTED_SCO > /dev/null 2>/dev/null |
126 |
if [ $? -ne 0 ]; then |
127 |
echoerr "error: ($testnum), diff $TMP/example_data.xref.scores $EXPECTED_SCO" |
128 |
- popd > /dev/null |
129 |
exit $testnum |
130 |
fi |
131 |
|
132 |
@@ -301,7 +286,6 @@ runit() { |
133 |
if test $CREATE_EXP_FILE = 0 |
134 |
then |
135 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" |
136 |
- popd > /dev/null |
137 |
exit 1 |
138 |
else |
139 |
echo "cp $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" |
140 |
@@ -312,7 +296,6 @@ runit() { |
141 |
diff --ignore-all-space $TMP/example_data.scores.2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null |
142 |
if [ $? -ne 0 ]; then |
143 |
echoerr "error: ($testnum) diff $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" |
144 |
- popd > /dev/null |
145 |
exit $testnum |
146 |
fi |
147 |
|
148 |
@@ -351,7 +334,6 @@ then |
149 |
if test $CREATE_EXP_FILE = 0 |
150 |
then |
151 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_TESTLEN does not exist" |
152 |
- popd > /dev/null |
153 |
exit 1 |
154 |
else |
155 |
echo "cp $TMP/testlen.out $EXPECTED_TESTLEN" |
156 |
@@ -362,7 +344,6 @@ fi |
157 |
diff --ignore-all-space $TMP/testlen.out $EXPECTED_TESTLEN > /dev/null 2>/dev/null |
158 |
if [ $? -ne 0 ]; then |
159 |
echoerr "error: ($testnum) diff $TMP/testlen.out $EXPECTED_TESTLEN" |
160 |
- popd > /dev/null |
161 |
exit $testnum |
162 |
fi |
163 |
echo "passed" |
164 |
@@ -390,7 +371,6 @@ for file in small small2 ; do |
165 |
if test $CREATE_EXP_FILE = 0 |
166 |
then |
167 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_TLSH does not exist" |
168 |
- popd > /dev/null |
169 |
exit 1 |
170 |
else |
171 |
echo "cp $TMP/$file.tlsh $EXPECTED_TLSH" |
172 |
@@ -401,7 +381,6 @@ for file in small small2 ; do |
173 |
diff --ignore-all-space $TMP/$file.tlsh $EXPECTED_TLSH |
174 |
if [ $? -ne 0 ]; then |
175 |
echoerr "error: ($testnum) $TMP/$file.tlsh $EXPECTED_TLSH" |
176 |
- popd > /dev/null |
177 |
exit $testnum |
178 |
fi |
179 |
done |
180 |
@@ -432,14 +411,12 @@ EXPECTED_SCO=exp/example_data.$HASH.$CHKSUM.len.scores |
181 |
if test ! -f $EXPECTED_SCO |
182 |
then |
183 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" |
184 |
- popd > /dev/null |
185 |
exit 1 |
186 |
fi |
187 |
|
188 |
diff --ignore-all-space $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null |
189 |
if [ $? -ne 0 ]; then |
190 |
echoerr "error: ($testnum) diff $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO" |
191 |
- popd > /dev/null |
192 |
exit $testnum |
193 |
fi |
194 |
|
195 |
@@ -454,7 +431,6 @@ echo "../bin/${TLSH_PROG} -T 201 -l2 -lcsv -l example_ |
196 |
diff --ignore-all-space $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null |
197 |
if [ $? -ne 0 ]; then |
198 |
echoerr "error: ($testnum) diff $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO" |
199 |
- popd > /dev/null |
200 |
exit $testnum |
201 |
fi |
202 |
|
203 |
@@ -480,14 +456,12 @@ EXPECTED_RES=exp/example_data.Week3.split.tlsh |
204 |
if test ! -f $EXPECTED_RES |
205 |
then |
206 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_RES does not exist" |
207 |
- popd > /dev/null |
208 |
exit 1 |
209 |
fi |
210 |
|
211 |
diff --ignore-all-space $TMP/example_data.Week3.split.tlsh $EXPECTED_RES > /dev/null 2>/dev/null |
212 |
if [ $? -ne 0 ]; then |
213 |
echoerr "error: ($testnum) diff $TMP/example_data.Week3.split.tlsh $EXPECTED_RES" |
214 |
- popd > /dev/null |
215 |
exit $testnum |
216 |
fi |
217 |
|
218 |
@@ -512,7 +486,6 @@ then |
219 |
if test $CREATE_EXP_FILE = 0 |
220 |
then |
221 |
echoerr "error: ($testnum), Expected Result file $EXPECTED_STEST does not exist" |
222 |
- popd > /dev/null |
223 |
exit 1 |
224 |
else |
225 |
echo "cp $TMP/simple_unittest.out $EXPECTED_STEST" |
226 |
@@ -523,13 +496,10 @@ fi |
227 |
diff --ignore-all-space $TMP/simple_unittest.out $EXPECTED_STEST > /dev/null 2>/dev/null |
228 |
if [ $? -ne 0 ]; then |
229 |
echoerr "error: ($testnum) diff $TMP/simple_unittest.out $EXPECTED_STEST" |
230 |
- popd > /dev/null |
231 |
- exit -1 |
232 |
+ exit 255 |
233 |
fi |
234 |
|
235 |
echo "passed all example data tests" |
236 |
- |
237 |
-popd > /dev/null |
238 |
|
239 |
echo |
240 |
echo "If you have made changes to the Tlsh python module, build and install it, and run python_test.sh" |