From 4586e03b4526a74bcd45662634bf9d76808ae343 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Mon, 10 Jun 2024 16:13:28 +0300 Subject: [PATCH] Code refactoring to improve test coverage (II) Test the `-v` argument. --- .github/workflows/functional_test.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/functional_test.sh b/.github/workflows/functional_test.sh index ca50aaf..d894c94 100644 --- a/.github/workflows/functional_test.sh +++ b/.github/workflows/functional_test.sh @@ -70,13 +70,17 @@ coverage run -a --branch bin/kernel-hardening-checker -s $SYSCTL_EXAMPLE -m json coverage run -a --branch bin/kernel-hardening-checker -s $SYSCTL_EXAMPLE -m show_ok coverage run -a --branch bin/kernel-hardening-checker -s $SYSCTL_EXAMPLE -m show_fail +echo ">>>>> test -v (kernel version detection) <<<<<" +cp kernel_hardening_checker/config_files/distros/fedora_34.config ./test.config +coverage run -a --branch bin/kernel-hardening-checker -c ./test.config -v /proc/version + echo "Collect coverage for error handling" echo ">>>>> -c and -p together <<<<<" -coverage run -a --branch bin/kernel-hardening-checker -p X86_64 -c kernel_hardening_checker/config_files/distros/fedora_34.config && exit 1 +coverage run -a --branch bin/kernel-hardening-checker -p X86_64 -c ./test.config && exit 1 echo ">>>>> -c and -g together <<<<<" -coverage run -a --branch bin/kernel-hardening-checker -g X86_64 -c kernel_hardening_checker/config_files/distros/fedora_34.config && exit 1 +coverage run -a --branch bin/kernel-hardening-checker -g X86_64 -c ./test.config && exit 1 echo ">>>>> -l without -c <<<<<" coverage run -a --branch bin/kernel-hardening-checker -l /proc/cmdline && exit 1 @@ -97,8 +101,6 @@ coverage run -a --branch bin/kernel-hardening-checker -p X86_64 -m show_fail && echo ">>>>> wrong mode for -g <<<<<" coverage run -a --branch bin/kernel-hardening-checker -g X86_64 -m show_ok && exit 1 -cp kernel_hardening_checker/config_files/distros/fedora_34.config ./test.config - echo ">>>>> no kconfig file <<<<<" coverage run -a --branch bin/kernel-hardening-checker -c ./nosuchfile && exit 1 @@ -116,10 +118,14 @@ echo ">>>>> no kernel version <<<<<" sed '3d' test.config > error.config coverage run -a --branch bin/kernel-hardening-checker -c error.config && exit 1 -echo ">>>>> strange kernel version string <<<<<" +echo ">>>>> strange kernel version in kconfig <<<<<" sed '3 s/5./version 5./' test.config > error.config coverage run -a --branch bin/kernel-hardening-checker -c error.config && exit 1 +echo ">>>>> strange kernel version via -v <<<<<" +sed '3d' test.config > error.config +coverage run -a --branch bin/kernel-hardening-checker -c error.config -v /proc/cmdline && exit 1 + echo ">>>>> no arch <<<<<" sed '305d' test.config > error.config coverage run -a --branch bin/kernel-hardening-checker -c error.config && exit 1 -- 2.31.1