diff --git a/lib/unix.c b/lib/unix.c index 3c8f327c8..c31145ec3 100644 --- a/lib/unix.c +++ b/lib/unix.c @@ -80,7 +80,7 @@ qb_sys_mmap_file_open(char *path, const char *file, size_t bytes, if (is_absolute) { (void)strlcpy(path, file, PATH_MAX); } else { -#if defined(QB_LINUX) || defined(QB_CYGWIN) +#if defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU) snprintf(path, PATH_MAX, "/dev/shm/%s", file); #else snprintf(path, PATH_MAX, "%s/%s", SOCKETDIR, file); diff --git a/tests/_syslog_override.h b/tests/_syslog_override.h index 7b254aea0..923caeaa7 100644 --- a/tests/_syslog_override.h +++ b/tests/_syslog_override.h @@ -24,7 +24,7 @@ #ifndef QB_SYSLOG_OVERRIDE_H_DEFINED #define QB_SYSLOG_OVERRIDE_H_DEFINED -#include +#include "os_base.h" extern int _syslog_opened; extern int _syslog_option; diff --git a/tests/check_common.h b/tests/check_common.h index 5f1f53690..2347648fc 100644 --- a/tests/check_common.h +++ b/tests/check_common.h @@ -66,4 +66,13 @@ /* add_tcase(, , [, ]) */ #define add_tcase(...) add_tcase_select(VA_ARGS_CNT(__VA_ARGS__))(__VA_ARGS__) +/* expected failure (the timeout argument is mandatory here) */ +#define add_tcase_xfail(suite, tcase, func, timeout) \ + do { \ + (tcase) = tcase_create(STRINGIFY(func) + sizeof("test")); \ + tcase_add_exit_test((tcase), func, 1); \ + tcase_set_timeout((tcase), (timeout)); \ + suite_add_tcase((suite), (tcase)); \ + } while (0) + #endif diff --git a/tests/check_ipc.c b/tests/check_ipc.c index 71b3a7fa5..87343d025 100644 --- a/tests/check_ipc.c +++ b/tests/check_ipc.c @@ -1551,21 +1551,28 @@ make_shm_suite(void) TCase *tc; Suite *s = suite_create("shm"); - add_tcase(s, tc, test_ipc_txrx_shm_timeout, 30); - add_tcase(s, tc, test_ipc_server_fail_shm, 8); - add_tcase(s, tc, test_ipc_txrx_shm_block, 8); - add_tcase(s, tc, test_ipc_txrx_shm_tmo, 8); - add_tcase(s, tc, test_ipc_fc_shm, 8); - add_tcase(s, tc, test_ipc_dispatch_shm, 16); - add_tcase(s, tc, test_ipc_stress_test_shm, 16); - add_tcase(s, tc, test_ipc_bulk_events_shm, 16); - add_tcase(s, tc, test_ipc_exit_shm, 8); - add_tcase(s, tc, test_ipc_event_on_created_shm, 10); - add_tcase(s, tc, test_ipc_service_ref_count_shm, 10); - add_tcase(s, tc, test_ipc_stress_connections_shm, 3600); +#undef add_cond_tcase +#ifdef DISABLE_IPC_SHM +#define add_cond_tcase(func, timeout) add_tcase_xfail(s, tc, func, timeout) +#else +#define add_cond_tcase(func, timeout) add_tcase(s, tc, func, timeout) +#endif + + add_cond_tcase(test_ipc_txrx_shm_timeout, 30); + add_cond_tcase(test_ipc_server_fail_shm, 8); + add_cond_tcase(test_ipc_txrx_shm_block, 8); + add_cond_tcase(test_ipc_txrx_shm_tmo, 8); + add_cond_tcase(test_ipc_fc_shm, 8); + add_cond_tcase(test_ipc_dispatch_shm, 16); + add_cond_tcase(test_ipc_stress_test_shm, 16); + add_cond_tcase(test_ipc_bulk_events_shm, 16); + add_cond_tcase(test_ipc_exit_shm, 8); + add_cond_tcase(test_ipc_event_on_created_shm, 10); + add_cond_tcase(test_ipc_service_ref_count_shm, 10); + add_cond_tcase(test_ipc_stress_connections_shm, 3600); #ifdef HAVE_FAILURE_INJECTION - add_tcase(s, tc, test_ipcc_truncate_when_unlink_fails_shm, 8); + add_cond_tcase(test_ipcc_truncate_when_unlink_fails_shm, 8); #endif return s; @@ -1577,24 +1584,32 @@ make_soc_suite(void) Suite *s = suite_create("socket"); TCase *tc; - add_tcase(s, tc, test_ipc_txrx_us_timeout, 30); +#undef add_cond_tcase +#ifdef QB_GNU +/* SO_SNDBUF isn't implemented in pflocal on Hurd */ +#define add_cond_tcase(func, timeout) add_tcase_xfail(s, tc, func, timeout) +#else +#define add_cond_tcase(func, timeout) add_tcase(s, tc, func, timeout) +#endif + + add_cond_tcase(test_ipc_txrx_us_timeout, 30); /* Commented out for the moment as space in /dev/shm on the CI machines causes random failures */ -/* add_tcase(s, tc, test_ipc_max_dgram_size, 30); */ - add_tcase(s, tc, test_ipc_server_fail_soc, 8); - add_tcase(s, tc, test_ipc_txrx_us_block, 8); - add_tcase(s, tc, test_ipc_txrx_us_tmo, 8); - add_tcase(s, tc, test_ipc_fc_us, 8); - add_tcase(s, tc, test_ipc_exit_us, 8); - add_tcase(s, tc, test_ipc_dispatch_us, 16); +/* add_cond_tcase(test_ipc_max_dgram_size, 30); */ + add_cond_tcase(test_ipc_server_fail_soc, 8); + add_cond_tcase(test_ipc_txrx_us_block, 8); + add_cond_tcase(test_ipc_txrx_us_tmo, 8); + add_cond_tcase(test_ipc_fc_us, 8); + add_cond_tcase(test_ipc_exit_us, 8); + add_cond_tcase(test_ipc_dispatch_us, 16); #ifndef __clang__ /* see variable length array in structure' at the top */ - add_tcase(s, tc, test_ipc_stress_test_us, 60); + add_cond_tcase(test_ipc_stress_test_us, 60); #endif - add_tcase(s, tc, test_ipc_bulk_events_us, 16); - add_tcase(s, tc, test_ipc_event_on_created_us, 10); - add_tcase(s, tc, test_ipc_disconnect_after_created_us, 10); - add_tcase(s, tc, test_ipc_service_ref_count_us, 10); - add_tcase(s, tc, test_ipc_stress_connections_us, 3600); + add_cond_tcase(test_ipc_bulk_events_us, 16); + add_cond_tcase(test_ipc_event_on_created_us, 10); + add_cond_tcase(test_ipc_disconnect_after_created_us, 10); + add_cond_tcase(test_ipc_service_ref_count_us, 10); + add_cond_tcase(test_ipc_stress_connections_us, 3600); return s; } @@ -1605,19 +1620,12 @@ main(void) int32_t number_failed; SRunner *sr; Suite *s; - int32_t do_shm_tests = QB_TRUE; set_ipc_name("ipc_test"); -#ifdef DISABLE_IPC_SHM - do_shm_tests = QB_FALSE; -#endif /* DISABLE_IPC_SHM */ s = make_soc_suite(); sr = srunner_create(s); - - if (do_shm_tests) { - srunner_add_suite(sr, make_shm_suite()); - } + srunner_add_suite(sr, make_shm_suite()); qb_log_init("check", LOG_USER, LOG_EMERG); atexit(qb_log_fini);