Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/testing: new runtime test for bash
@ 2023-04-24 21:51 Yann E. MORIN
  2023-05-08 21:53 ` Yann E. MORIN
  2023-06-09  9:09 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Yann E. MORIN @ 2023-04-24 21:51 UTC (permalink / raw)
  To: buildroot; +Cc: Yann E. MORIN

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@free.fr>
---
 support/testing/tests/package/test_bash.py | 47 ++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 support/testing/tests/package/test_bash.py

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")
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-09  9:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-24 21:51 [Buildroot] [PATCH] support/testing: new runtime test for bash Yann E. MORIN
2023-05-08 21:53 ` Yann E. MORIN
2023-06-09  9:09 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox