]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
chrt: (tests) Add new cases for custom slice on SCHED_{OTHER,BATCH}
authorPetre Tudor <petre-ionut.tudor@arm.com>
Wed, 29 Jan 2025 17:05:18 +0000 (17:05 +0000)
committerPetre Tudor <petre-ionut.tudor@arm.com>
Wed, 12 Feb 2025 15:56:56 +0000 (15:56 +0000)
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>
tests/expected/schedutils/chrt-batch-custom-slice [new file with mode: 0644]
tests/expected/schedutils/chrt-other-custom-slice [new file with mode: 0644]
tests/functions.sh
tests/ts/schedutils/chrt

diff --git a/tests/expected/schedutils/chrt-batch-custom-slice b/tests/expected/schedutils/chrt-batch-custom-slice
new file mode 100644 (file)
index 0000000..ea788bf
--- /dev/null
@@ -0,0 +1,3 @@
+SCHED_BATCH
+0
+<removed>'s current runtime parameter: 100000
diff --git a/tests/expected/schedutils/chrt-other-custom-slice b/tests/expected/schedutils/chrt-other-custom-slice
new file mode 100644 (file)
index 0000000..df1db19
--- /dev/null
@@ -0,0 +1,3 @@
+SCHED_OTHER
+0
+<removed>'s current runtime parameter: 100000
index d5a92c91c80e7804101cfcd66dac9c2b52b83cff..1d7a425f692286aad5492621d22ab8b3acaea925 100644 (file)
@@ -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")
 
@@ -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
 
index fd5f7af781f20fd0f4faf5e6c7c0136d35908c2c..74186c05347faaec38f0ae8a5b50a326d1f322f0 100755 (executable)
@@ -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
 }
@@ -53,7 +73,7 @@ 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
@@ -61,8 +81,17 @@ if [ $? == 0 ]; then
 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
@@ -70,6 +99,15 @@ if [ $? == 0 ]; then
 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