blob: 2be603a62d359847e4ae721661e6d805de4efb2f [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;
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
32TEST(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}