diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-05-03 19:39:58 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-05-03 19:40:28 -0400 |
commit | b11937fc35264180f15b31fedbab56724d2fadfa (patch) | |
tree | 67a3bd5e28996a128988bcacbde8829a0a4cd5f8 | |
parent | 5b8e0f3fdeba17a4b7e8fdda3bfba0e4fef0634f (diff) |
got tests to work on BSD
-rwxr-xr-x | build.sh | 10 | ||||
-rw-r--r-- | tests/.gitignore | 2 | ||||
-rw-r--r-- | tests/test.c | 19 |
3 files changed, 23 insertions, 8 deletions
@@ -8,15 +8,17 @@ if [ "$CC" = "" ]; then fi if uname | grep -qi bsd; then - CFLAGS="$CFLAGS -L/usr/local/lib -I/usr/local/include" + CFLAGS="$CFLAGS -L/usr/local/lib -I/usr/local/include -std=gnu99 -w" +else + CFLAGS="$CFLAGS -Wpedantic -std=c11" fi ADDITIONAL_FLAGS="$CFLAGS -Wno-unused-function" if [ "$CC" = "clang" ]; then - WARNINGS='-Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wimplicit-fallthrough -Wno-missing-braces' + WARNINGS='-Wall -Wextra -Wshadow -Wconversion -Wimplicit-fallthrough -Wno-missing-braces' elif [ "$CC" = "gcc" ]; then - WARNINGS='-Wall -Wextra -Wpedantic -Wshadow -Wconversion' + WARNINGS='-Wall -Wextra -Wshadow -Wconversion' elif [ "$CC" = "tcc" ]; then WARNINGS='-Wall' elif [ "$CC" = "g++" ]; then @@ -35,7 +37,7 @@ if [ "$COMPILE_TIME_FOREIGN_FN_SUPPORT" != "no" ]; then fi -DEBUG_FLAGS="-O0 $WARNINGS -std=c11 -DTOC_DEBUG" +DEBUG_FLAGS="-O0 $WARNINGS -DTOC_DEBUG" if [ "$CC" = "gcc" ]; then DEBUG_FLAGS="$DEBUG_FLAGS -no-pie -gdwarf-2 -pipe" elif [ "$CC" = "clang" ]; then diff --git a/tests/.gitignore b/tests/.gitignore index 4b9aca5..33ccc5b 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,4 +1,6 @@ got out.c +a.out *.exe test +*.core diff --git a/tests/test.c b/tests/test.c index 1da262b..0593c9d 100644 --- a/tests/test.c +++ b/tests/test.c @@ -14,7 +14,9 @@ static const char *tests[] = { "arrs_slices", "ptr_arithmetic", "defer", - "sizeof", +#ifndef __OpenBSD__ + "sizeof", /* OpenBSD's GCC doesn't support _Alignof */ +#endif "new", "arr", "arr2", @@ -42,9 +44,12 @@ static const char *compilers[] = { }; #else static const char *compilers[] = { - "gcc -O0 -g -Wno-parentheses-equality -Wno-builtin-declaration-mismatch", - "clang -O3 -s -Wno-parentheses-equality -Wno-builtin-requires-header -Wno-format-security", + "gcc -O0 -g -Wno-parentheses-equality -Wno-builtin-declaration-mismatch -std=c99", + "clang -O3 -s -Wno-parentheses-equality -Wno-builtin-requires-header -Wno-format-security -std=c99" +#ifdef __linux__ /* couldn't get TCC to build on BSD */ + , "tcc" +#endif }; #endif #define ncompilers ((int)(sizeof compilers / sizeof *compilers)) @@ -61,8 +66,12 @@ int main(int argc, char **argv) { int i, c; char command[256]; int color = 0; + int valgrind = 0; #if unix color = isatty(1); + #ifdef __linux__ /* valgrind is complaining a lot on BSD, but i think it's wrong */ + valgrind = 1; + #endif #endif char const *failed; if (color) { @@ -76,8 +85,10 @@ int main(int argc, char **argv) { fflush(stdout); if (windows) { sprintf(command, "..\\toc %s.toc", test); + } else if (valgrind) { + sprintf(command, "valgrind -q --error-exitcode=1 ../toc %s.toc", test); } else { - sprintf(command, "valgrind -q --exit-on-first-error=yes --error-exitcode=1 ../toc %s.toc", test); + sprintf(command, "../toc %s.toc", test); } if (system(command)) { fprintf(stderr, "%s (while compiling toc).\n", failed); |