[Buildroot] [git commit branch/2023.02.x] support/testing: new runtime test for bash

Peter Korsgaard peter at korsgaard.com
Fri Jun 9 08:12:23 UTC 2023


commit: https://git.buildroot.net/buildroot/commit/?id=a5ce02522a7c0c2ced03cd1b0350db68c1b28f6d
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2023.02.x

Commit 2dff6e93ca2a (package/readline: add upstream patch to fix crash
with invalid locale specification) fixed a regression in readline 8.2
[0], that could have been caught with a runtime test. readline is a
library, so we need an executable that exercises readline.

Since readline and bash are developped in tandem [1], it is only logical
to use bash to test readline.

Add a new runtime test for bash, that checks that we can indeed run an
interactive shell, and that an non-existing locale does not cause the
dreaded segfault. We do not use the default configuration, because it
uses a uclibc toolchain, and we want to reproduce against a glibc one.

[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021109
[1] https://tiswww.case.edu/php/chet/readline/rltop.html#Bugs

Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
(cherry picked from commit 511f28ae5ca0fbd3c997f5c460747a5d3e0ca24b)
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
---
 support/testing/tests/package/test_bash.py | 47 ++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/support/testing/tests/package/test_bash.py b/support/testing/tests/package/test_bash.py
new file mode 100644
index 0000000000..f0ee8cadc1
--- /dev/null
+++ b/support/testing/tests/package/test_bash.py
@@ -0,0 +1,47 @@
+import os
+
+import infra.basetest
+
+
+class TestBash(infra.basetest.BRTest):
+    config = \
+        """
+        BR2_arm=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+        BR2_ENABLE_LOCALE_WHITELIST=""
+        BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+        BR2_PACKAGE_BASH=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        # Check that we are indeed not (yet) running bash
+        out, _ = self.emulator.run('echo "${BASH}"')
+        self.assertEqual(out[0], "", "Already running bash instead of busybox' sh")
+
+        self.assertRunOk("bash -il")
+        # Twist! The above command is still runing, it's just that
+        # bash did display the prompt we expect. Check we are indeed
+        # actually bash
+        out, _ = self.emulator.run('echo "${BASH}"')
+        self.assertEqual(out[0], "/bin/bash", "Not running bash")
+        # Exit bash, back to busybox' shell
+        self.emulator.run("exit 0")
+
+        # Check that we are indeed no longer running bash
+        out, _ = self.emulator.run('echo "${BASH}"')
+        self.assertEqual(out[0], "", "Still running bash instead of busybox' sh")
+
+        # Try to run with a non-available locale
+        self.assertRunOk("LC_ALL=en_US bash -il")
+        out, _ = self.emulator.run('echo "${BASH}"')
+        self.assertEqual(out[0], "/bin/bash", "Not running bash")
+        self.emulator.run("exit 0")



More information about the buildroot mailing list