blob: 6ae65cedb7897b7553d38b12056c7761931db167 [file] [log] [blame]
Andrew Jefferye73bd0a2023-01-25 10:39:57 +10301#include "HwmonTempSensor.hpp"
2#include "dbus/connection.hpp"
3
James Feist582be092018-11-27 10:54:59 -08004#include <nlohmann/json.hpp>
5
James Feist38fb5982020-05-28 10:09:54 -07006#include <fstream>
7
Ed Tanous8a57ec02020-10-09 12:46:52 -07008#include <gtest/gtest.h>
James Feist6714a252018-09-10 15:26:18 -07009
10TEST(HwmonTempSensor, TestTMP75)
11{
12 boost::asio::io_service io;
Patrick Williams92f8f512022-07-22 19:26:55 -050013 auto system_bus = std::make_shared<dbus::connection>(io, dbus_t::session);
James Feist6714a252018-09-10 15:26:18 -070014 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
32TEST(HwmonTempSensor, TestTMP421)
33{
34 boost::asio::io_service io;
Patrick Williams92f8f512022-07-22 19:26:55 -050035 auto system_bus = std::make_shared<dbus::connection>(io, dbus_t::session);
James Feist6714a252018-09-10 15:26:18 -070036 dbus::DbusObjectServer object_server(system_bus);
37
38 std::vector<thresholds::Threshold> sensor_thresholds;
39 auto t = thresholds::Threshold(thresholds::Level::WARNING,
40 thresholds::Direction::HIGH, 80);
41 sensor_thresholds.emplace_back(t);
42
43 std::ofstream test_file("test1.txt");
44 test_file << "28\n";
45 test_file.close();
46 auto filename = std::string("test1.txt");
47 auto tempsensname = std::string("test sensor");
48 HwmonTempSensor test(filename, object_server, io, tempsensname,
49 std::move(sensor_thresholds));
50
51 std::remove("test1.txt");
52}