From 79a29381a4e708c4cbd38d831d4b2d5ad546d97e Mon Sep 17 00:00:00 2001 From: Kristian Schuster Date: Sun, 26 Jan 2020 19:13:26 +0100 Subject: [PATCH] restructered test and fixed vmlinuz detection --- include/tests_kernel | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/include/tests_kernel b/include/tests_kernel index 0f72525e..e7b6b742 100644 --- a/include/tests_kernel +++ b/include/tests_kernel @@ -624,7 +624,7 @@ fi # Check if /boot exists - if [ ${PRIVILEGED} -eq 1 -a -d "${ROOTDIR}boot" ]; then + if [ -d "${ROOTDIR}boot" ]; then LogText "Result: /boot exists, performing more tests from here" FIND=$(${LSBINARY} ${ROOTDIR}boot/* 2> /dev/null) if [ -n "${FIND}" ]; then @@ -650,18 +650,17 @@ else ReportException "${TEST_NO}:1" "Can't determine kernel version on disk, need debug data" fi - elif [ -f ${ROOTDIR}boot/vmlinuz-linux -o -f ${ROOTDIR}boot/vmlinuz-linux-lts -o -f $(ls -t ${ROOTDIR}boot/vm[l-]* 2> /dev/null | head -1) ]; then - if [ -L ${ROOTDIR}boot/vmlinuz-linux ]; then - LogText "Result: found symlink ${ROOTDIR}boot/vmlinuz-linux" - FOUND_VMLINUZ=$(readlink ${ROOTDIR}boot/vmlinuz-linux) - LogText "Result: symlinked target is ${FOUND_VMLINUZ}" - VERSION_ON_DISK=$(echo ${FOUND_VMLINUZ} | ${SEDBINARY} 's/^vmlinuz-//') + elif [ -f ${ROOTDIR}boot/vmlinuz-linux ] || [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ] || [ -f "$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${HEADBINARY} -1)" ]; then + if [ -f ${ROOTDIR}boot/vmlinuz-linux ]; then + LogText "Result: found ${ROOTDIR}boot/vmlinuz-linux" + FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux elif [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ]; then - LogText "Result: found boot/vmlinuz-linux-lts" + LogText "Result: found ${ROOTDIR}boot/vmlinuz-linux-lts" FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux-lts else # Match on /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default - FOUND_VMLINUZ=$(ls -t ${ROOTDIR}boot/vm[l-]* 2> /dev/null | head -1) + FOUND_VMLINUZ=$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${HEADBINARY} -1) + LogText "Result: found ${FOUND_VMLINUZ}" fi if [ -L "${FOUND_VMLINUZ}" ]; then @@ -673,7 +672,6 @@ fi if [ -z "${VERSION_ON_DISK}" ]; then - LogText "Result: found ${FOUND_VMLINUZ}" LogText "Test: checking kernel version on disk" NEXTLINE=0 VERSION_ON_DISK="" @@ -686,6 +684,11 @@ if [ "${I}" = "version" ]; then NEXTLINE=1; fi fi done + fi + + if [ -z "${VERSION_ON_DISK}" ]; then + LogText "Result: could not find the version on disk" + ReportException "${TEST_NO}:4" "Could not find the kernel version" else LogText "Result: found version ${VERSION_ON_DISK}" ACTIVE_KERNEL=$(uname -r) @@ -698,10 +701,6 @@ LogText "Result: reboot needed, as there is a difference between active kernel and the one on disk" fi fi - if [ -z "${VERSION_ON_DISK}" ]; then - LogText "Result: could not find the version on disk" - ReportException "${TEST_NO}:4" "Could not find the kernel version" - fi else if [ -L ${ROOTDIR}boot/vmlinuz ]; then LogText "Result: found symlink of ${ROOTDIR}boot/vmlinuz, skipping file"