Skip to content

Commit f06bfe4

Browse files
committed
1 parent 2b6d554 commit f06bfe4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

computer_hw/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
<exec_depend>diagnostic_aggregator</exec_depend>
2222
<exec_depend>libsensors_monitor</exec_depend>
2323
<exec_depend>rospy</exec_depend>
24+
<test_depend>roslib</test_depend>
2425

2526
</package>

computer_hw/test/parse_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
import sys
4343
import unittest
4444

45+
import roslib
46+
4547
import computer_hw
48+
from computer_hw.nvidia_temperature_monitor.py import NVidiaTempMonitor, parse_smi_output
4649

4750
TEXT_PATH = 'test/sample_output/nvidia_smi_out_2021.txt'
4851
TEXT_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

Comments
 (0)