support/testing: new runtime test for bash
Commit2dff6e93ca
(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> (cherry picked from commit511f28ae5c
) Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
parent
d9f2fa8e63
commit
a5ce02522a
47
support/testing/tests/package/test_bash.py
Normal file
47
support/testing/tests/package/test_bash.py
Normal file
@ -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")
|
Loading…
Reference in New Issue
Block a user