From ec3e47abb56a23acd5d6a308e2f190a0a7b30a1f Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Mon, 26 Nov 2018 12:02:06 +0100 Subject: [PATCH] Skip tests requiring extended precision if not avail Alpine is running with Musl libc and musl uses extended precision doubles, while valgrind can't handle extended precision, 2.3 == atof("2.3") won't be true under valgrind. And therefore the option retrieval methods *_get_double would fail. Also we have to increase the test verbosity, as `SKIPm` doesn't print the message when skipping the tests. See: silentbicycle/greatest#85 --- Makefile | 4 ++-- test/option_parser.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8cf1a0c..9737a64 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ dunstify: dunstify.o .PHONY: test test-valgrind test-coverage test: test/test clean-coverage-run - ./test/test + ./test/test -v test-valgrind: test/test valgrind \ @@ -81,7 +81,7 @@ test-valgrind: test/test --errors-for-leak-kinds=definite \ --num-callers=40 \ --error-exitcode=123 \ - ./test/test + ./test/test -v test-coverage: CFLAGS += -fprofile-arcs -ftest-coverage -O0 test-coverage: test diff --git a/test/option_parser.c b/test/option_parser.c index 0c7f807..6de02a8 100644 --- a/test/option_parser.c +++ b/test/option_parser.c @@ -97,6 +97,10 @@ TEST test_ini_get_int(void) TEST test_ini_get_double(void) { + if (2.3 != atof("2.3")) { + SKIPm("Skipping test_ini_get_double, as it seems we're running under musl+valgrind!"); + } + char *double_section = "double"; ASSERT_EQ(1, ini_get_double(double_section, "simple", 0)); ASSERT_EQ(1.5, ini_get_double(double_section, "decimal", 0)); @@ -152,6 +156,10 @@ TEST test_cmdline_get_int(void) TEST test_cmdline_get_double(void) { + if (2.3 != atof("2.3")) { + SKIPm("Skipping test_cmdline_get_double, as it seems we're running under musl+valgrind!"); + } + ASSERT_EQ(2, cmdline_get_double("-simple_double", 0, "")); ASSERT_EQ(5.2, cmdline_get_double("-double", 0, "")); ASSERT_EQ(3.14, cmdline_get_double("-nonexistent", 3.14, "")); @@ -258,6 +266,10 @@ TEST test_option_get_int(void) TEST test_option_get_double(void) { + if (2.3 != atof("2.3")) { + SKIPm("Skipping test_option_get_double, as it seems we're running under musl+valgrind!"); + } + char *double_section = "double"; ASSERT_EQ(2, option_get_double(double_section, "simple", "-simple_double", 0, "")); ASSERT_EQ(5.2, option_get_double(double_section, "simple", "-double", 0, ""));