Remove Legacy code from P10 and future code
Remove Occ control code that supports older hardware models P8 and P9.
This is in preparation for occ control taking over occ poll handling.
Change-Id: Iff99ac8ff3a3fe6e9a6af994b20b06793ead50fc
Signed-off-by: Sheldon Bailey <baileysh@us.ibm.com>
diff --git a/test/TestI2cOcc.cpp b/test/TestI2cOcc.cpp
deleted file mode 100644
index c0fe979..0000000
--- a/test/TestI2cOcc.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "i2c_occ.hpp"
-
-#include <filesystem>
-#include <fstream>
-#include <string>
-
-#include <gtest/gtest.h>
-
-#ifdef I2C_OCC
-namespace i2c_occ
-{
-
-namespace fs = std::filesystem;
-
-using namespace std::string_literals;
-const auto STR_4_0050 = "4-0050"s;
-const auto STR_5_0051 = "5-0051"s;
-const auto STR_6_0056 = "6-0056"s;
-const auto STR_7_0057 = "7-0057"s;
-
-const auto TEST_DIR = "test-dir/"s;
-const auto BASE = TEST_DIR + "sys/bus/i2c/devices/";
-const auto I2C_0 = BASE + "i2c-0";
-const auto I2C_1 = BASE + "i2c-1";
-const auto I2C_2 = BASE + "i2c-2";
-const auto I2C_0_0068 = BASE + "0-0068";
-const auto I2C_4_0050 = BASE + STR_4_0050;
-const auto I2C_5_0051 = BASE + STR_5_0051;
-const auto I2C_6_0056 = BASE + STR_6_0056;
-const auto I2C_7_0057 = BASE + STR_7_0057;
-const auto NAME = "/name";
-const auto OCC_MASTER_NAME = "/occ_master";
-const auto P8_OCC_HWMON = "p8-occ-hwmon";
-
-const auto OTHER_STRING = "SomeOtherString123"s;
-
-class TestUtilGetOccHwmonDevices : public testing::Test
-{
- public:
- TestUtilGetOccHwmonDevices()
- {
- // Prepare env for test case
- fs::create_directories(I2C_0);
- fs::create_directories(I2C_1);
- fs::create_directories(I2C_2);
- fs::create_directories(I2C_0_0068);
- fs::create_directories(I2C_4_0050);
- fs::create_directories(I2C_5_0051);
- fs::create_directories(I2C_6_0056);
- fs::create_directories(I2C_7_0057);
-
- std::ofstream ofs;
-
- ofs.open(I2C_0 + NAME); // i2c-0 has empty name
- ofs.close();
-
- ofs.open(I2C_1 + NAME);
- ofs << "some text\n"; // i2c-1/name has some text
- ofs.close();
-
- ofs.open(I2C_2 + NAME);
- ofs << "Aspped i2c"; // i2c-2/name is aspeed i2c
- ofs.close();
-
- ofs.open(I2C_0_0068 + NAME);
- ofs << "other text"; // 0-0068/name is has other text
- ofs.close();
-
- ofs.open(I2C_4_0050 + NAME);
- ofs << "p8-occ-hwmon\n"; // 4-0050/name is p8-occ-hwmon
- ofs.close();
-
- ofs.open(I2C_4_0050 + OCC_MASTER_NAME);
- ofs << "0\n"; // Make 4-0050 the slave occ
- ofs.close();
-
- ofs.open(I2C_5_0051 + NAME);
- ofs << "p8-occ-hwmon\n"; // 5-0051/name is p8-occ-hwmon
- ofs.close();
-
- ofs.open(I2C_5_0051 + OCC_MASTER_NAME);
- ofs << "0\n"; // Make 5-0051 the slave occ
- ofs.close();
-
- ofs.open(I2C_6_0056 + NAME);
- ofs << "p8-occ-hwmon\n"; // 6-0056/name is p8-occ-hwmon
- ofs.close();
-
- ofs.open(I2C_6_0056 + OCC_MASTER_NAME);
- ofs << "1\n"; // Make 6-0056 the master occ
- ofs.close();
-
- ofs.open(I2C_7_0057 + NAME);
- ofs << "p8-occ-hwmon\n"; // 7-0057/name is p8-occ-hwmon
- ofs.close();
- }
-
- ~TestUtilGetOccHwmonDevices()
- {
- // Cleanup test env
- fs::remove_all(TEST_DIR);
- }
-};
-
-TEST_F(TestUtilGetOccHwmonDevices, getDevicesOK)
-{
- // With test env, it shall find all the 4 p8-occ-hwmon devices
- auto ret = getOccHwmonDevices(BASE.c_str());
- EXPECT_EQ(4u, ret.size());
- // The first one shall be master occ
- EXPECT_EQ(STR_6_0056, ret[0]);
- // The left is sorted
- EXPECT_EQ(STR_4_0050, ret[1]);
- EXPECT_EQ(STR_5_0051, ret[2]);
- EXPECT_EQ(STR_7_0057, ret[3]);
-}
-
-TEST_F(TestUtilGetOccHwmonDevices, getDevicesValidDirNoDevices)
-{
- // Giving a dir without valid devices,
- // it shall return an empty vector
- auto ret = getOccHwmonDevices(TEST_DIR.c_str());
- EXPECT_TRUE(ret.empty());
-}
-
-TEST_F(TestUtilGetOccHwmonDevices, getDevicesDirNotExist)
-{
- // Giving a dir that does not exist,
- // it shall return an empty vector
- auto ret = getOccHwmonDevices((TEST_DIR + "not-exist").c_str());
- EXPECT_TRUE(ret.empty());
-}
-
-TEST(TestI2cDbusNames, i2cToDbus)
-{
- // It shall convert 4-0050 to 4_0050
- auto str = STR_4_0050;
- i2cToDbus(str);
- EXPECT_EQ("4_0050", str);
-
- // It shall not modify for other strings without '-'
- str = OTHER_STRING;
- i2cToDbus(str);
- EXPECT_EQ(OTHER_STRING, str);
-}
-
-TEST(TestI2cDbusNames, dbusToI2c)
-{
- // It shall convert 4_0050 to 4-0050
- auto str = "4_0050"s;
- dbusToI2c(str);
- EXPECT_EQ(STR_4_0050, str);
-
- // It shall not modify for other strings without '-'
- str = OTHER_STRING;
- dbusToI2c(str);
- EXPECT_EQ(OTHER_STRING, str);
-}
-
-TEST(TestI2cDbusNames, getI2cDeviceName)
-{
- auto path = "/org/open_power/control/occ_4_0050"s;
- auto name = getI2cDeviceName(path);
- EXPECT_EQ(STR_4_0050, name);
-
- // With invalid occ path, the code shall assert
- path = "/org/open_power/control/SomeInvalidPath"s;
- EXPECT_DEATH(getI2cDeviceName(path), "");
-}
-
-} // namespace i2c_occ
-
-#endif // I2C_OCC
diff --git a/test/error_files_tests.cpp b/test/error_files_tests.cpp
index d83bfe1..ef895fa 100644
--- a/test/error_files_tests.cpp
+++ b/test/error_files_tests.cpp
@@ -25,12 +25,7 @@
public:
ErrorFiles() :
rc(sd_event_default(&event)), pEvent(event), manager(pEvent),
- status(pEvent, "/dummy1", manager
-#ifdef POWER10
- ,
- powerMode
-#endif
- )
+ status(pEvent, "/dummy1", manager, powerMode)
{
EXPECT_GE(rc, 0);
event = nullptr;
@@ -80,9 +75,7 @@
sd_event* event;
int rc;
open_power::occ::EventPtr pEvent;
-#ifdef POWER10
std::unique_ptr<powermode::PowerMode> powerMode = nullptr;
-#endif
Manager manager;
Status status;
@@ -94,24 +87,8 @@
TEST_F(ErrorFiles, AddDeviceErrorWatch)
{
- Device occDevice(pEvent, devicePath, manager, status
-#ifdef POWER10
- ,
- powerMode
-#endif
- );
+ Device occDevice(pEvent, devicePath, manager, status, powerMode);
occDevice.addErrorWatch(false);
occDevice.removeErrorWatch();
}
-
-// legacy OCC devices not supported on POWER10
-#ifndef POWER10
-TEST_F(ErrorFiles, AddLegacyDeviceErrorWatch)
-{
- Device legacyOccDevice(pEvent, legacyDevicePath, manager, status);
-
- legacyOccDevice.addErrorWatch(false);
- legacyOccDevice.removeErrorWatch();
-}
-#endif
diff --git a/test/meson.build b/test/meson.build
index f54bbcc..d9cc977 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -29,26 +29,14 @@
'../occ_presence.cpp',
'../occ_command.cpp',
'../occ_dbus.cpp',
+ '../pldm.cpp',
'../powercap.cpp',
- '../i2c_occ.cpp',
+ '../powermode.cpp',
'../utils.cpp',
occ_sensor_hpp,
]
-if get_option('with-host-communication-protocol') == 'pldm'
- test_sources += ['../pldm.cpp']
-endif
-
-if get_option('power10-support').allowed()
- test_sources += ['../powermode.cpp']
-endif
-
-tests = [
- 'error_files_tests.cpp',
- 'occ_dbus_test.cpp',
- 'TestI2cOcc.cpp',
- 'utest.cpp',
-]
+tests = ['error_files_tests.cpp', 'occ_dbus_test.cpp', 'utest.cpp']
pthread_dep = dependency('threads')
diff --git a/test/utest.cpp b/test/utest.cpp
index f06ad7b..92a5fd5 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -16,12 +16,7 @@
public:
VerifyOccInput() :
rc(sd_event_default(&event)), eventP(event), manager(eventP),
- occStatus(eventP, "/test/path/occ1", manager
-#ifdef POWER10
- ,
- powerMode
-#endif
- ),
+ occStatus(eventP, "/test/path/occ1", manager, powerMode),
pcap(occStatus)
{
EXPECT_GE(rc, 0);
@@ -35,9 +30,9 @@
Manager manager;
Status occStatus;
-#ifdef POWER10
+
std::unique_ptr<powermode::PowerMode> powerMode = nullptr;
-#endif
+
powercap::PowerCap pcap;
};