Skip to content

Commit b4cc8ec

Browse files
committed
test-cpu/gpufreq: fix tlp detection
Rationale: /usr/sbin/ may not be included in PATH, as in Debian.
1 parent b76a10c commit b4cc8ec

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

unit-tests/test-cpufreq.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,10 +1066,7 @@ check_platform_profile () {
10661066
}
10671067

10681068
# check prerequisites and initialize
1069-
cmd_exists "$TLP" || {
1070-
printf_msg "Error: %s not installed." "$TLP"
1071-
exit 254
1072-
}
1069+
check_tlp
10731070
_cpu_driver=$(read_sysf "${CPU0}/cpufreq/scaling_driver") || {
10741071
printf_msg "Error: could not determine cpu scaling driver."
10751072
exit 128

unit-tests/test-func

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ cache_root_cred () {
3434
sudo true
3535
}
3636

37-
cmd_exists () {
38-
# test if command exists -- $1: command
39-
command -v "$1" > /dev/null 2>&1
37+
check_tlp () {
38+
# test if tlp installed
39+
if [ ! -f /usr/sbin/tlp ]; then
40+
printf_msg "Error: %s not installed." "$TLP" 1>&2
41+
exit 254
42+
fi
4043
}
4144

4245
read_sysf () {

unit-tests/test-gpufreq.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,7 @@ check_amd_gpu_abm_level () {
401401
}
402402

403403
# check prerequisites and initialize
404-
cmd_exists "$TLP" || {
405-
printf_msg "Error: %s not installed." "$TLP"
406-
exit 254
407-
}
408-
cache_root_cred
409-
404+
check_tlp
410405
start_report
411406

412407
# shellcheck disable=SC2034

0 commit comments

Comments
 (0)