Skip to content

Commit 60f333f

Browse files
committed
Improved test scripts
1 parent 74df1a7 commit 60f333f

File tree

8 files changed

+114
-21
lines changed

8 files changed

+114
-21
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
gmon.out
2-
report_*.txt
1+
unittest/gmon.out
2+
unittest/_*.txt
33

44
# -----------------------------------------------------------------------------
55
# Compiled sources

unittest/clean.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
if [ -f unittest.c ]
3+
then
4+
rm -f _*.txt gmon.out
5+
fi

unittest/run_all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ echo ""
66
./run_sanitizer.sh
77
./run_gprof.sh
88
./run_valgrind.sh
9+
./run_compare.sh
910
echo ""
1011
echo "Done"

unittest/run_compare.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/sh
2+
REPORT=_report_compare.txt
3+
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
4+
5+
NEW=../utility/mapcode
6+
OLD=$HOME/bin/mapcode-2.3.1
7+
8+
OPTS1="--grid 1000000 8"
9+
OPTS2="--random 1000000 8 1234"
10+
OPTS3="--random 1000000 8 11223344"
11+
12+
TEST=`which $OLD`
13+
if [ "$TEST" = "" ]
14+
then
15+
echo "No $OLD found on this machine - skipping script..."
16+
exit 1
17+
fi
18+
19+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
20+
echo "Run compare with previous output..." | tee $REPORT
21+
date | tee -a $REPORT
22+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
23+
24+
echo "" | tee -a $REPORT
25+
echo "Run with: -O3" | tee -a $REPORT
26+
cd ../mapcodelib
27+
gcc $OPTS -O3 -c mapcoder.c
28+
cd ../utility
29+
gcc $OPTS -O3 mapcode.cpp -lm -o mapcode ../mapcodelib/mapcoder.o
30+
cd ../unittest
31+
32+
TEST=`which $NEW`
33+
if [ "$TEST" = "" ]
34+
then
35+
echo "No $NEW found on this machine - skipping script..."
36+
exit 1
37+
fi
38+
39+
echo ""
40+
echo "Execute: $NEW $OPTS1" | tee -a $REPORT
41+
$NEW | grep version | tee -a $REPORT
42+
$NEW $OPTS1 > _new_1.txt | tee -a $REPORT
43+
44+
echo ""
45+
echo "Execute: $OLD $OPTS1" | tee -a $REPORT
46+
$OLD | grep version | tee -a $REPORT
47+
$OLD $OPTS1 > _old_1.txt | tee -a $REPORT
48+
diff _new_1.txt _old_1.txt | tee -a $REPORT
49+
if [ $? -ne 0 ]
50+
then
51+
echo "ERROR: Diffs found with: " $OPTS1 | tee -a $REPORT
52+
fi
53+
54+
echo ""
55+
echo "Execute: $NEW $OPTS2" | tee -a $REPORT
56+
$NEW | grep version | tee -a $REPORT
57+
$NEW $OPTS2 > _new_2.txt | tee -a $REPORT
58+
59+
echo ""
60+
echo "Execute: $OLD $OPTS2" | tee -a $REPORT
61+
$OLD | grep version | tee -a $REPORT
62+
$OLD $OPTS2 > _old_2.txt | tee -a $REPORT
63+
diff _new_2.txt _old_2.txt | tee -a $REPORT
64+
if [ $? -ne 0 ]
65+
then
66+
echo "ERROR: Diffs found with: " $OPTS2 | tee -a $REPORT
67+
fi
68+
69+
echo ""
70+
echo "Execute: $NEW $OPTS3" | tee -a $REPORT
71+
$NEW | grep version | tee -a $REPORT
72+
$NEW $OPTS3 > _new_3.txt | tee -a $REPORT
73+
74+
echo ""
75+
echo "Execute: $OLD $OPTS3" | tee -a $REPORT
76+
$OLD | grep version | tee -a $REPORT
77+
$OLD $OPTS3 > _old_3.txt | tee -a $REPORT
78+
diff _new_3.txt _old_3.txt | tee -a $REPORT
79+
if [ $? -ne 0 ]
80+
then
81+
echo "ERROR: Diffs found with: " $OPTS3 | tee -a $REPORT
82+
fi
83+
84+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
85+
86+
echo "" | tee -a $REPORT
87+
echo "Report in: $REPORT"

unittest/run_gprof.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
#!/bin/sh
2-
REPORT=report_gprof.txt
2+
REPORT=_report_gprof.txt
33
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
44
LIB="../mapcodelib/mapcoder.o"
55

6-
echo "!! -------------------------------------------------------------" | tee -a $REPORT
7-
echo "Run gprof profiler..." | tee $REPORT
8-
date | tee -a $REPORT
9-
echo "!! -------------------------------------------------------------" | tee -a $REPORT
10-
116
TEST=`which gprof`
127
if [ "$TEST" = "" ]
138
then
149
echo "No gprof found on this machine - skipping script..."
1510
exit 1
1611
fi
1712

13+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
14+
echo "Run gprof profiler..." | tee $REPORT
15+
date | tee -a $REPORT
16+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
17+
1818
echo "" | tee -a $REPORT
1919
echo "Run with: -O0" | tee -a $REPORT
2020
cd ../mapcodelib

unittest/run_normal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
REPORT=report_normal.txt
2+
REPORT=_report_normal.txt
33
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
44

55
echo "!! -------------------------------------------------------------" | tee -a $REPORT

unittest/run_sanitizer.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/bin/sh
2-
REPORT=report_sanitizer.txt
2+
REPORT=_report_sanitizer.txt
33
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
44
LIB="../mapcodelib/mapcoder.o"
55

66
export ASAN_OPTIONS=debug=true:strict_string_checks=1:detect_stack_use_after_return=true:detect_invalid_pointer_pairs=99999:detect_container_overflow=true:detect_odr_violation=2:check_initialization_order=true:strict_init_order=true
77

8-
echo "!! -------------------------------------------------------------" | tee -a $REPORT
9-
echo "Run address sanitizer..." | tee $REPORT
10-
date | tee -a $REPORT
11-
echo "!! -------------------------------------------------------------" | tee -a $REPORT
12-
138
TEST=`which clang`
149
if [ "$TEST" = "" ]
1510
then
1611
echo "No clang found on this machine - skipping script..."
1712
exit 1
1813
fi
1914

15+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
16+
echo "Run address sanitizer..." | tee $REPORT
17+
date | tee -a $REPORT
18+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
19+
2020
# No optimize
2121
echo "" | tee -a $REPORT
2222
echo "Run with: -O0" | tee -a $REPORT

unittest/run_valgrind.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
#!/bin/sh
2-
REPORT=report_valgrind.txt
2+
REPORT=_report_valgrind.txt
33
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
44
LIB="../mapcodelib/mapcoder.o"
55

6-
echo "!! -------------------------------------------------------------" | tee -a $REPORT
7-
echo "Run valgrind" | tee $REPORT
8-
date | tee -a $REPORT
9-
echo "!! -------------------------------------------------------------" | tee -a $REPORT
10-
116
TEST=`which valgrind`
127
if [ "$TEST" = "" ]
138
then
149
echo "No valgrind found on this machine - skipping script..."
1510
exit 1
1611
fi
1712

13+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
14+
echo "Run valgrind" | tee $REPORT
15+
date | tee -a $REPORT
16+
echo "!! -------------------------------------------------------------" | tee -a $REPORT
17+
1818
echo "" | tee -a $REPORT
1919
echo "Run with: -O0" | tee -a report_valgrind.txt
2020
cd ../mapcodelib

0 commit comments

Comments
 (0)