diff options
| author | millert <> | 2007-09-03 14:42:44 +0000 |
|---|---|---|
| committer | millert <> | 2007-09-03 14:42:44 +0000 |
| commit | b7b77a835b1b9da7ec261009d15f310b4e4c4249 (patch) | |
| tree | ac862acc251d3e1362df57c4b59aea10e2735418 | |
| parent | 7e0e6a2581ab1d1bca602865b8e38dfa2f54424a (diff) | |
| download | openbsd-b7b77a835b1b9da7ec261009d15f310b4e4c4249.tar.gz openbsd-b7b77a835b1b9da7ec261009d15f310b4e4c4249.tar.bz2 openbsd-b7b77a835b1b9da7ec261009d15f310b4e4c4249.zip | |
Adapt atexit() regress to recent changes and add __cxa_atexit() regress.
__cxa_atexit() regress from kurt@
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libc/Makefile | 4 | ||||
| -rw-r--r-- | src/regress/lib/libc/atexit/atexit_test.c | 6 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/Makefile | 13 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/libgd1/Makefile | 9 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/libgd1/gd1.C | 32 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/libgd1/shlib_version | 2 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/libgd2/Makefile | 9 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/libgd2/gd2.C | 32 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/libgd2/shlib_version | 2 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/test1/Makefile | 29 | ||||
| -rw-r--r-- | src/regress/lib/libc/cxa-atexit/test1/test1.C | 63 |
11 files changed, 196 insertions, 5 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile index e3e29ddd69..689f87aa03 100644 --- a/src/regress/lib/libc/Makefile +++ b/src/regress/lib/libc/Makefile | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.25 2007/05/17 03:02:32 ray Exp $ | 1 | # $OpenBSD: Makefile,v 1.26 2007/09/03 14:42:43 millert Exp $ |
| 2 | 2 | ||
| 3 | SUBDIR+= _setjmp alloca atexit basename db dirname getaddrinfo | 3 | SUBDIR+= _setjmp alloca atexit basename cxa-atexit db dirname getaddrinfo |
| 4 | SUBDIR+= getcap getopt_long hsearch longjmp locale malloc | 4 | SUBDIR+= getcap getopt_long hsearch longjmp locale malloc |
| 5 | SUBDIR+= netdb popen regex setjmp setjmp-signal sigreturn sigsetjmp | 5 | SUBDIR+= netdb popen regex setjmp setjmp-signal sigreturn sigsetjmp |
| 6 | SUBDIR+= sprintf strerror strtod strtonum telldir time vis | 6 | SUBDIR+= sprintf strerror strtod strtonum telldir time vis |
diff --git a/src/regress/lib/libc/atexit/atexit_test.c b/src/regress/lib/libc/atexit/atexit_test.c index efa2274168..3dd0b62c3e 100644 --- a/src/regress/lib/libc/atexit/atexit_test.c +++ b/src/regress/lib/libc/atexit/atexit_test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: atexit_test.c,v 1.5 2003/09/02 23:52:16 david Exp $ */ | 1 | /* $OpenBSD: atexit_test.c,v 1.6 2007/09/03 14:42:44 millert Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2002 Daniel Hartmeier | 4 | * Copyright (c) 2002 Daniel Hartmeier |
| @@ -79,7 +79,7 @@ main(int argc, char *argv[]) | |||
| 79 | /* this is supposed to segfault */ | 79 | /* this is supposed to segfault */ |
| 80 | if (!strcmp(argv[1], "-invalid-atexit")) { | 80 | if (!strcmp(argv[1], "-invalid-atexit")) { |
| 81 | signal(SIGSEGV, handle_signal); | 81 | signal(SIGSEGV, handle_signal); |
| 82 | __atexit->fns[0] = handle_invalid; | 82 | __atexit->fns[0].fn_ptr.std_func = handle_invalid; |
| 83 | } else if (!strcmp(argv[1], "-invalid-cleanup")) { | 83 | } else if (!strcmp(argv[1], "-invalid-cleanup")) { |
| 84 | struct atexit *p = __atexit; | 84 | struct atexit *p = __atexit; |
| 85 | 85 | ||
| @@ -88,7 +88,7 @@ main(int argc, char *argv[]) | |||
| 88 | p = p->next; | 88 | p = p->next; |
| 89 | if (p == NULL) | 89 | if (p == NULL) |
| 90 | fprintf(stderr, "p == NULL, no page found\n"); | 90 | fprintf(stderr, "p == NULL, no page found\n"); |
| 91 | p->fns[0] = handle_invalid; | 91 | p->fns[0].fn_ptr.std_func = handle_invalid; |
| 92 | } | 92 | } |
| 93 | __atexit_register_cleanup(handle_cleanup); | 93 | __atexit_register_cleanup(handle_cleanup); |
| 94 | counter = 0; | 94 | counter = 0; |
diff --git a/src/regress/lib/libc/cxa-atexit/Makefile b/src/regress/lib/libc/cxa-atexit/Makefile new file mode 100644 index 0000000000..ffd83fe1ca --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/Makefile | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $ | ||
| 2 | |||
| 3 | .include <bsd.own.mk> | ||
| 4 | |||
| 5 | USE_GCC3?=No | ||
| 6 | |||
| 7 | .if ${USE_GCC3:L} == "yes" | ||
| 8 | SUBDIR+= libgd1 libgd2 test1 | ||
| 9 | .endif | ||
| 10 | |||
| 11 | install: | ||
| 12 | |||
| 13 | .include <bsd.subdir.mk> | ||
diff --git a/src/regress/lib/libc/cxa-atexit/libgd1/Makefile b/src/regress/lib/libc/cxa-atexit/libgd1/Makefile new file mode 100644 index 0000000000..958b726d28 --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/libgd1/Makefile | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $ | ||
| 2 | |||
| 3 | LIB=gd1 | ||
| 4 | SRCS= gd1.C | ||
| 5 | NOPROFILE=yes | ||
| 6 | |||
| 7 | regress: all | ||
| 8 | |||
| 9 | .include <bsd.lib.mk> | ||
diff --git a/src/regress/lib/libc/cxa-atexit/libgd1/gd1.C b/src/regress/lib/libc/cxa-atexit/libgd1/gd1.C new file mode 100644 index 0000000000..b3ecd56d91 --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/libgd1/gd1.C | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* $OpenBSD: gd1.C,v 1.1 2007/09/03 14:42:44 millert Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2007 Kurt Miller <kurt@openbsd.org> | ||
| 5 | * | ||
| 6 | * Permission to use, copy, modify, and distribute this software for any | ||
| 7 | * purpose with or without fee is hereby granted, provided that the above | ||
| 8 | * copyright notice and this permission notice appear in all copies. | ||
| 9 | * | ||
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <stdio.h> | ||
| 20 | |||
| 21 | extern int check1; | ||
| 22 | |||
| 23 | struct global_destructor_test_obj1 { | ||
| 24 | inline ~global_destructor_test_obj1() { | ||
| 25 | check1 = 0; | ||
| 26 | } | ||
| 27 | }; | ||
| 28 | |||
| 29 | extern "C" void gd_test1() | ||
| 30 | { | ||
| 31 | static global_destructor_test_obj1 gdt; | ||
| 32 | } | ||
diff --git a/src/regress/lib/libc/cxa-atexit/libgd1/shlib_version b/src/regress/lib/libc/cxa-atexit/libgd1/shlib_version new file mode 100644 index 0000000000..97c9f92d6b --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/libgd1/shlib_version | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | major=0 | ||
| 2 | minor=0 | ||
diff --git a/src/regress/lib/libc/cxa-atexit/libgd2/Makefile b/src/regress/lib/libc/cxa-atexit/libgd2/Makefile new file mode 100644 index 0000000000..7ca21d8bd2 --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/libgd2/Makefile | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $ | ||
| 2 | |||
| 3 | LIB=gd2 | ||
| 4 | SRCS= gd2.C | ||
| 5 | NOPROFILE=yes | ||
| 6 | |||
| 7 | regress: all | ||
| 8 | |||
| 9 | .include <bsd.lib.mk> | ||
diff --git a/src/regress/lib/libc/cxa-atexit/libgd2/gd2.C b/src/regress/lib/libc/cxa-atexit/libgd2/gd2.C new file mode 100644 index 0000000000..69e7ffb220 --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/libgd2/gd2.C | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* $OpenBSD: gd2.C,v 1.1 2007/09/03 14:42:44 millert Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2007 Kurt Miller <kurt@openbsd.org> | ||
| 5 | * | ||
| 6 | * Permission to use, copy, modify, and distribute this software for any | ||
| 7 | * purpose with or without fee is hereby granted, provided that the above | ||
| 8 | * copyright notice and this permission notice appear in all copies. | ||
| 9 | * | ||
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <stdio.h> | ||
| 20 | |||
| 21 | extern int check2; | ||
| 22 | |||
| 23 | struct global_destructor_test_obj2 { | ||
| 24 | inline ~global_destructor_test_obj2() { | ||
| 25 | check2 = 0; | ||
| 26 | } | ||
| 27 | }; | ||
| 28 | |||
| 29 | extern "C" void gd_test2() | ||
| 30 | { | ||
| 31 | static global_destructor_test_obj2 gdt; | ||
| 32 | } | ||
diff --git a/src/regress/lib/libc/cxa-atexit/libgd2/shlib_version b/src/regress/lib/libc/cxa-atexit/libgd2/shlib_version new file mode 100644 index 0000000000..97c9f92d6b --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/libgd2/shlib_version | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | major=0 | ||
| 2 | minor=0 | ||
diff --git a/src/regress/lib/libc/cxa-atexit/test1/Makefile b/src/regress/lib/libc/cxa-atexit/test1/Makefile new file mode 100644 index 0000000000..533392d144 --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/test1/Makefile | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2007/09/03 14:42:44 millert Exp $ | ||
| 2 | |||
| 3 | .include <bsd.obj.mk> | ||
| 4 | |||
| 5 | GD1_DIR=${.CURDIR}/../libgd1 | ||
| 6 | GD1_OBJDIR!= if [ -d $(GD1_DIR)/${__objdir} ]; then \ | ||
| 7 | echo "$(GD1_DIR)/${__objdir}"; \ | ||
| 8 | else \ | ||
| 9 | echo "$(GD1_DIR)"; \ | ||
| 10 | fi | ||
| 11 | |||
| 12 | GD2_DIR=${.CURDIR}/../libgd2 | ||
| 13 | GD2_OBJDIR!= if [ -d $(GD2_DIR)/${__objdir} ]; then \ | ||
| 14 | echo "$(GD2_DIR)/${__objdir}"; \ | ||
| 15 | else \ | ||
| 16 | echo "$(GD2_DIR)"; \ | ||
| 17 | fi | ||
| 18 | |||
| 19 | PROG= test1 | ||
| 20 | |||
| 21 | SRCS= test1.C | ||
| 22 | |||
| 23 | CFLAGS+= -DLIBGD1="\"$(GD1_OBJDIR)/libgd1.so\"" | ||
| 24 | CFLAGS+= -DLIBGD2="\"$(GD2_OBJDIR)/libgd2.so\"" | ||
| 25 | LDFLAGS+= -Wl,-E | ||
| 26 | |||
| 27 | NOMAN= | ||
| 28 | |||
| 29 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/cxa-atexit/test1/test1.C b/src/regress/lib/libc/cxa-atexit/test1/test1.C new file mode 100644 index 0000000000..75fb967a90 --- /dev/null +++ b/src/regress/lib/libc/cxa-atexit/test1/test1.C | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | /* $OpenBSD: test1.C,v 1.1 2007/09/03 14:42:44 millert Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2007 Kurt Miller <kurt@openbsd.org> | ||
| 5 | * | ||
| 6 | * Permission to use, copy, modify, and distribute this software for any | ||
| 7 | * purpose with or without fee is hereby granted, provided that the above | ||
| 8 | * copyright notice and this permission notice appear in all copies. | ||
| 9 | * | ||
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <dlfcn.h> | ||
| 20 | #include <err.h> | ||
| 21 | #include <stdio.h> | ||
| 22 | |||
| 23 | int check1, check2; | ||
| 24 | |||
| 25 | int | ||
| 26 | main() | ||
| 27 | { | ||
| 28 | void *libgd1, *libgd2; | ||
| 29 | void (*gd_test)(); | ||
| 30 | int i; | ||
| 31 | |||
| 32 | for (i=0; i < 50; i++) { | ||
| 33 | check1 = check2 = 1; | ||
| 34 | |||
| 35 | libgd1 = dlopen(LIBGD1, RTLD_LAZY); | ||
| 36 | if (libgd1 == NULL) | ||
| 37 | errx(1, "dlopen(%s, RTLD_LAZY) FAILED\n", LIBGD1); | ||
| 38 | |||
| 39 | gd_test = (void (*)())dlsym(libgd1, "gd_test1"); | ||
| 40 | if (gd_test == NULL) | ||
| 41 | errx(1, "dlsym(libgd1, \"gd_test1\") FAILED\n"); | ||
| 42 | |||
| 43 | (*gd_test)(); | ||
| 44 | |||
| 45 | libgd2 = dlopen(LIBGD2, RTLD_LAZY); | ||
| 46 | if (libgd2 == NULL) | ||
| 47 | errx(1, "dlopen(%s, RTLD_LAZY) FAILED\n", LIBGD2); | ||
| 48 | |||
| 49 | gd_test = (void (*)())dlsym(libgd2, "gd_test2"); | ||
| 50 | if (gd_test == NULL) | ||
| 51 | errx(1, "dlsym(libgd2, \"gd_test2\") FAILED\n"); | ||
| 52 | |||
| 53 | (*gd_test)(); | ||
| 54 | |||
| 55 | dlclose(libgd1); | ||
| 56 | dlclose(libgd2); | ||
| 57 | |||
| 58 | if (check1 || check2) | ||
| 59 | errx(1, "global destructors not called\n"); | ||
| 60 | } | ||
| 61 | |||
| 62 | return (0); | ||
| 63 | } | ||
