Skip to content

Commit

Permalink
chrt: (tests) Add new cases for custom slice on SCHED_{OTHER,BATCH}
Browse files Browse the repository at this point in the history
Adds two new test cases setting --sched-runtime for SCHED_{OTHER,BATCH}.

The new custom slice tests are skipped for kernel versions < 6.12,
which do not have the feature. The existing chrt tests for
SCHED_{OTHER,BATCH} are skipped for kernel versions >= 6.12.

This is for two reasons:
 - the default sched_runtime value depends on target platform
 - without custom slice support, the value of sched_runtime is
   always zero for SCHED_{OTHER,BATCH}

Expected output with kernel version < 6.12:
   schedutils: chrt                           ...
                : batch                       ... OK
                : batch-custom-slice          ... SKIPPED
                : other                       ... OK
                : other-custom-slice          ... SKIPPED
		: deadline                    ... OK

Expected output with kernel version >= 6.12:
   schedutils: chrt                           ...
                : batch                       ... SKIPPED
                : batch-custom-slice          ... OK
                : other                       ... SKIPPED
                : other-custom-slice          ... OK
		: deadline                    ... OK

Signed-off-by: Petre Tudor <petre-ionut.tudor@arm.com>
  • Loading branch information
petretudor-arm committed Feb 12, 2025
1 parent 22ff43f commit 96f3bac
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
3 changes: 3 additions & 0 deletions tests/expected/schedutils/chrt-batch-custom-slice
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SCHED_BATCH
0
<removed>'s current runtime parameter: 100000
3 changes: 3 additions & 0 deletions tests/expected/schedutils/chrt-other-custom-slice
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SCHED_OTHER
0
<removed>'s current runtime parameter: 100000
28 changes: 27 additions & 1 deletion tests/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,13 @@ function ts_init_env {
CHARSET="UTF-8"
ASAN_OPTIONS="detect_leaks=0"
UBSAN_OPTIONS="print_stacktrace=1:print_summary=1:halt_on_error=1"
KERNEL_VERSION_XYZ=$(uname -r | awk -F- '{print $1}')
KERNEL_VERSION_MAJOR=$(echo "$KERNEL_VERSION_XYZ" | awk -F. '{print $1}')
KERNEL_VERSION_MINOR=$(echo "$KERNEL_VERSION_XYZ" | awk -F. '{print $2}')
KERNEL_RELEASE=$(echo "$KERNEL_VERSION_XYZ" | awk -F. '{print $3}')

export LANG LANGUAGE LC_ALL CHARSET ASAN_OPTIONS UBSAN_OPTIONS
export LANG LANGUAGE LC_ALL CHARSET ASAN_OPTIONS UBSAN_OPTIONS \
KERNEL_VERSION_XYZ KERNEL_VERSION_MAJOR KERNEL_VERSION_MINOR KERNEL_RELEASE

mydir=$(ts_canonicalize "$mydir")

Expand Down Expand Up @@ -641,6 +646,27 @@ function ts_skip_subtest {

}

# Specify the kernel version X.Y.Z you wish to compare against like:
#
# ts_kernel_ver_lt X Y Z
#
function ts_kernel_ver_lt {
if [ $KERNEL_VERSION_MAJOR -lt $1 ]; then
return 0
elif [ $KERNEL_VERSION_MAJOR -eq $1 ]; then
if [ $KERNEL_VERSION_MINOR -lt $2 ]; then
return 0
elif [ $KERNEL_VERSION_MINOR -eq $2 ]; then
if [ $KERNEL_RELEASE -lt $3 ]; then
return 0
fi
fi

fi

return 1
}

function ts_finalize {
ts_cleanup_on_exit

Expand Down
42 changes: 40 additions & 2 deletions tests/ts/schedutils/chrt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ function skip_policy {
return 0
}

function skip_kernel_lt {
ts_kernel_ver_lt $1 $2 $3
if [ $? == 0 ]; then
ts_skip_subtest "kernel version must be >= $1.$2.$3"
return 1
fi

return 0
}

function skip_kernel_ge {
ts_kernel_ver_lt $1 $2 $3
if [ $? == 1 ]; then
ts_skip_subtest "kernel version must be < $1.$2.$3"
return 1
fi

return 0
}

function cleanup_output {
sed -i -e 's/pid [0-9]*/<removed>/' $TS_OUTPUT
}
Expand All @@ -53,23 +73,41 @@ fi


ts_init_subtest "batch"
skip_policy SCHED_BATCH
skip_policy SCHED_BATCH && skip_kernel_ge 6 12 0
if [ $? == 0 ]; then
do_chrt --batch 0
cleanup_output
ts_finalize_subtest
fi


ts_init_subtest "batch-custom-slice"
skip_policy SCHED_BATCH && skip_kernel_lt 6 12 0
if [ $? == 0 ]; then
do_chrt --batch --sched-runtime 100000 0
cleanup_output
ts_finalize_subtest
fi


ts_init_subtest "other"
skip_policy SCHED_OTHER
skip_policy SCHED_OTHER && skip_kernel_ge 6 12 0
if [ $? == 0 ]; then
do_chrt --other 0
cleanup_output
ts_finalize_subtest
fi


ts_init_subtest "other-custom-slice"
skip_policy SCHED_OTHER && skip_kernel_lt 6 12 0
if [ $? == 0 ]; then
do_chrt --other --sched-runtime 100000 0
cleanup_output
ts_finalize_subtest
fi


ts_init_subtest "rr"
skip_policy SCHED_RR
if [ $? == 0 ]; then
Expand Down

0 comments on commit 96f3bac

Please sign in to comment.