1 #include "powercap.hpp"
2 #include "utils.hpp"
3
4 #include <occ_events.hpp>
5 #include <occ_manager.hpp>
6
7 #include <filesystem>
8
9 #include <gtest/gtest.h>
10
11 using namespace open_power::occ;
12 using namespace open_power::occ::utils;
13
14 class VerifyOccInput : public ::testing::Test
15 {
16 public:
VerifyOccInput()17 VerifyOccInput() :
18 rc(sd_event_default(&event)), eventP(event), manager(eventP),
19 occStatus(eventP, "/test/path/occ1", manager, powerMode), pcap()
20 {
21 EXPECT_GE(rc, 0);
22 event = nullptr;
23 }
~VerifyOccInput()24 ~VerifyOccInput() {}
25
26 sd_event* event = nullptr;
27 int rc;
28 open_power::occ::EventPtr eventP;
29
30 Manager manager;
31 Status occStatus;
32
33 std::unique_ptr<powermode::PowerMode> powerMode = nullptr;
34
35 powercap::PowerCap pcap;
36 };
37
TEST(VerifyPathParsing,EmptyPath)38 TEST(VerifyPathParsing, EmptyPath)
39 {
40 std::filesystem::path path = "";
41 std::string parsed = Device::getPathBack(path);
42
43 EXPECT_STREQ(parsed.c_str(), "");
44 }
45
TEST(VerifyPathParsing,FilenamePath)46 TEST(VerifyPathParsing, FilenamePath)
47 {
48 std::filesystem::path path = "/test/foo.bar";
49 std::string parsed = Device::getPathBack(path);
50
51 EXPECT_STREQ(parsed.c_str(), "foo.bar");
52 }
53
TEST(VerifyPathParsing,DirectoryPath)54 TEST(VerifyPathParsing, DirectoryPath)
55 {
56 std::filesystem::path path = "/test/bar/";
57 std::string parsed = Device::getPathBack(path);
58
59 EXPECT_STREQ(parsed.c_str(), "bar");
60 }
61