Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/libexec/ld.elf_so ld.elf_so: Factor out logic in TLS t...
details: https://anonhg.NetBSD.org/src/rev/9a166499bc83
branches: trunk
changeset: 376118:9a166499bc83
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Jun 01 22:24:52 2023 +0000
description:
ld.elf_so: Factor out logic in TLS tests to make writing more easier.
No functional change intended.
XXX pullup-10
diffstat:
tests/libexec/ld.elf_so/t_tls_extern.c | 165 +++++++++++---------------------
1 files changed, 58 insertions(+), 107 deletions(-)
diffs (221 lines):
diff -r 0b1270eab0a1 -r 9a166499bc83 tests/libexec/ld.elf_so/t_tls_extern.c
--- a/tests/libexec/ld.elf_so/t_tls_extern.c Thu Jun 01 21:58:05 2023 +0000
+++ b/tests/libexec/ld.elf_so/t_tls_extern.c Thu Jun 01 22:24:52 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_tls_extern.c,v 1.4 2023/06/01 20:50:18 riastradh Exp $ */
+/* $NetBSD: t_tls_extern.c,v 1.5 2023/06/01 22:24:52 riastradh Exp $ */
/*-
* Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -33,6 +33,51 @@
#define ATF_REQUIRE_DL(x) ATF_REQUIRE_MSG(x, "%s: %s", #x, dlerror())
+enum order {
+ DEF_USE,
+ USE_DEF,
+ USE_DEF_NOLOAD,
+};
+
+static void
+tls_extern(const char *libdef, const char *libuse, enum order order,
+ bool xfail)
+{
+ void *def, *use;
+ int *(*fdef)(void), *(*fuse)(void);
+ int *pdef, *puse;
+
+ (void)dlerror();
+
+ switch (order) {
+ case DEF_USE:
+ ATF_REQUIRE_DL(def = dlopen(libdef, 0));
+ ATF_REQUIRE_DL(use = dlopen(libuse, 0));
+ break;
+ case USE_DEF:
+ ATF_REQUIRE_DL(use = dlopen(libuse, 0));
+ ATF_REQUIRE_DL(def = dlopen(libdef, 0));
+ break;
+ case USE_DEF_NOLOAD:
+ ATF_REQUIRE_DL(use = dlopen(libuse, 0));
+ ATF_REQUIRE_DL(def = dlopen(libdef, RTLD_NOLOAD));
+ break;
+ }
+
+ ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
+ ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
+
+ pdef = (*fdef)();
+ puse = (*fuse)();
+ if (xfail) {
+ atf_tc_expect_fail("PR toolchain/50277:"
+ " rtld relocation bug with thread local storage");
+ }
+ ATF_CHECK_EQ_MSG(pdef, puse,
+ "%p in defining library != %p in using library",
+ pdef, puse);
+}
+
ATF_TC(tls_extern_dynamic_defuse);
ATF_TC_HEAD(tls_extern_dynamic_defuse, tc)
{
@@ -41,23 +86,8 @@ ATF_TC_HEAD(tls_extern_dynamic_defuse, t
}
ATF_TC_BODY(tls_extern_dynamic_defuse, tc)
{
- void *def, *use;
- int *(*fdef)(void), *(*fuse)(void);
- int *pdef, *puse;
-
- (void)dlerror();
-
- ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", 0));
- ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0));
-
- ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
- ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
-
- pdef = (*fdef)();
- puse = (*fuse)();
- ATF_CHECK_EQ_MSG(pdef, puse,
- "%p in defining library != %p in using library",
- pdef, puse);
+ tls_extern("libh_def_dynamic.so", "libh_use_dynamic.so",
+ DEF_USE, /*xfail*/false);
}
ATF_TC(tls_extern_dynamic_usedef);
@@ -68,23 +98,8 @@ ATF_TC_HEAD(tls_extern_dynamic_usedef, t
}
ATF_TC_BODY(tls_extern_dynamic_usedef, tc)
{
- void *def, *use;
- int *(*fdef)(void), *(*fuse)(void);
- int *pdef, *puse;
-
- (void)dlerror();
-
- ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0));
- ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", 0));
-
- ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
- ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
-
- pdef = (*fdef)();
- puse = (*fuse)();
- ATF_CHECK_EQ_MSG(pdef, puse,
- "%p in defining library != %p in using library",
- pdef, puse);
+ tls_extern("libh_def_dynamic.so", "libh_use_dynamic.so",
+ USE_DEF, /*xfail*/false);
}
ATF_TC(tls_extern_dynamic_usedefnoload);
@@ -95,23 +110,8 @@ ATF_TC_HEAD(tls_extern_dynamic_usedefnol
}
ATF_TC_BODY(tls_extern_dynamic_usedefnoload, tc)
{
- void *def, *use;
- int *(*fdef)(void), *(*fuse)(void);
- int *pdef, *puse;
-
- (void)dlerror();
-
- ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0));
- ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", RTLD_NOLOAD));
-
- ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
- ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
-
- pdef = (*fdef)();
- puse = (*fuse)();
- ATF_CHECK_EQ_MSG(pdef, puse,
- "%p in defining library != %p in using library",
- pdef, puse);
+ tls_extern("libh_def_dynamic.so", "libh_use_dynamic.so",
+ USE_DEF_NOLOAD, /*xfail*/false);
}
ATF_TC(tls_extern_static_defuse);
@@ -122,23 +122,8 @@ ATF_TC_HEAD(tls_extern_static_defuse, tc
}
ATF_TC_BODY(tls_extern_static_defuse, tc)
{
- void *def, *use;
- int *(*fdef)(void), *(*fuse)(void);
- int *pdef, *puse;
-
- (void)dlerror();
-
- ATF_REQUIRE_DL(def = dlopen("libh_def_static.so", 0));
- ATF_REQUIRE_DL(use = dlopen("libh_use_static.so", 0));
-
- ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
- ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
-
- pdef = (*fdef)();
- puse = (*fuse)();
- ATF_CHECK_EQ_MSG(pdef, puse,
- "%p in defining library != %p in using library",
- pdef, puse);
+ tls_extern("libh_def_static.so", "libh_use_static.so",
+ DEF_USE, /*xfail*/false);
}
ATF_TC(tls_extern_static_usedef);
@@ -149,25 +134,8 @@ ATF_TC_HEAD(tls_extern_static_usedef, tc
}
ATF_TC_BODY(tls_extern_static_usedef, tc)
{
- void *def, *use;
- int *(*fdef)(void), *(*fuse)(void);
- int *pdef, *puse;
-
- (void)dlerror();
-
- ATF_REQUIRE_DL(use = dlopen("libh_use_static.so", 0));
- ATF_REQUIRE_DL(def = dlopen("libh_def_static.so", 0));
-
- ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
- ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
-
- pdef = (*fdef)();
- puse = (*fuse)();
- atf_tc_expect_fail("PR toolchain/50277:"
- " rtld relocation bug with thread local storage");
- ATF_CHECK_EQ_MSG(pdef, puse,
- "%p in defining library != %p in using library",
- pdef, puse);
+ tls_extern("libh_def_static.so", "libh_use_static.so",
+ USE_DEF, /*xfail*/true);
}
ATF_TC(tls_extern_static_usedefnoload);
@@ -178,25 +146,8 @@ ATF_TC_HEAD(tls_extern_static_usedefnolo
}
ATF_TC_BODY(tls_extern_static_usedefnoload, tc)
{
- void *def, *use;
- int *(*fdef)(void), *(*fuse)(void);
- int *pdef, *puse;
-
- (void)dlerror();
-
- ATF_REQUIRE_DL(use = dlopen("libh_use_static.so", 0));
- ATF_REQUIRE_DL(def = dlopen("libh_def_static.so", RTLD_NOLOAD));
-
- ATF_REQUIRE_DL(fdef = dlsym(def, "fdef"));
- ATF_REQUIRE_DL(fuse = dlsym(use, "fuse"));
-
- pdef = (*fdef)();
- puse = (*fuse)();
- atf_tc_expect_fail("PR toolchain/50277:"
- " rtld relocation bug with thread local storage");
- ATF_CHECK_EQ_MSG(pdef, puse,
- "%p in defining library != %p in using library",
- pdef, puse);
+ tls_extern("libh_def_static.so", "libh_use_static.so",
+ USE_DEF_NOLOAD, /*xfail*/true);
}
ATF_TP_ADD_TCS(tp)
Home |
Main Index |
Thread Index |
Old Index