42
42
import sys
43
43
import unittest
44
44
45
+ import roslib
46
+
45
47
import computer_hw
48
+ from computer_hw .nvidia_temperature_monitor .py import NVidiaTempMonitor , parse_smi_output
46
49
47
50
TEXT_PATH = 'test/sample_output/nvidia_smi_out_2021.txt'
48
51
TEXT_HIGH_TEMP_PATH = 'test/sample_output/nvidia_smi_high_temp.txt'
@@ -73,12 +76,12 @@ def test_parse(self):
73
76
self .assert_ (gpu_stat .temperature > 40 and gpu_stat .temperature < 90 , "Invalid temperature readings. Temperature: %d" % gpu_stat .temperature )
74
77
self .assert_ (gpu_stat .fan_speed > 0 and gpu_stat .fan_speed < 471 , "Invalid fan speed readings. Fan Speed %f" % gpu_stat .fan_speed )
75
78
76
- diag_stat = computer_hw .gpu_status_to_diag (gpu_stat )
79
+ diag_stat = NVidiaTempMonitor .gpu_status_to_diag (gpu_stat )
77
80
78
81
self .assert_ (diag_stat .level == 0 , "Diagnostics reports an error for nominal input. Message: %s" % diag_stat .message )
79
82
80
83
def test_high_temp_parse (self ):
81
- gpu_stat = computer_hw . parse_smi_output (self .high_temp_data )
84
+ gpu_stat = parse_smi_output (self .high_temp_data )
82
85
83
86
# Check valid
84
87
self .assert_ (self .high_temp_data , "Unable to read sample output, no test to run" )
@@ -93,17 +96,17 @@ def test_high_temp_parse(self):
93
96
self .assert_ (gpu_stat .temperature > 90 , "Invalid temperature readings. Temperature: %d" % gpu_stat .temperature )
94
97
self .assert_ (gpu_stat .fan_speed > 0 and gpu_stat .fan_speed < 471 , "Invalid fan speed readings. Fan Speed %s" % gpu_stat .fan_speed )
95
98
96
- diag_stat = computer_hw .gpu_status_to_diag (gpu_stat )
99
+ diag_stat = NVidiaTempMonitor .gpu_status_to_diag (gpu_stat )
97
100
98
101
self .assert_ (diag_stat .level == 1 , "Diagnostics didn't report warning for high temp input. Level %d, Message: %s" % (diag_stat .level , diag_stat .message ))
99
102
100
103
101
104
def test_empty_parse (self ):
102
- gpu_stat = computer_hw . parse_smi_output ('' )
105
+ gpu_stat = parse_smi_output ('' )
103
106
104
107
self .assert_ (gpu_stat .temperature == 0 , "Invalid temperature reading. Should be 0. Reading: %d" % gpu_stat .temperature )
105
108
106
- diag_stat = computer_hw .gpu_status_to_diag (gpu_stat )
109
+ diag_stat = NVidiaTempMonitor .gpu_status_to_diag (gpu_stat )
107
110
108
111
self .assert_ (diag_stat .level == 2 , "Diagnostics didn't reports an error for empty input. Level: %d, Message: %s" % (diag_stat .level , diag_stat .message ))
109
112
0 commit comments