mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
csu/tests: Add tests to verify that errno == 0 upon program startup
Reviewed by: kib, kevans Differential Revision: https://reviews.freebsd.org/D50998
This commit is contained in:
parent
09c9cab2c2
commit
b5c04c8f96
4 changed files with 44 additions and 0 deletions
|
|
@ -318,6 +318,8 @@
|
|||
..
|
||||
dynamicpie
|
||||
..
|
||||
errno
|
||||
..
|
||||
static
|
||||
..
|
||||
..
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ SUBDIR= dso
|
|||
TESTS_SUBDIRS= dynamic
|
||||
TESTS_SUBDIRS+= dynamiclib
|
||||
TESTS_SUBDIRS+= dynamicpie
|
||||
TESTS_SUBDIRS+= errno
|
||||
TESTS_SUBDIRS+= static
|
||||
|
||||
SUBDIR_DEPEND_dynamiclib=dso
|
||||
|
|
|
|||
18
lib/csu/tests/errno/Makefile
Normal file
18
lib/csu/tests/errno/Makefile
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
PLAIN_TESTS_C= errno_test \
|
||||
errno_static_test \
|
||||
errno_thr_test \
|
||||
errno_thr_static_test
|
||||
|
||||
SRCS.errno_static_test= errno_test.c
|
||||
LDFLAGS.errno_static_test= -static
|
||||
|
||||
SRCS.errno_thr_test= errno_test.c
|
||||
LIBADD.errno_thr_test= pthread
|
||||
|
||||
SRCS.errno_thr_static_test= errno_test.c
|
||||
LDFLAGS.errno_thr_static_test= -static
|
||||
LIBADD.errno_thr_static_test= pthread
|
||||
|
||||
MK_PIE:= no
|
||||
|
||||
.include <bsd.test.mk>
|
||||
23
lib/csu/tests/errno/errno_test.c
Normal file
23
lib/csu/tests/errno/errno_test.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2025 Mark Johnston <markj@FreeBSD.org>
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void __attribute__((constructor))
|
||||
f(void)
|
||||
{
|
||||
errno = 42;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/* errno must be zero upon program startup. */
|
||||
if (errno != 0)
|
||||
exit(1);
|
||||
exit(0);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue