Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated scripts
  • Loading branch information
rijnb committed Oct 31, 2016
commit 3f40b7789dc37926d4c1e35cd310ddca43ac7c64
2 changes: 1 addition & 1 deletion unittest/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ echo "Run all tests..."
date
echo ""
./run_normal.sh
# ./run_sanitizer.sh
./run_sanitizer.sh
./run_gprof.sh
./run_valgrind.sh
echo ""
Expand Down
5 changes: 3 additions & 2 deletions unittest/run_gprof.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
REPORT=report_gprof.txt
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
LIB="../mapcodelib/mapcoder.o"

echo "Run gprof profiler..." | tee $REPORT
date | tee -a $REPORT
Expand All @@ -9,7 +10,7 @@ echo "Run with: -O0" | tee -a $REPORT
cd ../mapcodelib
gcc $OPTS -g -O0 -c mapcoder.c -pg
cd ../unittest
gcc $OPTS -g -O0 unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o -pg
gcc $OPTS -g -O0 unittest.c -lm -lpthread -o unittest $LIB -pg
./unittest | tee -a $REPORT
gprof ./unittest | tee -a $REPORT
echo "----------------" | tee -a $REPORT
Expand All @@ -19,7 +20,7 @@ echo "Run with: -O3" | tee -a $REPORT
cd ../mapcodelib
gcc $OPTS -g -O3 -c mapcoder.c -pg
cd ../unittest
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o -pg
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest $LIB -pg
./unittest | tee -a $REPORT
gprof ./unittest | tee -a $REPORT
echo "----------------" | tee -a $REPORT
Expand Down
23 changes: 12 additions & 11 deletions unittest/run_sanitizer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
REPORT=report_sanitizer.txt
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
LIB="../mapcodelib/mapcoder.o"

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

Expand All @@ -12,39 +13,39 @@ echo "Run with: -O0" | tee -a $REPORT
cd ../mapcodelib
gcc $OPTS -O0 -DDEBUG -c mapcoder.c
cd ../unittest
gcc $OPTS -O0 -DDEBUG unittest.c -lm -lpthread -fsanitize=address -o unittest
gcc $OPTS -O0 -DDEBUG unittest.c -lm -lpthread -fsanitize=address -o unittest $LIB
./unittest | tee -a $REPORT
echo "----------------" | tee -a $REPORT sanitize.txt
echo "----------------" | tee -a $REPORT

# Optimize 1
echo "" | tee -a $REPORT
echo "Run with: -O1" | tee -a $REPORT sanitize.txt
echo "Run with: -O1" | tee -a $REPORT
cd ../mapcodelib
gcc $OPTS -O1 -c mapcoder.c
cd ../unittest
gcc $OPTS -O1 unittest.c -lm -lpthread -fsanitize=address -o unittest
gcc $OPTS -O1 unittest.c -lm -lpthread -fsanitize=address -o unittest $LINK
./unittest | tee -a $REPORT
echo "----------------" | tee -a $REPORT sanitize.txt
echo "----------------" | tee -a $REPORT

# Optimize 2
echo "" | tee -a $REPORT
echo "Run with: -O2" | tee -a $REPORT sanitize.txt
echo "Run with: -O2" | tee -a $REPORT
cd ../mapcodelib
gcc $OPTS -O2 -c mapcoder.c
cd ../unittest
gcc $OPTS -O2 unittest.c -lm -lpthread -fsanitize=address -o unittest
gcc $OPTS -O2 unittest.c -lm -lpthread -fsanitize=address -o unittest $LIB
./unittest | tee -a $REPORT
echo "----------------" | tee -a $REPORT sanitize.txt
echo "----------------" | tee -a $REPORT

# Optimize 3
echo "" | tee -a $REPORT
echo "Run with: -O3" | tee -a $REPORT sanitize.txt
echo "Run with: -O3" | tee -a $REPORT
cd ../mapcodelib
gcc $OPTS -O3 -c mapcoder.c
cd ../unittest
gcc $OPTS -O3 unittest.c -lm -lpthread -fsanitize=address -o unittest
gcc $OPTS -O3 unittest.c -lm -lpthread -fsanitize=address -o unittest $LIB
./unittest | tee -a $REPORT
echo "----------------" | tee -a $REPORT sanitize.txt
echo "----------------" | tee -a $REPORT

echo "" | tee -a $REPORT
echo "Report in: $REPORT"
5 changes: 3 additions & 2 deletions unittest/run_valgrind.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
REPORT=report_valgrind.txt
OPTS="-Wall -Werror -Wno-pointer-to-int-cast"
LIB="../mapcodelib/mapcoder.o"

echo "Run valgrind" | tee $REPORT

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

Expand All @@ -17,7 +18,7 @@ echo "Run with: -O3" | tee -a report_valgrind.txt
cd ../mapcodelib
gcc $OPTS -g -O3 -c mapcoder.c
cd ../unittest
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest ../mapcodelib/mapcoder.o
gcc $OPTS -g -O3 unittest.c -lm -lpthread -o unittest $LIB
valgrind --leak-check=yes ./unittest | tee -a $REPORT
echo "----------------" tee -a $REPORT

Expand Down
5 changes: 3 additions & 2 deletions unittest/unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ static const double METERS_PER_DEGREE_LON = 111319.490793;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#endif

#define REF(x) if (x) {} else {}

static int nrErrors = 0;


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

// Ref unused var.
if (ISO3166_ALPHA[0] == 0) {
}
REF(ISO3166_ALPHA[0]);

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