Created
October 7, 2022 21:11
-
-
Save chantra/5c7dd823e2b7c9419ef55d8139e82010 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -a TEST_NAMES_FROM_BOOT | |
read_test_from_boot() { | |
# Check if test names were passed as boot parameter. | |
# We expect `run_tests` to be a comma-separated list of test names. | |
IFS=',' read -r -a TEST_NAMES_FROM_BOOT <<< \ | |
"$(sed -n 's/.*run_tests=\([^ ]*\).*/\1/p' /tmp/a)" | |
echo "${TEST_NAMES_FROM_BOOT[@]}" | |
} | |
# Expect 2 tests | |
echo "BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.19.11-300.fc37.x86_64 root=UUID=ac6e459c-7981-469d-916a-58ed2b23a3ef ro rootflags=subvol=root rd.luks.uuid=luks-e2fb3dac-2da5-4503-a4b8-b55de838800a rhgb quiet run_tests=test_progs,test_progs2" > /tmp/a | |
read_test_from_boot | |
echo "${#TEST_NAMES_FROM_BOOT[@]}" | |
# Expect 0 test | |
echo "BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.19.11-300.fc37.x86_64 root=UUID=ac6e459c-7981-469d-916a-58ed2b23a3ef ro rootflags=subvol=root rd.luks.uuid=luks-e2fb3dac-2da5-4503-a4b8-b55de838800a rhgb quiet abc" > /tmp/a | |
read_test_from_boot | |
echo "${#TEST_NAMES_FROM_BOOT[@]}" | |
# Expect 2 tests, some trailing content | |
echo "BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.19.11-300.fc37.x86_64 root=UUID=ac6e459c-7981-469d-916a-58ed2b23a3ef ro rootflags=subvol=root rd.luks.uuid=luks-e2fb3dac-2da5-4503-a4b8-b55de838800a rhgb quiet run_tests=test_progs,test_progs2 abc" > /tmp/a | |
read_test_from_boot | |
echo "${#TEST_NAMES_FROM_BOOT[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ /tmp/example.sh
test_progs test_progs2
2
0
test_progs test_progs2
2