aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Roxell <anders.roxell@linaro.org>2021-10-22 11:22:30 +0200
committernareshkamboju <naresh.kamboju@gmail.com>2021-10-24 07:22:27 +0530
commitc4ecdbdcb8122adacb24f47dd7e8e523c8fb63d4 (patch)
tree84d7be48151235b82614e03492d305bb89e39c30
parentcd290705abbe2a77868e276b8abd3d8e1d21dcc8 (diff)
kunit: fix find of kunit modules
Make it possible to pass in a module name or the last part of a module name like 'test.ko', then this will find all modules that ends with '*test.ko'. Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
-rwxr-xr-xautomated/linux/kunit/kunit.sh61
-rw-r--r--automated/linux/kunit/kunit.yaml5
2 files changed, 41 insertions, 25 deletions
diff --git a/automated/linux/kunit/kunit.sh b/automated/linux/kunit/kunit.sh
index 7b83df16..e553d27a 100755
--- a/automated/linux/kunit/kunit.sh
+++ b/automated/linux/kunit/kunit.sh
@@ -9,8 +9,9 @@ TEST_LOG="${OUTPUT}/test_log.txt"
TEST_PASS_FAIL_LOG="${OUTPUT}/test_pass_fail_log.txt"
TEST_CMD="dmesg"
TEST_CMD_FILE="${OUTPUT}/${TEST_CMD}.txt"
-# Example KUNIT_TEST_MODULE="kunit-test.ko"
-KUNIT_TEST_MODULE=""
+# This will try to find all modules that ends with '*test.ko'
+# Example KUNIT_TEST_MODULE="test.ko"
+KUNIT_TEST_MODULE="test.ko"
usage() {
echo "Usage: $0 [-m <kunit test module> ]" 1>&2
@@ -57,30 +58,44 @@ check_root || error_msg "Please run this script as root"
# Test run.
create_out_dir "${OUTPUT}"
-if [ -n "${KUNIT_TEST_MODULE}" ] && ! lsmod | grep "${KUNIT_TEST_MODULE%.*}";
+find "/lib/modules/$(uname -r)" -name "*${KUNIT_TEST_MODULE}*"| tee /tmp/kunit_modules.txt
+rm /tmp/kunit_module_names_not_loaded.txt 2>/dev/null
+# find modules that isn't loaded
+while read -r module; do
+ module_name=$(echo "${module}"|awk -F '/' '{print $NF}')
+ lsmod |grep "${module_name}"
+ if [ $? != "${module_name}" ]; then
+ echo "${module_name}" | tee -a /tmp/kunit_module_names_not_loaded.txt
+ fi
+done < "/tmp/kunit_modules.txt"
+if [ -f /tmp/kunit_module_names_not_loaded.txt ]
then
- echo KUNIT_TEST_MODULE="${KUNIT_TEST_MODULE}"
- ln -s "$(find "/lib/modules/$(uname -r)" -name "${KUNIT_TEST_MODULE}*")" \
- "/lib/modules/$(uname -r)"
+ while read -r module; do
+ module_name=$(echo "${module}"|awk -F '/' '{print $NF}')
+ echo KUNIT_TEST_MODULE="${module_name}"
+ ln -s "${module}" \
+ "/lib/modules/$(uname -r)/${module_name}"
+ done < "/tmp/kunit_modules.txt"
depmod -a
- modprobe "${KUNIT_TEST_MODULE%.*}"
- exit_on_fail "modprobe-${KUNIT_TEST_MODULE%.*}"
- lsmod
+ while read -r module_name; do
+ modprobe "${module_name}"
+ exit_on_fail "modprobe-${module_name}"
+ lsmod
+ done < "/tmp/kunit_module_names_not_loaded.txt"
+fi
+if [ -f /proc/config.gz ]
+then
+ CONFIG_KUNIT_TEST=$(zcat /proc/config.gz | grep "CONFIG_KUNIT_TEST=")
+elif [ -f /boot/config-"$(uname -r)" ]
+then
+ KERNEL_CONFIG_FILE="/boot/config-$(uname -r)"
+ CONFIG_KUNIT_TEST=$(grep "CONFIG_KUNIT_TEST=" "${KERNEL_CONFIG_FILE}")
else
- if [ -f /proc/config.gz ]
- then
- CONFIG_KUNIT_TEST=$(zcat /proc/config.gz | grep "CONFIG_KUNIT_TEST=")
- elif [ -f /boot/config-"$(uname -r)" ]
- then
- KERNEL_CONFIG_FILE="/boot/config-$(uname -r)"
- CONFIG_KUNIT_TEST=$(grep "CONFIG_KUNIT_TEST=" "${KERNEL_CONFIG_FILE}")
- else
- exit_on_skip "kunit-pre-requirements" "Kernel config file not available"
- fi
- if [ "${CONFIG_KUNIT_TEST}" = "CONFIG_KUNIT_TEST=y" ]
- then
- exit_on_skip "kunit-pre-requirements" "Kernel config CONFIG_KUNIT_TEST=y not enabled"
- fi
+ exit_on_skip "kunit-pre-requirements" "Kernel config file not available"
+fi
+if [ "${CONFIG_KUNIT_TEST}" = "CONFIG_KUNIT_TEST=y" ]
+then
+ exit_on_skip "kunit-pre-requirements" "Kernel config CONFIG_KUNIT_TEST=y not enabled"
fi
run "${TEST_CMD}"
diff --git a/automated/linux/kunit/kunit.yaml b/automated/linux/kunit/kunit.yaml
index 11e08d84..75feac01 100644
--- a/automated/linux/kunit/kunit.yaml
+++ b/automated/linux/kunit/kunit.yaml
@@ -22,8 +22,9 @@ metadata:
- x86
params:
- # Example: kunit-test.ko
- KUNIT_TEST_MODULE: ""
+ # This will try to find all modules that ends with '*test.ko'
+ # Example: test.ko
+ KUNIT_TEST_MODULE: "test.ko"
run:
steps: