mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
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
This commit is contained in:
parent
10270621c2
commit
f3a98debec
2 changed files with 16 additions and 10 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <valgrind/valgrind.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/dict.h>
|
||||
|
|
@ -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[])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue