From 1a49685c289ad4f699f01398f014adaf3b2b2d03 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 4 Aug 2014 05:45:09 +0000 Subject: [PATCH] Remove hardcoded path to TESTSDIR (Makefile, ld_library_pathfds.c) at build time by using atf_tc_get_config_var(tc, "srcdir")) This will allow end-users to move the binaries to different locations after they've been built without having to rebuild the binaries with the new paths Phabric: D525 (part of a larger patch) Reviewed by: jmmv Approved by: jmmv (co-mentor) --- libexec/rtld-elf/tests/Makefile | 2 -- libexec/rtld-elf/tests/ld_library_pathfds.c | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libexec/rtld-elf/tests/Makefile b/libexec/rtld-elf/tests/Makefile index 5e57f60f3f53..cc4fac8fc5ca 100644 --- a/libexec/rtld-elf/tests/Makefile +++ b/libexec/rtld-elf/tests/Makefile @@ -9,6 +9,4 @@ SUBDIR+= libpythagoras target ATF_TESTS_C= ld_library_pathfds -CFLAGS+= -DTESTSDIR="\"${TESTSDIR}\"" - .include diff --git a/libexec/rtld-elf/tests/ld_library_pathfds.c b/libexec/rtld-elf/tests/ld_library_pathfds.c index 274b5e820206..b8ef31ee8f2b 100644 --- a/libexec/rtld-elf/tests/ld_library_pathfds.c +++ b/libexec/rtld-elf/tests/ld_library_pathfds.c @@ -38,7 +38,7 @@ struct descriptors { int usr; }; -static void setup(struct descriptors *); +static void setup(struct descriptors *, const atf_tc_t *); static void expect_success(int binary, char *pathfds); static void expect_missing_library(int binary, char *pathfds); @@ -53,7 +53,7 @@ ATF_TC_BODY(missing_library, tc) { struct descriptors files; - setup(&files); + setup(&files, tc); expect_missing_library(files.binary, NULL); } @@ -64,7 +64,7 @@ ATF_TC_BODY(wrong_library_directories, tc) struct descriptors files; char *pathfds; - setup(&files); + setup(&files, tc); ATF_REQUIRE( asprintf(&pathfds, "LD_LIBRARY_PATH_FDS=%d", files.etc) > 0); @@ -78,7 +78,7 @@ ATF_TC_BODY(bad_library_directories, tc) struct descriptors files; char *pathfds; - setup(&files); + setup(&files, tc); ATF_REQUIRE(asprintf(&pathfds, "::", files.etc) > 0); expect_missing_library(files.binary, pathfds); @@ -91,7 +91,7 @@ ATF_TC_BODY(single_library_directory, tc) struct descriptors files; char *pathfds; - setup(&files); + setup(&files, tc); ATF_REQUIRE( asprintf(&pathfds, "LD_LIBRARY_PATH_FDS=%d", files.testdir) > 0); @@ -105,7 +105,7 @@ ATF_TC_BODY(first_library_directory, tc) struct descriptors files; char *pathfds; - setup(&files); + setup(&files, tc); ATF_REQUIRE( asprintf(&pathfds, "LD_LIBRARY_PATH_FDS=%d:%d", files.testdir, files.etc) > 0); @@ -120,7 +120,7 @@ ATF_TC_BODY(middle_library_directory, tc) struct descriptors files; char *pathfds; - setup(&files); + setup(&files, tc); ATF_REQUIRE( asprintf(&pathfds, "LD_LIBRARY_PATH_FDS=%d:%d:%d", files.root, files.testdir, files.usr) > 0); @@ -135,7 +135,7 @@ ATF_TC_BODY(last_library_directory, tc) struct descriptors files; char *pathfds; - setup(&files); + setup(&files, tc); ATF_REQUIRE( asprintf(&pathfds, "LD_LIBRARY_PATH_FDS=%d:%d", files.root, files.testdir) > 0); @@ -161,10 +161,11 @@ ATF_TP_ADD_TCS(tp) static void -setup(struct descriptors *dp) +setup(struct descriptors *dp, const atf_tc_t *tc) { - ATF_REQUIRE((dp->testdir = opendir(TESTSDIR)) >= 0); + dp->testdir = opendir(atf_tc_get_config_var(tc, "srcdir")); + ATF_REQUIRE(dp->testdir >= 0); ATF_REQUIRE( (dp->binary = openat(dp->testdir, "target", O_RDONLY)) >= 0);