Skip to content

Commit 3f40b77

Browse files
committed
Updated scripts
1 parent e3eda03 commit 3f40b77

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

unittest/run_all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ echo "Run all tests..."
22
date
33
echo ""
44
./run_normal.sh
5-
# ./run_sanitizer.sh
5+
./run_sanitizer.sh
66
./run_gprof.sh
77
./run_valgrind.sh
88
echo ""

unittest/run_gprof.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
REPORT=report_gprof.txt
22
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
3+
LIB="../mapcodelib/mapcoder.o"
34

45
echo "Run gprof profiler..." | tee $REPORT
56
date | tee -a $REPORT
@@ -9,7 +10,7 @@ echo "Run with: -O0" | tee -a $REPORT
910
cd ../mapcodelib
1011
gcc $OPTS -g -O0 -c mapcoder.c -pg
1112
cd ../unittest
12-
gcc $OPTS -g -O0 unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o -pg
13+
gcc $OPTS -g -O0 unittest.c -lm -lpthread -o unittest $LIB -pg
1314
./unittest | tee -a $REPORT
1415
gprof ./unittest | tee -a $REPORT
1516
echo "----------------" | tee -a $REPORT
@@ -19,7 +20,7 @@ echo "Run with: -O3" | tee -a $REPORT
1920
cd ../mapcodelib
2021
gcc $OPTS -g -O3 -c mapcoder.c -pg
2122
cd ../unittest
22-
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o -pg
23+
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest $LIB -pg
2324
./unittest | tee -a $REPORT
2425
gprof ./unittest | tee -a $REPORT
2526
echo "----------------" | tee -a $REPORT

unittest/run_sanitizer.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
REPORT=report_sanitizer.txt
22
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
3+
LIB="../mapcodelib/mapcoder.o"
34

45
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
56

@@ -12,39 +13,39 @@ echo "Run with: -O0" | tee -a $REPORT
1213
cd ../mapcodelib
1314
gcc $OPTS -O0 -DDEBUG -c mapcoder.c
1415
cd ../unittest
15-
gcc $OPTS -O0 -DDEBUG unittest.c -lm -lpthread -fsanitize=address -o unittest
16+
gcc $OPTS -O0 -DDEBUG unittest.c -lm -lpthread -fsanitize=address -o unittest $LIB
1617
./unittest | tee -a $REPORT
17-
echo "----------------" | tee -a $REPORT sanitize.txt
18+
echo "----------------" | tee -a $REPORT
1819

1920
# Optimize 1
2021
echo "" | tee -a $REPORT
21-
echo "Run with: -O1" | tee -a $REPORT sanitize.txt
22+
echo "Run with: -O1" | tee -a $REPORT
2223
cd ../mapcodelib
2324
gcc $OPTS -O1 -c mapcoder.c
2425
cd ../unittest
25-
gcc $OPTS -O1 unittest.c -lm -lpthread -fsanitize=address -o unittest
26+
gcc $OPTS -O1 unittest.c -lm -lpthread -fsanitize=address -o unittest $LINK
2627
./unittest | tee -a $REPORT
27-
echo "----------------" | tee -a $REPORT sanitize.txt
28+
echo "----------------" | tee -a $REPORT
2829

2930
# Optimize 2
3031
echo "" | tee -a $REPORT
31-
echo "Run with: -O2" | tee -a $REPORT sanitize.txt
32+
echo "Run with: -O2" | tee -a $REPORT
3233
cd ../mapcodelib
3334
gcc $OPTS -O2 -c mapcoder.c
3435
cd ../unittest
35-
gcc $OPTS -O2 unittest.c -lm -lpthread -fsanitize=address -o unittest
36+
gcc $OPTS -O2 unittest.c -lm -lpthread -fsanitize=address -o unittest $LIB
3637
./unittest | tee -a $REPORT
37-
echo "----------------" | tee -a $REPORT sanitize.txt
38+
echo "----------------" | tee -a $REPORT
3839

3940
# Optimize 3
4041
echo "" | tee -a $REPORT
41-
echo "Run with: -O3" | tee -a $REPORT sanitize.txt
42+
echo "Run with: -O3" | tee -a $REPORT
4243
cd ../mapcodelib
4344
gcc $OPTS -O3 -c mapcoder.c
4445
cd ../unittest
45-
gcc $OPTS -O3 unittest.c -lm -lpthread -fsanitize=address -o unittest
46+
gcc $OPTS -O3 unittest.c -lm -lpthread -fsanitize=address -o unittest $LIB
4647
./unittest | tee -a $REPORT
47-
echo "----------------" | tee -a $REPORT sanitize.txt
48+
echo "----------------" | tee -a $REPORT
4849

4950
echo "" | tee -a $REPORT
5051
echo "Report in: $REPORT"

unittest/run_valgrind.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
REPORT=report_valgrind.txt
22
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
3+
LIB="../mapcodelib/mapcoder.o"
34

45
echo "Run valgrind" | tee $REPORT
56

@@ -8,7 +9,7 @@ echo "Run with: -O0" | tee -a report_valgrind.txt
89
cd ../mapcodelib
910
gcc $OPTS -g -O0 -DDEBUG -c mapcoder.c
1011
cd ../unittest
11-
gcc $OPTS -g -O0 -DDEBUG unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o
12+
gcc $OPTS -g -O0 -DDEBUG unittest.c -lm -lpthread -o unittest $LIB
1213
valgrind --leak-check=yes ./unittest | tee -a $REPORT
1314
echo "----------------" tee -a $REPORT
1415

@@ -17,7 +18,7 @@ echo "Run with: -O3" | tee -a report_valgrind.txt
1718
cd ../mapcodelib
1819
gcc $OPTS -g -O3 -c mapcoder.c
1920
cd ../unittest
20-
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o
21+
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest $LIB
2122
valgrind --leak-check=yes ./unittest | tee -a $REPORT
2223
echo "----------------" tee -a $REPORT
2324

unittest/unittest.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ static const double METERS_PER_DEGREE_LON = 111319.490793;
5757
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
5858
#endif
5959

60+
#define REF(x) if (x) {} else {}
61+
6062
static int nrErrors = 0;
6163

6264

@@ -2039,8 +2041,7 @@ int main(const int argc, const char **argv) {
20392041
int nrTests = 0;
20402042

20412043
// Ref unused var.
2042-
if (ISO3166_ALPHA[0] == 0) {
2043-
}
2044+
REF(ISO3166_ALPHA[0]);
20442045

20452046
printf("Mapcode C Library Unit Tests\n");
20462047
printf("Library version %s (data version %s)\n", MAPCODE_C_VERSION, MAPCODE_DATA_VERSION);

0 commit comments

Comments
 (0)