Commit c7e84706 authored by Muhammad Usama Anjum's avatar Muhammad Usama Anjum Committed by Shuah Khan

selftests: cpufreq: conform test to TAP

This test outputs lots of information. Let's conform the core part of
the test to TAP and leave the information printing messages for now.
Include ktap_helpers.sh to print conformed logs. Use KSFT_* macros to
return the correct exit code for the kselftest framework and CIs to
understand the exit status.
Signed-off-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 557f1375
...@@ -178,8 +178,7 @@ cpufreq_basic_tests() ...@@ -178,8 +178,7 @@ cpufreq_basic_tests()
count=$(count_cpufreq_managed_cpus) count=$(count_cpufreq_managed_cpus)
if [ $count = 0 ]; then if [ $count = 0 ]; then
printf "No cpu is managed by cpufreq core, exiting\n" ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting\n"
exit;
else else
printf "CPUFreq manages: $count CPUs\n\n" printf "CPUFreq manages: $count CPUs\n\n"
fi fi
......
...@@ -7,15 +7,15 @@ source governor.sh ...@@ -7,15 +7,15 @@ source governor.sh
source module.sh source module.sh
source special-tests.sh source special-tests.sh
DIR="$(dirname $(readlink -f "$0"))"
source "${DIR}"/../kselftest/ktap_helpers.sh
FUNC=basic # do basic tests by default FUNC=basic # do basic tests by default
OUTFILE=cpufreq_selftest OUTFILE=cpufreq_selftest
SYSFS= SYSFS=
CPUROOT= CPUROOT=
CPUFREQROOT= CPUFREQROOT=
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
helpme() helpme()
{ {
printf "Usage: $0 [-h] [-todg args] printf "Usage: $0 [-h] [-todg args]
...@@ -32,7 +32,7 @@ helpme() ...@@ -32,7 +32,7 @@ helpme()
[-d <driver's module name: only with \"-t modtest>\"] [-d <driver's module name: only with \"-t modtest>\"]
[-g <governor's module name: only with \"-t modtest>\"] [-g <governor's module name: only with \"-t modtest>\"]
\n" \n"
exit 2 exit "${KSFT_FAIL}"
} }
prerequisite() prerequisite()
...@@ -40,8 +40,8 @@ prerequisite() ...@@ -40,8 +40,8 @@ prerequisite()
msg="skip all tests:" msg="skip all tests:"
if [ $UID != 0 ]; then if [ $UID != 0 ]; then
echo $msg must be run as root >&2 ktap_skip_all "$msg must be run as root"
exit $ksft_skip exit "${KSFT_SKIP}"
fi fi
taskset -p 01 $$ taskset -p 01 $$
...@@ -49,21 +49,21 @@ prerequisite() ...@@ -49,21 +49,21 @@ prerequisite()
SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
if [ ! -d "$SYSFS" ]; then if [ ! -d "$SYSFS" ]; then
echo $msg sysfs is not mounted >&2 ktap_skip_all "$msg sysfs is not mounted"
exit 2 exit "${KSFT_SKIP}"
fi fi
CPUROOT=$SYSFS/devices/system/cpu CPUROOT=$SYSFS/devices/system/cpu
CPUFREQROOT="$CPUROOT/cpufreq" CPUFREQROOT="$CPUROOT/cpufreq"
if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then
echo $msg cpus not available in sysfs >&2 ktap_skip_all "$msg cpus not available in sysfs"
exit 2 exit "${KSFT_SKIP}"
fi fi
if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then
echo $msg cpufreq directory not available in sysfs >&2 ktap_skip_all "$msg cpufreq directory not available in sysfs"
exit 2 exit "${KSFT_SKIP}"
fi fi
} }
...@@ -105,8 +105,7 @@ do_test() ...@@ -105,8 +105,7 @@ do_test()
count=$(count_cpufreq_managed_cpus) count=$(count_cpufreq_managed_cpus)
if [ $count = 0 -a $FUNC != "modtest" ]; then if [ $count = 0 -a $FUNC != "modtest" ]; then
echo "No cpu is managed by cpufreq core, exiting" ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
exit 2;
fi fi
case "$FUNC" in case "$FUNC" in
...@@ -125,8 +124,7 @@ do_test() ...@@ -125,8 +124,7 @@ do_test()
"modtest") "modtest")
# Do we have modules in place? # Do we have modules in place?
if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then
echo "No driver or governor module passed with -d or -g" ktap_exit_fail_msg "No driver or governor module passed with -d or -g"
exit 2;
fi fi
if [ $DRIVER_MOD ]; then if [ $DRIVER_MOD ]; then
...@@ -137,8 +135,7 @@ do_test() ...@@ -137,8 +135,7 @@ do_test()
fi fi
else else
if [ $count = 0 ]; then if [ $count = 0 ]; then
echo "No cpu is managed by cpufreq core, exiting" ktap_exit_fail_msg "No cpu is managed by cpufreq core, exiting"
exit 2;
fi fi
module_governor_test $GOVERNOR_MOD module_governor_test $GOVERNOR_MOD
...@@ -162,7 +159,7 @@ do_test() ...@@ -162,7 +159,7 @@ do_test()
;; ;;
*) *)
echo "Invalid [-f] function type" ktap_print_msg "Invalid [-f] function type"
helpme helpme
;; ;;
esac esac
...@@ -186,13 +183,25 @@ dmesg_dumps() ...@@ -186,13 +183,25 @@ dmesg_dumps()
dmesg >> $1.dmesg_full.txt dmesg >> $1.dmesg_full.txt
} }
ktap_print_header
# Parse arguments # Parse arguments
parse_arguments $@ parse_arguments $@
ktap_set_plan 1
# Make sure all requirements are met # Make sure all requirements are met
prerequisite prerequisite
# Run requested functions # Run requested functions
clear_dumps $OUTFILE clear_dumps $OUTFILE
do_test | tee -a $OUTFILE.txt do_test | tee -a $OUTFILE.txt
if [ "${PIPESTATUS[0]}" -ne 0 ]; then
exit ${PIPESTATUS[0]};
fi
dmesg_dumps $OUTFILE dmesg_dumps $OUTFILE
ktap_test_pass "Completed successfully"
ktap_print_totals
exit "${KSFT_PASS}"
...@@ -24,16 +24,14 @@ test_basic_insmod_rmmod() ...@@ -24,16 +24,14 @@ test_basic_insmod_rmmod()
# insert module # insert module
insmod $1 insmod $1
if [ $? != 0 ]; then if [ $? != 0 ]; then
printf "Insmod $1 failed\n" ktap_exit_fail_msg "Insmod $1 failed\n"
exit;
fi fi
printf "Removing $1 module\n" printf "Removing $1 module\n"
# remove module # remove module
rmmod $1 rmmod $1
if [ $? != 0 ]; then if [ $? != 0 ]; then
printf "rmmod $1 failed\n" ktap_exit_fail_msg "rmmod $1 failed\n"
exit;
fi fi
printf "\n" printf "\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment