]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: don't pre-process $KERNEL_APPEND
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 9 Nov 2023 14:33:31 +0000 (15:33 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 9 Nov 2023 16:31:12 +0000 (16:31 +0000)
Let's just rely on the word splitting done by bash instead of messing
with that ourselves, as it's just adding extra complexity to appease one
ShellCheck check. Also, this apparently never worked for the nspawn
stuff anyway, since I forgot to set $IFS to an appropriate value, so it
always put all arguments from $KERNEL_APPEND into a single array item
with an extra newline, which then made systemd sad:

~# readarray arr <<< "foo bar baz"; for i in "${arr[@]}"; do echo "'$i'"; done
'foo bar baz
'
~# make -C test/TEST-45-TIMEDATE/ clean setup run BUILD_DIR=$PWD/build TEST_NO_QEMU=1 KERNEL_APPEND="systemd.log_level=console"
...
~# journalctl -o short-monotonic --no-hostname --file /var/tmp/systemd-tests/systemd-test.XaDX67/system.journal --grep "Failed to parse" -p info --no-pager
[551138.986882] systemd-tmpfiles[21]: Failed to parse log level 'console
[551138.987179] systemd-remount-fs[20]: Failed to parse log level 'console
[551138.993125] systemd-sysusers[23]: Failed to parse log level 'console
[551138.998685] journalctl[29]: Failed to parse log level 'console

Resolves: #29945

test/test-functions

index 8663f902d80141d3d3c51dc0087b5aa12ac61f75..3cb08fb47a9b5db7ee782447b376a9a8c770a8ad 100644 (file)
@@ -594,12 +594,6 @@ run_qemu() {
     fi
     qemu_options+=(${QEMU_OPTIONS_ARRAY:+"${QEMU_OPTIONS_ARRAY[@]}"})
 
-    if [[ -n "${KERNEL_APPEND:=}" ]]; then
-        local user_kernel_append
-        readarray user_kernel_append <<< "$KERNEL_APPEND"
-        kernel_params+=("${user_kernel_append[@]}")
-    fi
-
     if [[ -n "$INITRD" ]]; then
         if [[ -n "$INITRD_EXTRA" ]]; then
             # An addition initrd has been specified, let's combine it with the main one.
@@ -634,7 +628,7 @@ run_qemu() {
         qemu_cmd=(timeout --foreground "$QEMU_TIMEOUT" "$QEMU_BIN")
     fi
 
-    (set -x; "${qemu_cmd[@]}" "${qemu_options[@]}" -append "${kernel_params[*]}" |& tee "${TESTDIR:?}/console.log")
+    (set -x; "${qemu_cmd[@]}" "${qemu_options[@]}" -append "${kernel_params[*]} ${KERNEL_APPEND:-}" |& tee "${TESTDIR:?}/console.log")
     rc=$?
     if [ "$rc" -eq 124 ] && [ "$QEMU_TIMEOUT" != "infinity" ]; then
         derror "Test timed out after ${QEMU_TIMEOUT}s"
@@ -679,12 +673,6 @@ run_nspawn() {
         nspawn_options+=("${user_nspawn_arguments[@]}")
     fi
 
-    if [[ -n "${KERNEL_APPEND:=}" ]]; then
-        local user_kernel_append
-        readarray user_kernel_append <<< "$KERNEL_APPEND"
-        kernel_params+=("${user_kernel_append[@]}")
-    fi
-
     if [[ "$UNIFIED_CGROUP_HIERARCHY" = "hybrid" ]]; then
         dwarn "nspawn doesn't support SYSTEMD_NSPAWN_UNIFIED_HIERARCHY=hybrid, skipping"
         exit
@@ -703,7 +691,9 @@ run_nspawn() {
         nspawn_cmd+=("$SYSTEMD_NSPAWN")
     fi
 
-    (set -x; "${nspawn_cmd[@]}" "${nspawn_options[@]}" "${kernel_params[@]}" |& tee "${TESTDIR:?}/console.log")
+    # Word splitting here is intentional
+    # shellcheck disable=SC2086
+    (set -x; "${nspawn_cmd[@]}" "${nspawn_options[@]}" "${kernel_params[@]}" ${KERNEL_APPEND:-} |& tee "${TESTDIR:?}/console.log")
     rc=$?
     if [ "$rc" -eq 124 ] && [ "$NSPAWN_TIMEOUT" != "infinity" ]; then
         derror "Test timed out after ${NSPAWN_TIMEOUT}s"