test-container: Set /bin up as a symbolic link to /usr/bin

Message ID 20211112104142.GA30371@lostca.se
State New
Headers
Series test-container: Set /bin up as a symbolic link to /usr/bin |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Arjun Shankar Nov. 12, 2021, 10:41 a.m. UTC
  From: Arjun Shankar <arjun@redhat.com>

This makes the container environment more compatible with various
operating systems.

For example, prior to this commit tst-vfork3 would fail when building
the glibc package for RHEL 9.  This was because _CS_PATH is "/usr/bin"
there instead of the default "/bin:/usr/bin", causing the test to try
to execute /usr/bin/echo in the container where echo was located in /bin
instead.  While this could be fixed in the test itself, this commit
seems like a more general solution.
---
 Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
  

Comments

Florian Weimer Nov. 12, 2021, 12:25 p.m. UTC | #1
* Arjun Shankar via Libc-alpha:

> From: Arjun Shankar <arjun@redhat.com>
>
> This makes the container environment more compatible with various
> operating systems.
>
> For example, prior to this commit tst-vfork3 would fail when building
> the glibc package for RHEL 9.  This was because _CS_PATH is "/usr/bin"
> there instead of the default "/bin:/usr/bin", causing the test to try
> to execute /usr/bin/echo in the container where echo was located in /bin
> instead.  While this could be fixed in the test itself, this commit
> seems like a more general solution.

Thank you for this analysis.

I think this is just a broken downstream patch.  We should fix this
downstream for now, probably adding the symbolic links our installation
has to the containers.

We need real UsrMove support in glibc, as a configure-time option.  This
would activate the _CS_PATH change in our downstream patch, change the
default library search path, alter the installation paths (and probably
create the symbolic links if they do not exist), and make sure that the
test containers match the installation tree.

Thanks,
Florian
  

Patch

diff --git a/Makefile b/Makefile
index a49870d3d1..d738bd07d2 100644
--- a/Makefile
+++ b/Makefile
@@ -598,15 +598,17 @@  $(tests-container) $(addsuffix /tests,$(subdirs)) : \
 $(objpfx)testroot.pristine/install.stamp :
 	test -d $(objpfx)testroot.pristine || \
 	  mkdir $(objpfx)testroot.pristine
-	# We need a working /bin/sh for some of the tests.
-	test -d $(objpfx)testroot.pristine/bin || \
-	  mkdir $(objpfx)testroot.pristine/bin
+	test -d $(objpfx)testroot.pristine/usr/bin || \
+	  mkdir -p $(objpfx)testroot.pristine/usr/bin
+	# We need a /bin for some of the tests, so we symlink it to /usr/bin
+	test -e $(objpfx)testroot.pristine/bin || \
+	  ln -s usr/bin $(objpfx)testroot.pristine/bin
 	# We need the compiled locale dir for localedef tests.
 	test -d $(objpfx)testroot.pristine/$(complocaledir) || \
 	  mkdir -p $(objpfx)testroot.pristine/$(complocaledir)
-	cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh
-	cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo
-	cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true
+	cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/usr/bin/sh
+	cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/usr/bin/echo
+	cp $(objpfx)support/true-container $(objpfx)testroot.pristine/usr/bin/true
 ifeq ($(run-built-tests),yes)
 	# Copy these DSOs first so we can overwrite them with our own.
 	for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1  \