Skip to content

Commit 1244f1f

Browse files
committed
hwmon test t8015
1 parent e6d8aa1 commit 1244f1f

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
. /usr/lib/hoolocktest/test_functions.sh
6+
7+
# only t8015's smc supported reporting temperatures
8+
HWMON_PATH="/sys/devices/platform/soc/236000100.smc/macsmc-hwmon/hwmon/hwmon2";
9+
10+
# hopefully the temperature is between -40°C and +120°C
11+
# temperatures are reported in 100th of kelvins
12+
13+
TEMP_MIN="-40000"
14+
TEMP_MAX="120000"
15+
16+
require_dir_exists "$HWMON_PATH"
17+
18+
check_temp_sensor() {
19+
require_file_exists "$HWMON_PATH"/temp"$1"_label
20+
require_file_exists "$HWMON_PATH"/temp"$1"_input
21+
22+
act_lbl="$(cat "$HWMON_PATH"/temp"$1"_label)"
23+
temp="$(cat "$HWMON_PATH"/temp"$1"_input)"
24+
25+
if [ "$act_lbl" != "$2" ]; then
26+
printf "Error: Expected label $2 got $act_lbl"
27+
exit 1;
28+
fi
29+
30+
if [ "$(expr "$temp" "<" "$TEMP_MIN")" = "1" ]; then
31+
printf "Error: $act_lbl Temperature too low: %s °C\n" $(expr "$temp" '/' '100' )
32+
exit 1;
33+
fi
34+
35+
if [ "$(expr "$temp" ">" "$TEMP_MAX")" = "1" ]; then
36+
printf "Error: $act_lbl Temperature too high: %s °C\n" $(expr "$temp" '/' '100' )
37+
exit 1;
38+
fi
39+
}
40+
41+
check_temp_sensor "1" "Battery Temp"
42+
check_temp_sensor "2" "Battery Flex Temp"
43+
check_temp_sensor "3" "Forehead Temp"
44+
check_temp_sensor "4" "Rear Camera Temp"
45+
check_temp_sensor "5" "Cellular Radio Temp"
46+
check_temp_sensor "6" "CPU Temp"
47+
check_temp_sensor "7" "Charger Temp"

hoolocktest/src/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ int main(void)
9696
if (ret)
9797
bail("battery test failed\n");
9898
printf("battery test OK\n");
99+
100+
ret = runCommand((const char*[]){HLT_PATH("test_smc_sensors"), NULL});
101+
if (ret)
102+
bail("HWMON test failed\n");
103+
printf("HWMON test OK\n");
99104
}
100105

101106
printf("HoolockLinux Test -- SUCCESS\n");

0 commit comments

Comments
 (0)