]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: correctly process multiline strings in $KERNEL_APPEND
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 19 Aug 2022 14:30:24 +0000 (16:30 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 19 Aug 2022 21:31:32 +0000 (22:31 +0100)
Some tests (like TEST-02) set a multiline string to $KERNEL_APPEND
(which is a valid thing to do), unfortunately we'd use only the first
line of it and throw the rest away, e.g:

```
$ printf "%s" "$x"
hello

this is a multiline

kernel command line
$ read -ra out <<< "$x"
$ printf "%s" "${out[@]}"
hello
```

Let's use readarray/mapfile instead to avoid this:

```
$ readarray out <<< "$x"
$ printf "%s" "${out[@]}"
hello

this is a multiline

kernel command line

```

test/test-functions

index 5dec5e28dec1e04b1270ee432a28d7c0b19c71f5..3cdfd800f08c5db96956a98646321366dcff99de 100644 (file)
@@ -498,7 +498,7 @@ run_qemu() {
 
     if [[ -n "${KERNEL_APPEND:=}" ]]; then
         local user_kernel_append
-        read -ra user_kernel_append <<< "$KERNEL_APPEND"
+        readarray user_kernel_append <<< "$KERNEL_APPEND"
         kernel_params+=("${user_kernel_append[@]}")
     fi
 
@@ -557,7 +557,7 @@ run_nspawn() {
 
     if [[ -n "${KERNEL_APPEND:=}" ]]; then
         local user_kernel_append
-        read -ra user_kernel_append <<< "$KERNEL_APPEND"
+        readarray user_kernel_append <<< "$KERNEL_APPEND"
         kernel_params+=("${user_kernel_append[@]}")
     fi