James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #include <HwmonTempSensor.hpp> |
| 2 | #include <dbus/connection.hpp> |
James Feist | 582be09 | 2018-11-27 10:54:59 -0800 | [diff] [blame] | 3 | #include <nlohmann/json.hpp> |
| 4 | |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 5 | #include <fstream> |
| 6 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 7 | #include <gtest/gtest.h> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 8 | |
| 9 | TEST(HwmonTempSensor, TestTMP75) |
| 10 | { |
| 11 | boost::asio::io_service io; |
| 12 | auto system_bus = |
| 13 | std::make_shared<dbus::connection>(io, dbus::bus::session); |
| 14 | dbus::DbusObjectServer object_server(system_bus); |
| 15 | |
| 16 | std::vector<thresholds::Threshold> sensor_thresholds; |
| 17 | auto t = thresholds::Threshold(thresholds::Level::CRITICAL, |
| 18 | thresholds::Direction::LOW, 80); |
| 19 | sensor_thresholds.emplace_back(t); |
| 20 | |
| 21 | std::ofstream test_file("test0.txt"); |
| 22 | test_file << "28\n"; |
| 23 | test_file.close(); |
| 24 | auto filename = std::string("test0.txt"); |
| 25 | auto tempsensname = std::string("test sensor"); |
| 26 | HwmonTempSensor test(filename, object_server, io, tempsensname, |
| 27 | std::move(sensor_thresholds)); |
| 28 | |
| 29 | std::remove("test0.txt"); |
| 30 | } |
| 31 | |
| 32 | TEST(HwmonTempSensor, TestTMP421) |
| 33 | { |
| 34 | boost::asio::io_service io; |
| 35 | auto system_bus = |
| 36 | std::make_shared<dbus::connection>(io, dbus::bus::session); |
| 37 | dbus::DbusObjectServer object_server(system_bus); |
| 38 | |
| 39 | std::vector<thresholds::Threshold> sensor_thresholds; |
| 40 | auto t = thresholds::Threshold(thresholds::Level::WARNING, |
| 41 | thresholds::Direction::HIGH, 80); |
| 42 | sensor_thresholds.emplace_back(t); |
| 43 | |
| 44 | std::ofstream test_file("test1.txt"); |
| 45 | test_file << "28\n"; |
| 46 | test_file.close(); |
| 47 | auto filename = std::string("test1.txt"); |
| 48 | auto tempsensname = std::string("test sensor"); |
| 49 | HwmonTempSensor test(filename, object_server, io, tempsensname, |
| 50 | std::move(sensor_thresholds)); |
| 51 | |
| 52 | std::remove("test1.txt"); |
| 53 | } |