diff mbox series

[v3,2/4] support/testing/tests/package/test_bash.py: do not read startup files

Message ID 20230706201917.284060-2-ju.o@free.fr
State New
Headers show
Series [v3,1/4] support/testing/infra/emulator.py: change the shell prompt before running tests | expand

Commit Message

Julien Olivain July 6, 2023, 8:19 p.m. UTC
The commit:
"support/testing/infra/emulator.py: change the shell prompt before running tests"
changed the prompt before running tests.

When bash is invoked as a login shell in this test, it will read
system-wide configuration files. The "/etc/profile" file, in the
Buildroot filesystem skeleton in "system/skeleton/etc/profile" always
overwrite the PS1 prompt variable. Since the prompt set in the
emulator is different than the one in the system skeleton, the test
fails.

This commit adds the "--noprofile --norc" options when invoking "bash"
to make sure the PS1 prompt variable will not be overwritten, and will
rather be inherited from the calling shell.

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
This is a new patch in this v3 series to fix the bash runtime test, as
reported by Yann in:
https://lists.buildroot.org/pipermail/buildroot/2023-June/669510.html
---
 support/testing/tests/package/test_bash.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/support/testing/tests/package/test_bash.py b/support/testing/tests/package/test_bash.py
index f0ee8cadc1..2a25da13e7 100644
--- a/support/testing/tests/package/test_bash.py
+++ b/support/testing/tests/package/test_bash.py
@@ -27,7 +27,9 @@  class TestBash(infra.basetest.BRTest):
         out, _ = self.emulator.run('echo "${BASH}"')
         self.assertEqual(out[0], "", "Already running bash instead of busybox' sh")
 
-        self.assertRunOk("bash -il")
+        # We disable profile/rc files to avoid overwriting PS1 prompt.
+        # The new bash process will inherit PS1 from the caller shell.
+        self.assertRunOk("bash --noprofile --norc -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
@@ -41,7 +43,7 @@  class TestBash(infra.basetest.BRTest):
         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")
+        self.assertRunOk("LC_ALL=en_US bash --noprofile --norc -il")
         out, _ = self.emulator.run('echo "${BASH}"')
         self.assertEqual(out[0], "/bin/bash", "Not running bash")
         self.emulator.run("exit 0")