4242import sys
4343import unittest
4444
45+ import roslib
46+
4547import computer_hw
48+ from computer_hw .nvidia_temperature_monitor .py import NVidiaTempMonitor , parse_smi_output
4649
4750TEXT_PATH = 'test/sample_output/nvidia_smi_out_2021.txt'
4851TEXT_HIGH_TEMP_PATH = 'test/sample_output/nvidia_smi_high_temp.txt'
@@ -73,12 +76,12 @@ def test_parse(self):
7376 self .assert_ (gpu_stat .temperature > 40 and gpu_stat .temperature < 90 , "Invalid temperature readings. Temperature: %d" % gpu_stat .temperature )
7477 self .assert_ (gpu_stat .fan_speed > 0 and gpu_stat .fan_speed < 471 , "Invalid fan speed readings. Fan Speed %f" % gpu_stat .fan_speed )
7578
76- diag_stat = computer_hw .gpu_status_to_diag (gpu_stat )
79+ diag_stat = NVidiaTempMonitor .gpu_status_to_diag (gpu_stat )
7780
7881 self .assert_ (diag_stat .level == 0 , "Diagnostics reports an error for nominal input. Message: %s" % diag_stat .message )
7982
8083 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 )
8285
8386 # Check valid
8487 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):
9396 self .assert_ (gpu_stat .temperature > 90 , "Invalid temperature readings. Temperature: %d" % gpu_stat .temperature )
9497 self .assert_ (gpu_stat .fan_speed > 0 and gpu_stat .fan_speed < 471 , "Invalid fan speed readings. Fan Speed %s" % gpu_stat .fan_speed )
9598
96- diag_stat = computer_hw .gpu_status_to_diag (gpu_stat )
99+ diag_stat = NVidiaTempMonitor .gpu_status_to_diag (gpu_stat )
97100
98101 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 ))
99102
100103
101104 def test_empty_parse (self ):
102- gpu_stat = computer_hw . parse_smi_output ('' )
105+ gpu_stat = parse_smi_output ('' )
103106
104107 self .assert_ (gpu_stat .temperature == 0 , "Invalid temperature reading. Should be 0. Reading: %d" % gpu_stat .temperature )
105108
106- diag_stat = computer_hw .gpu_status_to_diag (gpu_stat )
109+ diag_stat = NVidiaTempMonitor .gpu_status_to_diag (gpu_stat )
107110
108111 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 ))
109112
0 commit comments