blob: f8efcc4940f640e9fd32e12546f60f229c49b5e2 [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001#include <HwmonTempSensor.hpp>
2#include <dbus/connection.hpp>
James Feist6714a252018-09-10 15:26:18 -07003#include <fstream>
James Feist582be092018-11-27 10:54:59 -08004#include <nlohmann/json.hpp>
5
James Feist6714a252018-09-10 15:26:18 -07006#include "gtest/gtest.h"
7
8TEST(HwmonTempSensor, TestTMP75)
9{
10 boost::asio::io_service io;
11 auto system_bus =
12 std::make_shared<dbus::connection>(io, dbus::bus::session);
13 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;
34 auto system_bus =
35 std::make_shared<dbus::connection>(io, dbus::bus::session);
36 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}