diff options
Diffstat (limited to 'lib/csu/tests')
-rw-r--r-- | lib/csu/tests/Makefile | 2 | ||||
-rw-r--r-- | lib/csu/tests/Makefile.inc | 1 | ||||
-rw-r--r-- | lib/csu/tests/Makefile.tests | 1 | ||||
-rw-r--r-- | lib/csu/tests/cxx_constructors.cc | 1 | ||||
-rw-r--r-- | lib/csu/tests/dso/Makefile | 5 | ||||
-rw-r--r-- | lib/csu/tests/dynamic/Makefile | 1 | ||||
-rw-r--r-- | lib/csu/tests/dynamiclib/Makefile | 1 | ||||
-rw-r--r-- | lib/csu/tests/dynamicpie/Makefile | 1 | ||||
-rw-r--r-- | lib/csu/tests/errno/Makefile | 18 | ||||
-rw-r--r-- | lib/csu/tests/errno/errno_test.c | 23 | ||||
-rw-r--r-- | lib/csu/tests/fini_test.c | 1 | ||||
-rw-r--r-- | lib/csu/tests/init_test.c | 30 | ||||
-rw-r--r-- | lib/csu/tests/static/Makefile | 1 |
13 files changed, 46 insertions, 40 deletions
diff --git a/lib/csu/tests/Makefile b/lib/csu/tests/Makefile index 3f95193420ea..b76ef590c88f 100644 --- a/lib/csu/tests/Makefile +++ b/lib/csu/tests/Makefile @@ -1,8 +1,10 @@ +PACKAGE= tests SUBDIR= dso TESTS_SUBDIRS= dynamic TESTS_SUBDIRS+= dynamiclib TESTS_SUBDIRS+= dynamicpie +TESTS_SUBDIRS+= errno TESTS_SUBDIRS+= static SUBDIR_DEPEND_dynamiclib=dso diff --git a/lib/csu/tests/Makefile.inc b/lib/csu/tests/Makefile.inc index 9904a82f1baf..2cb85b8d5d43 100644 --- a/lib/csu/tests/Makefile.inc +++ b/lib/csu/tests/Makefile.inc @@ -1,2 +1 @@ - TESTSDIR:= ${TESTSBASE}/${RELDIR:C/csu\/tests/csu/} diff --git a/lib/csu/tests/Makefile.tests b/lib/csu/tests/Makefile.tests index 12926d5e38a6..52179057b2a3 100644 --- a/lib/csu/tests/Makefile.tests +++ b/lib/csu/tests/Makefile.tests @@ -1,4 +1,3 @@ - ATF_TESTS_C+= init_test ATF_TESTS_C+= fini_test ATF_TESTS_CXX+= cxx_constructors diff --git a/lib/csu/tests/cxx_constructors.cc b/lib/csu/tests/cxx_constructors.cc index 3568c4528c36..3c04053884d2 100644 --- a/lib/csu/tests/cxx_constructors.cc +++ b/lib/csu/tests/cxx_constructors.cc @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> #include <sys/types.h> #include <sys/wait.h> diff --git a/lib/csu/tests/dso/Makefile b/lib/csu/tests/dso/Makefile index 6975e64c5dfe..431168de0328 100644 --- a/lib/csu/tests/dso/Makefile +++ b/lib/csu/tests/dso/Makefile @@ -1,5 +1,6 @@ - .PATH: ${.CURDIR:H} + +PACKAGE= tests SHLIB= h_csu SHLIB_NAME= libh_csu.so SHLIB_MAJOR= 1 @@ -19,6 +20,6 @@ SRCS+= ${src}.c SRCS+= ${src}.cc .endfor -LIBDIR= ${TESTSBASE}/lib/csu/dynamiclib/ +LIBDIR= ${TESTSBASE}/lib/csu/dynamiclib .include <bsd.lib.mk> diff --git a/lib/csu/tests/dynamic/Makefile b/lib/csu/tests/dynamic/Makefile index 1ceeb385b5e9..e9e57201cb9a 100644 --- a/lib/csu/tests/dynamic/Makefile +++ b/lib/csu/tests/dynamic/Makefile @@ -1,4 +1,3 @@ - .PATH: ${.CURDIR:H} .include <src.opts.mk> diff --git a/lib/csu/tests/dynamiclib/Makefile b/lib/csu/tests/dynamiclib/Makefile index ced5bbb4e935..13a9b837684e 100644 --- a/lib/csu/tests/dynamiclib/Makefile +++ b/lib/csu/tests/dynamiclib/Makefile @@ -1,4 +1,3 @@ - .PATH: ${.CURDIR:H} CFLAGS+= -DDSO_BASE DPADD+= ${.OBJDIR:H}/dso/libh_csu.so diff --git a/lib/csu/tests/dynamicpie/Makefile b/lib/csu/tests/dynamicpie/Makefile index b5c0356001db..204bef0c7d10 100644 --- a/lib/csu/tests/dynamicpie/Makefile +++ b/lib/csu/tests/dynamicpie/Makefile @@ -1,4 +1,3 @@ - .PATH: ${.CURDIR:H} .include <src.opts.mk> diff --git a/lib/csu/tests/errno/Makefile b/lib/csu/tests/errno/Makefile new file mode 100644 index 000000000000..eae54a936294 --- /dev/null +++ b/lib/csu/tests/errno/Makefile @@ -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> diff --git a/lib/csu/tests/errno/errno_test.c b/lib/csu/tests/errno/errno_test.c new file mode 100644 index 000000000000..d190c7fd2959 --- /dev/null +++ b/lib/csu/tests/errno/errno_test.c @@ -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); +} diff --git a/lib/csu/tests/fini_test.c b/lib/csu/tests/fini_test.c index 9475b40f4271..79dbceb8a37c 100644 --- a/lib/csu/tests/fini_test.c +++ b/lib/csu/tests/fini_test.c @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> #include <sys/types.h> #include <sys/wait.h> diff --git a/lib/csu/tests/init_test.c b/lib/csu/tests/init_test.c index 47bd9b7e64d7..2d4484735f76 100644 --- a/lib/csu/tests/init_test.c +++ b/lib/csu/tests/init_test.c @@ -38,9 +38,6 @@ typedef void (*func_ptr)(void); -extern volatile int jcr_run; -extern const func_ptr *jcr_ptr; -extern const void *jcr_func_ptr; extern volatile int ctors_run; extern volatile int preinit_array_run; extern volatile int preinit_array_state; @@ -48,37 +45,11 @@ extern volatile int init_array_run; extern volatile int init_array_state; #ifndef DSO_BASE -volatile int jcr_run; -const func_ptr *jcr_ptr; volatile int ctors_run; volatile int preinit_array_run; volatile int preinit_array_state = -1; volatile int init_array_run; volatile int init_array_state = -1; - -void _Jv_RegisterClasses(const func_ptr *); - -__section(".jcr") __used static func_ptr jcr_func = (func_ptr)1; -const void *jcr_func_ptr = &jcr_func; - -void -_Jv_RegisterClasses(const func_ptr *jcr) -{ - - jcr_run = 1; - jcr_ptr = jcr; -} -#endif - -#ifndef DSO_LIB -ATF_TC_WITHOUT_HEAD(jcr_test); -ATF_TC_BODY(jcr_test, tc) -{ - - ATF_REQUIRE_MSG(jcr_run == 1, ".jcr not run"); - ATF_REQUIRE_MSG(jcr_ptr == jcr_func_ptr, - "Incorrect pointer passed to _Jv_RegisterClasses"); -} #endif #ifndef DSO_BASE @@ -160,7 +131,6 @@ ATF_TC_BODY(init_array_test, tc) ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, jcr_test); ATF_TP_ADD_TC(tp, ctors_test); ATF_TP_ADD_TC(tp, preinit_array_test); ATF_TP_ADD_TC(tp, init_array_test); diff --git a/lib/csu/tests/static/Makefile b/lib/csu/tests/static/Makefile index c3f87641c8ef..e76c49c93a1a 100644 --- a/lib/csu/tests/static/Makefile +++ b/lib/csu/tests/static/Makefile @@ -1,4 +1,3 @@ - .PATH: ${.CURDIR:H} NO_SHARED= |