blob: dc354a8e4a0134cdec531afb34055a1da2275726 [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001#include <HwmonTempSensor.hpp>
2#include <dbus/connection.hpp>
James Feist582be092018-11-27 10:54:59 -08003#include <nlohmann/json.hpp>
4
James Feist38fb5982020-05-28 10:09:54 -07005#include <fstream>
6
Ed Tanous8a57ec02020-10-09 12:46:52 -07007#include <gtest/gtest.h>
James Feist6714a252018-09-10 15:26:18 -07008
9TEST(HwmonTempSensor, TestTMP75)
10{
11 boost::asio::io_service io;
Patrick Williams92f8f512022-07-22 19:26:55 -050012 auto system_bus = std::make_shared<dbus::connection>(io, dbus_t::session);
James Feist6714a252018-09-10 15:26:18 -070013 dbus::DbusObjectServer object_server(system_bus);
14
15 std::vector<thresholds::Threshold> sensor_thresholds;
16 auto t = thresholds::Threshold(thresholds::Level::CRITICAL,
17 thresholds::Direction::LOW, 80);
18 sensor_thresholds.emplace_back(t);
19
20 std::ofstream test_file("test0.txt");
21 test_file << "28\n";
22 test_file.close();
23 auto filename = std::string("test0.txt");
24 auto tempsensname = std::string("test sensor");
25 HwmonTempSensor test(filename, object_server, io, tempsensname,
26 std::move(sensor_thresholds));
27
28 std::remove("test0.txt");
29}
30
31TEST(HwmonTempSensor, TestTMP421)
32{
33 boost::asio::io_service io;
Patrick Williams92f8f512022-07-22 19:26:55 -050034 auto system_bus = std::make_shared<dbus::connection>(io, dbus_t::session);
James Feist6714a252018-09-10 15:26:18 -070035 dbus::DbusObjectServer object_server(system_bus);
36
37 std::vector<thresholds::Threshold> sensor_thresholds;
38 auto t = thresholds::Threshold(thresholds::Level::WARNING,
39 thresholds::Direction::HIGH, 80);
40 sensor_thresholds.emplace_back(t);
41
42 std::ofstream test_file("test1.txt");
43 test_file << "28\n";
44 test_file.close();
45 auto filename = std::string("test1.txt");
46 auto tempsensname = std::string("test sensor");
47 HwmonTempSensor test(filename, object_server, io, tempsensname,
48 std::move(sensor_thresholds));
49
50 std::remove("test1.txt");
51}