This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Use $(built-program-cmd) in io/ftwtest-sh
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Fri, 19 Oct 2012 20:51:19 +0000
- Subject: Use $(built-program-cmd) in io/ftwtest-sh
The logic for running io/ftwtest-sh attempts to compute absolute paths
to $(common-objpfx) and the test executable, because of the script
changing working directory at various points, and the script them sets
LD_LIBRARY_PATH and runs the dynamic linker directly using those
paths.
$(common-objpfx) can now be assumed to use absolute paths, and the
paths used for running a built program can be assumed to be absolute -
this follows from the requirement that testing is run outside the
build directory and the way makefile variables are set from $(objdir),
which is set in the build-directory Makefile generated by Makefile.in.
Thus there is no need for this extra complexity to determine absolute,
and the script can actually run the test program using an appropriate
command determined by the makefile. This patch arranges for it to do
so, passing $(built-program-cmd) down to the script (having ensured
that the ftwtest executable is the second dependency of the makefile
rule, as required by $(built-program-cmd)).
This follows
<http://sourceware.org/ml/libc-alpha/2012-10/msg00506.html>
(posix/tst-getconf.sh, committed) and
<http://sourceware.org/ml/libc-alpha/2012-10/msg00486.html>
(miscellaneous test scripts, pending review) and various other tests
that already worked by passing down $(run-program-prefix) or
$(built-program-cmd) before this patch series. (As with the other
patches, this changes the details of the exact command / environment
used to run ftwtest, but in the direction of greater consistency
between different tests.)
Tested x86_64.
2012-10-19 Joseph Myers <joseph@codesourcery.com>
* io/Makefile ($(objpfx)ftwtest.out): Depend on ftwtest-sh. Pass
script to $(SHELL) as $<. Pass $(common-objpfx) to script
directly. Pass built executable to script as
$(built-program-cmd).
* io/ftwtest-sh (ldso): Remove variable. Run ftwtest directly as
$testprogram without using LD_LIBRARY_PATH and $ldso.
diff --git a/io/Makefile b/io/Makefile
index f6534c0..9601a6f 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -101,7 +101,6 @@ tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
ifeq ($(cross-compiling),no)
tests: $(objpfx)ftwtest.out
-$(objpfx)ftwtest.out: $(objpfx)ftwtest
- $(SHELL) ftwtest-sh $(shell cd $(common-objpfx). && pwd)/ \
- $(shell cd $(<D) && pwd)/$(<F) > $@
+$(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
+ $(SHELL) $< $(common-objpfx) '$(built-program-cmd)' > $@
endif
diff --git a/io/ftwtest-sh b/io/ftwtest-sh
index 93b2e66..adc6667 100644
--- a/io/ftwtest-sh
+++ b/io/ftwtest-sh
@@ -47,8 +47,6 @@ export LANG
tmp=`pwd | sed 's|\(.\)/*$|\1|'`
tmpdir=$tmp/ftwtest.d
-[ -f ${objpfx}elf/ld.so ] && ldso=${objpfx}elf/ld.so
-
trap 'chmod -fR a+x $tmpdir; rm -fr $tmpdir $testout' 1 2 3 15
if test -d $tmpdir; then
@@ -73,7 +71,7 @@ chmod a-x,a+r $tmpdir/bar
testout=$tmp/ftwtest.out
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram $tmpdir |
+$testprogram $tmpdir |
sort > $testout
cat <<EOF | cmp $testout - || exit 1
@@ -92,7 +90,7 @@ base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, leve
EOF
rm $testout
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --depth $tmpdir |
+$testprogram --depth $tmpdir |
sort > $testout
cat <<EOF | cmp $testout - || exit 1
@@ -111,7 +109,7 @@ base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, leve
EOF
rm $testout
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --phys $tmpdir |
+$testprogram --phys $tmpdir |
sort > $testout
cat <<EOF | cmp $testout - || exit 1
@@ -135,7 +133,7 @@ rm $testout
# For the next test everything must be readable.
chmod -fR a+x $tmpdir
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir $tmpdir |
+$testprogram --chdir $tmpdir |
sort > $testout
# perhaps $tmp involves some symlinks...
@@ -159,7 +157,7 @@ rm $testout
curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
cd "$tmp"
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d |
+$testprogram --chdir ftwtest.d |
sort > $testout
cd "$curwd"
@@ -181,7 +179,7 @@ rm $testout
curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
cd "$tmp"
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/. |
+$testprogram --chdir ftwtest.d/. |
sort > $testout
cd "$curwd"
@@ -203,7 +201,7 @@ rm $testout
curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
cd "$tmp"
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/foo/lvl1/link@1 |
+$testprogram --chdir ftwtest.d/foo/lvl1/link@1 |
sort > $testout
cd "$curwd"
@@ -212,7 +210,7 @@ base = "ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ft
EOF
rm $testout
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --early-exit $tmpdir |
+$testprogram --early-exit $tmpdir |
sort > $testout
cat <<EOF | cmp $testout - || exit 1
@@ -226,7 +224,7 @@ echo > $tmpdir/foo/lvl1b/file@1b
echo > $tmpdir/foo/lvl1b/file2@1b
echo > $tmpdir/foo/lvl1b/file3@1b
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --skip-subtree=lvl1 $tmpdir |
+$testprogram --skip-subtree=lvl1 $tmpdir |
sort > $testout
cat <<EOF | diff -u $testout - || exit 1
@@ -243,7 +241,7 @@ base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file@1b", flag = FTW_F, level = 3
EOF
rm $testout
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --skip-siblings=lvl1 $tmpdir |
+$testprogram --skip-siblings=lvl1 $tmpdir |
sort > $testout
# The filesystem is not required to put lvl1 before lvl1b.
@@ -267,7 +265,7 @@ base = "$tmp/ftwtest.d/foo/lvl1b/", file = "file@1b", flag = FTW_F, level = 3
EOF
rm $testout
-LD_LIBRARY_PATH=$objpfx $ldso $testprogram --skip-siblings=file@1b $tmpdir |
+$testprogram --skip-siblings=file@1b $tmpdir |
sort > $testout
# The filesystem is not required to put file2@1b and file3@1b after file@1b.
--
Joseph S. Myers
joseph@codesourcery.com