From b1eecb51ccb023964acf61e5bf34e625b19df9fb Mon Sep 17 00:00:00 2001 From: Robin Newton Date: Tue, 26 Mar 2024 17:12:00 +0000 Subject: [PATCH] CP-45750 get storage-init test to work when sh != bash * storage-init itself contains bashisms, so in the tests don't try to run it with sh * bash run under its own name seems a bit resistent to attempts to redefine '[', so instead manipulate storage-init to subsistute uses of this for a mockable alternative. Signed-off-by: Robin Newton --- tests/test_storage_init.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/test_storage_init.py b/tests/test_storage_init.py index efe27d4c6..9b7138a4b 100644 --- a/tests/test_storage_init.py +++ b/tests/test_storage_init.py @@ -36,8 +36,8 @@ def setUp(self): # There are tweaks we need to make the to storage-init: # - Change the location of various key files - # - Add an alias for the shell's built-in '[' operator to a command we - # can mock + # - Replace the uses of the shell's built-in '[' operator to a command + # we can mock # - Ensure that the script calls a special command when it exits, so # that the test knows when it is done. @@ -61,7 +61,8 @@ def setUp(self): script = re.sub(r"/var/lib/misc/ran-storage-init\b", os.path.join(self.test_dir.name, "ran-storage-init"), script) - script = f"trap on_exit EXIT\nalias [=mock_test\n{script}" + script = re.sub(r"(?