aboutgitcode
path: root/mbuto
diff options
context:
space:
mode:
authorSevinj Aghayeva <sevinj.aghayeva@gmail.com>2022-04-17 13:27:21 -0400
committerStefano Brivio <sbrivio@redhat.com>2022-04-21 16:40:29 +0200
commitcd7f0e77340f869cb65aa756f9f6f888a3e4d084 (patch)
tree5d5fb1f8718d2348cde93ecd933f8e5ed03bf09b /mbuto
parent4447d4b29682a5aa4b09c47de9a1659b0f167d3b (diff)
downloadmbuto-cd7f0e77340f869cb65aa756f9f6f888a3e4d084.tar
mbuto-cd7f0e77340f869cb65aa756f9f6f888a3e4d084.tar.gz
mbuto-cd7f0e77340f869cb65aa756f9f6f888a3e4d084.tar.bz2
mbuto-cd7f0e77340f869cb65aa756f9f6f888a3e4d084.tar.lz
mbuto-cd7f0e77340f869cb65aa756f9f6f888a3e4d084.tar.xz
mbuto-cd7f0e77340f869cb65aa756f9f6f888a3e4d084.tar.zst
mbuto-cd7f0e77340f869cb65aa756f9f6f888a3e4d084.zip
mbuto: enable passing multiple collections and tests to suboptions
The run_kselftest.sh script, which is run upon booting the image created by mbuto, allows specifying multiple collections and specific tests, as in: run_kselftest.sh -c "net proc" -t "x86:iopl_32 timers:rtcpie" The above command runs (1) all the tests in the net collection, (2) all the tests in the proc collection, (3) the iopl_32 test from the x86 collection, and (4) the rtcpie test from the timers collection. This patch enables the same functionality in mbuto. Now users can run mbuto as follows: mbuto -p kselftests -C "net proc" -T "x86:iopl_32 timers:rtcpie" and mbuto generates an image that runs the same set of tests. In addition, mbuto installs only the tests in the specified collections in the image. For example, for the above command line, mbuto will install all the tests in the net, proc, x86, and timers collections (but it will only run iopl_32 and rtcpie test from the last two). Mbuto also installs only the modules needed for running these tests and warns the user if there are missing modules. Mbuto also warns the user if an invalid collection name is passed to the -C suboption. Due to irregular structure of Makefiles in selftest directories, it is hard to warn the user if an invalid test name is passed to the -T option. In this case the user will find out about the mistake after the kernel boots and run_kselftest.sh fails to run the test. Signed-off-by: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
Diffstat (limited to 'mbuto')
-rwxr-xr-xmbuto47
1 files changed, 32 insertions, 15 deletions
diff --git a/mbuto b/mbuto
index f9ee6c5..49b8139 100755
--- a/mbuto
+++ b/mbuto
@@ -203,14 +203,31 @@ profile_kselftests() {
exit 1
fi
- KERNEL="$(cat include/config/kernel.release)"
+ KERNEL="$(${CAT} include/config/kernel.release)"
+
+ __testpath="./tools/testing/selftests/"
+ __makefile="${__testpath}Makefile"
+ __colls=
+ for __c in ${SUBOPT_collection}; do
+ if ! ${GREP} -q "^TARGETS += ${__c}$" ${__makefile}; then
+ notice "WARNING: collection ${__c} doesn't exist"
+ continue
+ fi
+ __colls="${__c} ${__colls}"
+ done
+
+ for __t in ${SUBOPT_test}; do
+ __colls="${__colls} $(echo ${__t} | ${AWK} -F':' '{print $1}')"
+ done
+ __colls="$(echo ${__colls} | ${TR} ' ' '\n' | ${SORT} -u)"
+
+ __pattern=$(list_join "${__colls}" '^' '$' '|')
- __skip_targets=$(${AWK} '/^TARGETS/ { print $3}' \
- tools/testing/selftests/Makefile | \
- ${GREP} -v "^${SUBOPT_collection}$" | ${TR} '\n' ' ')
+ __skip_targets=$(${AWK} '/^TARGETS/ { print $3}' ${__makefile} | \
+ ${EGREP} -v "${__pattern}" | ${TR} '\n' ' ')
- ${MAKE} SKIP_TARGETS="${__skip_targets}" -C \
- tools/testing/selftests/ install >/dev/null 2>&1
+ ${MAKE} SKIP_TARGETS="${__skip_targets}" -C ${__testpath} install \
+ >/dev/null 2>&1
MODDIR="$(${REALPATH} .mbuto_mods)"
${RM} -rf "${MODDIR}"
@@ -218,10 +235,12 @@ profile_kselftests() {
INSTALL_MOD_PATH="${MODDIR}" ${MAKE} modules_install -j ${THREADS} \
>/dev/null
- __cfg="./tools/testing/selftests/${SUBOPT_collection}/config"
+ __files=$(list_join "${__colls}" "${__testpath}" '/config' ' ')
+ __cfgs="$(${CAT} ${__files} 2>/dev/null)"
+
KMODS=
- if [ -f ${__cfg} ]; then
- __mods=$(${AWK} -F'=' '/=m/ {print $1}' ${__cfg} | ${SORT} -u)
+ if [ ! -z "${__cfgs}" ]; then
+ __mods=$(echo "${__cfgs}" | ${AWK} -F'=' '/=m/ {print $1}' | ${SORT} -u)
__pattern=$(list_join "${__mods}" '^obj-\$\(' '\).*.o$' '|')
__result=$(${BASENAME} -a -s .o \
@@ -253,12 +272,11 @@ profile_kselftests() {
DIRS="${DIRS} /tmp /run/netns /var/run"
- COPIES="${COPIES}
- tools/testing/selftests/kselftest_install/*,"
+ COPIES="${COPIES} ${__testpath}kselftest_install/*,"
__run_args=
- [ ! -z ${SUBOPT_collection} ] && __run_args="-c ${SUBOPT_collection}"
- [ ! -z ${SUBOPT_test} ] && __run_args="${__run_args} -t ${SUBOPT_test}"
+ [ ! -z "${SUBOPT_collection}" ] && __run_args="-c ${SUBOPT_collection}"
+ [ ! -z "${SUBOPT_test}" ] && __run_args="${__run_args} -t ${SUBOPT_test}"
FIXUP='#!/bin/sh
@@ -289,8 +307,7 @@ profile_kselftests() {
[ "${a}" != "s" ] && ./run_kselftest.sh '"${__run_args}"'
'
- for __f in $(${FIND} tools/testing/selftests/kselftest_install/ \
- -executable); do
+ for __f in $(${FIND} ${__testpath}kselftest_install/ -executable); do
case $("${FILE}" -bi "${__f}") in
"application/"*) libs_copy "${__f}" ;;
esac