libc tests: Rename the quick_exit test file, fix style

Call it libc_exit_test instead of exit_test because the NetBSD test
suite already has a file with the latter name.  This is in preparation
for adding other exit()-related tests.

MFC after:	2 weeks
This commit is contained in:
Mark Johnston 2024-07-29 14:37:47 +00:00
parent 3852a5a226
commit 5132e16e1f
3 changed files with 15 additions and 8 deletions

View file

@ -51,6 +51,9 @@
# xargs -n1 | sort | uniq -d;
# done
# 20240729: rename quick_exit_test to libc_exit_test
OLD_FILES+=usr/tests/lib/libc/stdlib/quick_exit_test
# 20240729: retire ifaddr_byindex
OLD_FILES+=usr/share/man/man9/ifaddr_byindex.9.gz

View file

@ -3,6 +3,7 @@
ATF_TESTS_C+= clearenv_test
ATF_TESTS_C+= dynthr_test
ATF_TESTS_C+= heapsort_test
ATF_TESTS_C+= libc_exit_test
ATF_TESTS_C+= mergesort_test
ATF_TESTS_C+= qsort_test
.if ${COMPILER_TYPE} == "clang"
@ -11,7 +12,6 @@ ATF_TESTS_C+= qsort_b_test
ATF_TESTS_C+= qsort_r_compat_test
ATF_TESTS_C+= qsort_r_test
ATF_TESTS_C+= qsort_s_test
ATF_TESTS_C+= quick_exit_test
ATF_TESTS_C+= set_constraint_handler_s_test
ATF_TESTS_C+= strfmon_test
ATF_TESTS_C+= tsearch_test

View file

@ -12,32 +12,36 @@
#include <atf-c.h>
static void func_a(void)
static void
func_a(void)
{
if (write(STDOUT_FILENO, "a", 1) != 1)
_Exit(1);
}
static void func_b(void)
static void
func_b(void)
{
if (write(STDOUT_FILENO, "b", 1) != 1)
_Exit(1);
}
static void func_c(void)
static void
func_c(void)
{
if (write(STDOUT_FILENO, "c", 1) != 1)
_Exit(1);
}
static void child(void)
static void
child(void)
{
// this will be received by the parent
/* this will be received by the parent */
printf("hello, ");
fflush(stdout);
// this won't, because quick_exit() does not flush
/* this won't, because quick_exit() does not flush */
printf("world");
// these will be called in reverse order, producing "abc"
/* these will be called in reverse order, producing "abc" */
if (at_quick_exit(func_c) != 0 ||
at_quick_exit(func_b) != 0 ||
at_quick_exit(func_a) != 0)