From 364b770c648c7a4ee4ab8f3a5dd3e07dbe1f1461 Mon Sep 17 00:00:00 2001 From: Kristian Schuster Date: Sat, 28 Sep 2019 00:39:12 +0200 Subject: kernel-test: determine reboot requirement for more distros. Plus a few fixes --- include/tests_kernel | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'include/tests_kernel') diff --git a/include/tests_kernel b/include/tests_kernel index 56df2a99..95634786 100644 --- a/include/tests_kernel +++ b/include/tests_kernel @@ -527,6 +527,7 @@ for I in $(file ${ROOTDIR}boot/vmlinuz-linux); do if [ ${NEXTLINE} -eq 1 ]; then FINDVERSION="${I}" + break else # Searching for the Linux kernel after the keyword 'version' if [ "${I}" = "version" ]; then NEXTLINE=1; fi @@ -541,16 +542,28 @@ 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 ]; then + elif [ -f ${ROOTDIR}boot/vmlinuz-linux -o -f ${ROOTDIR}boot/vmlinuz-linux-lts -o -f $(ls -t ${ROOTDIR}boot/vmlinuz-* | head -1) ]; then if [ -f ${ROOTDIR}boot/vmlinuz-linux ]; then - LogText "Result: /found /boot/vmlinuz-linux (usually Arch Linux or similar)" - LogText "Test: checking kernel version on disk" - VERSION_ON_DISK=$(${FILEBINARY} -b ${ROOTDIR}boot/vmlinuz-linux | ${AWKBINARY} '{ if ($1=="Linux" && $7=="version") { print $8 }}') + FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux + elif [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ]; then + FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux-lts else - LogText "Result: /found /boot/vmlinuz-linux-lts (usually Arch Linux or similar)" - LogText "Test: checking kernel version on disk" - VERSION_ON_DISK=$(${FILEBINARY} -b ${ROOTDIR}boot/vmlinuz-linux-lts | ${AWKBINARY} '{ if ($1=="Linux" && $7=="version") { print $8 }}') + FOUND_VMLINUZ=$(ls -t ${ROOTDIR}boot/vmlinuz-* | head -1) fi + LogText "Result: /found /boot/vmlinuz-linux-lts (usually Arch Linux or similar)" + LogText "Test: checking kernel version on disk" + #VERSION_ON_DISK=$(${FILEBINARY} -b ${FOUND_VMLINUZ} | ${AWKBINARY} '{ if ($1=="Linux" && $7=="version") { print $8 }}') + NEXTLINE=0 + VERSION_ON_DISK="" + for I in $(file ${FOUND_VMLINUZ}); do + if [ ${NEXTLINE} -eq 1 ]; then + VERSION_ON_DISK="${I}" + break + else + # Searching for the Linux kernel after the keyword 'version' + if [ "${I}" = "version" ]; then NEXTLINE=1; fi + fi + done if [ -n "${VERSION_ON_DISK}" ]; then LogText "Result: found version ${VERSION_ON_DISK}" ACTIVE_KERNEL=$(uname -r) -- cgit v1.2.3