From f3a98debec14eddb208f6e48d37069e2b269835b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 8 Jun 2021 14:33:13 +1000 Subject: [PATCH] spa: don't run the spa_scnprintf abort test under valgrind valgrind doesn't know we expect this to fail, so let's not confuse it --- spa/tests/meson.build | 2 +- spa/tests/test-utils.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/spa/tests/meson.build b/spa/tests/meson.build index 6c1aa7d11..288d843fc 100644 --- a/spa/tests/meson.build +++ b/spa/tests/meson.build @@ -10,7 +10,7 @@ foreach a : test_apps test('spa-' + a, executable('spa-' + a, a + '.c', dependencies : [dl_lib, pthread_lib, mathlib ], - include_directories : [spa_inc ], + include_directories : [spa_inc, includes_inc ], c_args : [ '-D_GNU_SOURCE' ], install : installed_tests_enabled, install_dir : installed_tests_execdir), diff --git a/spa/tests/test-utils.c b/spa/tests/test-utils.c index 64a386c75..719117582 100644 --- a/spa/tests/test-utils.c +++ b/spa/tests/test-utils.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -784,6 +786,19 @@ static void test_snprintf(void) spa_assert(spa_scnprintf(dest, 1, "1234567") == 0); spa_assert(spa_streq(dest, "")); + /* The "append until buffer is full" use-case */ + len = 0; + while ((size_t)len < sizeof(dest) - 1) + len += spa_scnprintf(dest + len, sizeof(dest) - len, "123"); + /* and once more for good measure, this should print 0 characters */ + len = spa_scnprintf(dest + len, sizeof(dest) - len, "abc"); + spa_assert(len == 0); + spa_assert(spa_streq(dest, "1231231")); + + + if (RUNNING_ON_VALGRIND) + return; + /* Check for abort on negative/zero size */ for (int i = -2; i <= 0; i++) { pid = fork(); @@ -802,15 +817,6 @@ static void test_snprintf(void) spa_assert(WTERMSIG(status) == SIGABRT); } } - - /* The "append until buffer is full" use-case */ - len = 0; - while ((size_t)len < sizeof(dest) - 1) - len += spa_scnprintf(dest + len, sizeof(dest) - len, "123"); - /* and once more for good measure, this should print 0 characters */ - len = spa_scnprintf(dest + len, sizeof(dest) - len, "abc"); - spa_assert(len == 0); - spa_assert(spa_streq(dest, "1231231")); } int main(int argc, char *argv[])