selftest/kexec: fix "ignored null byte in input" warning
authorMimi Zohar <zohar@linux.ibm.com>
Wed, 24 Nov 2021 07:08:00 +0000 (12:38 +0530)
committerMimi Zohar <zohar@linux.ibm.com>
Fri, 31 Dec 2021 18:16:02 +0000 (13:16 -0500)
Instead of assigning the string to a variable, which might contain a
null character, redirect the output and grep for the string directly.

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
tools/testing/selftests/kexec/test_kexec_file_load.sh

index 2ff600388c30b686927770b2ac4d9fe020c7f35f..99f6fc23ee31498165a35e2056a08bb448afe01c 100755 (executable)
@@ -97,10 +97,11 @@ check_for_imasig()
 check_for_modsig()
 {
        local module_sig_string="~Module signature appended~"
-       local sig="$(tail --bytes $((${#module_sig_string} + 1)) $KERNEL_IMAGE)"
        local ret=0
 
-       if [ "$sig" == "$module_sig_string" ]; then
+       tail --bytes $((${#module_sig_string} + 1)) $KERNEL_IMAGE | \
+               grep -q "$module_sig_string"
+       if [ $? -eq 0 ]; then
                ret=1
                log_info "kexec kernel image modsig signed"
        else