From: Christian Goeschel Ndjomouo Date: Thu, 25 Jun 2026 00:29:08 +0000 (-0400) Subject: tests: (chcpu) test partial success chcpu code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e6d1d6f9f03a7af4ded52b98c278130aacdfad9;p=thirdparty%2Futil-linux.git tests: (chcpu) test partial success chcpu code --- diff --git a/tests/expected/chcpu/options-aarch64_Apple_Icestorm-M1-Pro b/tests/expected/chcpu/options-aarch64_Apple_Icestorm-M1-Pro index 434a7417b..e05ed9857 100644 --- a/tests/expected/chcpu/options-aarch64_Apple_Icestorm-M1-Pro +++ b/tests/expected/chcpu/options-aarch64_Apple_Icestorm-M1-Pro @@ -8,3 +8,4 @@ ---disable last enabled CPU--- CPU 0 disabled 0 +exit code: 64 diff --git a/tests/expected/chcpu/options-x86_64-i7-11th-2_8GHz b/tests/expected/chcpu/options-x86_64-i7-11th-2_8GHz index 28a14c366..a3bfe8ce0 100644 --- a/tests/expected/chcpu/options-x86_64-i7-11th-2_8GHz +++ b/tests/expected/chcpu/options-x86_64-i7-11th-2_8GHz @@ -49,3 +49,4 @@ CPU 6 disabled 0 0 1 +exit code: 64 diff --git a/tests/ts/chcpu/options b/tests/ts/chcpu/options index 7d0ecadad..2493553a4 100755 --- a/tests/ts/chcpu/options +++ b/tests/ts/chcpu/options @@ -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