From 5a7dcb86485f050aeeb77eef3313a6b92a2adde4 Mon Sep 17 00:00:00 2001 From: Mosder Date: Thu, 17 Sep 2026 15:51:23 +0200 Subject: feat: changed output tests and suppression to use file descriptors for more portability --- tests/safe_tests.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/safe_tests.c') diff --git a/tests/safe_tests.c b/tests/safe_tests.c index b50b073..3c25dd5 100644 --- a/tests/safe_tests.c +++ b/tests/safe_tests.c @@ -13,7 +13,7 @@ TEST(test_safe_malloc) { void *p = safe_malloc(1024); test_assert(p != NULL, "Failed to malloc 1KiB"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(malloc_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -26,7 +26,7 @@ TEST(test_safe_calloc) { void *p = safe_calloc(16, 16); test_assert(p != NULL, "Failed to calloc 16 items of 16 bytes"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(calloc_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -44,7 +44,7 @@ TEST(test_safe_realloc) { p = safe_realloc(p, 4096); test_assert(p != NULL, "Failed to realloc 1KiB to 4KiB"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(realloc_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -57,7 +57,7 @@ TEST(test_safe_fopen) { FILE *fp = safe_fopen(__FILE__, "r"); test_assert(fp != NULL, "Failed to fopen current file"); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(fopen_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -76,7 +76,7 @@ TEST(test_safe_dup) { test_assert(fd != -1, "Failed to dup STDOUT_FILENO"); close(fd); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(dup_exit, EXIT_FAILURE); unsuppress_outputs(); } @@ -96,7 +96,7 @@ TEST(test_safe_dup2) { test_assert(res != -1, "Failed to restore STDOUT_FILENO"); close(fd); - suppress_output(stderr); + suppress_output(STDERR_FILENO); test_assert_exit(dup2_exit, EXIT_FAILURE); unsuppress_outputs(); } -- cgit v1.2.3