]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (chcpu) test partial success chcpu code
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 25 Jun 2026 00:29:08 +0000 (20:29 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 25 Jun 2026 00:29:33 +0000 (20:29 -0400)
tests/expected/chcpu/options-aarch64_Apple_Icestorm-M1-Pro
tests/expected/chcpu/options-x86_64-i7-11th-2_8GHz
tests/ts/chcpu/options

index 434a7417b5e5875214d2c3b5d2129b986a608f2e..e05ed98578de432c2f06d6705004ebc3a821d9ff 100644 (file)
@@ -8,3 +8,4 @@
 ---disable last enabled CPU---
 CPU 0 disabled
 0
+exit code: 64
index 28a14c3665851cd44b6c8d32d796dfa3ca219124..a3bfe8ce071f2fe5d82f9389f6b2d634859bd935 100644 (file)
@@ -49,3 +49,4 @@ CPU 6 disabled
 0
 0
 1
+exit code: 64
index 7d0ecadad18676f1f57c023c40bce1333f9da3ef..2493553a44c4fce057701a39b372c8c5ac5039fe 100755 (executable)
@@ -31,10 +31,13 @@ _PATH_SYS_CPU="/sys/devices/system/cpu"
 DUMP_DIR="$TS_OUTDIR/dumps"
 mkdir -p "$DUMP_DIR"
 
+CHCPU_EXITCODE=0
+
 do_chcpu() {
     local sysroot=$1
     shift 1
     "$TS_CMD_CHCPU" --sysroot "${sysroot}" "${@}" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
+    CHCPU_EXITCODE="$?"
 }
 
 print_cpus_sys_interface() {
@@ -45,7 +48,7 @@ print_cpus_sys_interface() {
     start=$3
     end=$4
 
-    for ((i=start; i <=end; i++ )); do
+    for ((i=start; i <=end; i++)); do
         p="${sysroot}/${_PATH_SYS_CPU}/cpu${i}/${iface_name}"
         [ ! -f "$p" ] && continue
         cat "$p" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG"
@@ -56,6 +59,10 @@ print_ts_section_title() {
     echo "---${1}---" | tee -a "$TS_OUTPUT" "$TS_ERRLOG" >/dev/null
 }
 
+print_chcpu_exit_code() {
+    echo "exit code: $CHCPU_EXITCODE" >>"$TS_OUTPUT"
+}
+
 for dump_name in $(find "$TS_SELF"/dumps/ -type f -maxdepth 1 -name "*.tar.bz2" | sort); do
     subts_name=$(basename "$dump_name" .tar.bz2)
     ts_init_subtest "${subts_name}"
@@ -106,6 +113,9 @@ for dump_name in $(find "$TS_SELF"/dumps/ -type f -maxdepth 1 -name "*.tar.bz2"
     do_chcpu "${sysroot}" --disable 0-"$cpu_end"
     print_cpus_sys_interface "${sysroot}" "online" 0 "$cpu_end"
     rm -f "${sysroot}/${_PATH_SYS_CPU}"/cpu0/online
+    # Let's also check the exit code of chcpu, since not all CPUs could be
+    # configured a partial success exit code of 64 should be used.
+    print_chcpu_exit_code
 
     # Expected fails
     # Don't use print_ts_section_title() here