3 #include <gtest/gtest.h>
13 #define LOWBATTERY "LowBattery"
15 struct cpu_device *cpu_dev;
17 class CPUHalTest : public testing::Test
24 ret = hw_get_info(CPU_HARDWARE_DEVICE_ID,
25 (const struct hw_info **)&info);
28 cout << "Fail to load cpu hal(" << ret << ")" << endl;
33 cout << "Failed to open cpu device; open(NULL)" << endl;
38 ret = info->open(info, NULL, (struct hw_common**)&cpu_dev);
39 if (ret < 0 || !cpu_dev) {
40 cout << "Failed to get cpu device structure (" << ret << ")" << endl;
48 virtual void TearDown()
52 info = cpu_dev->common.info;
56 info->close((struct hw_common *)cpu_dev);
66 TEST_F(CPUHalTest, InitP)
68 EXPECT_NE(cpu_dev, nullptr);
71 TEST_F(CPUHalTest, DeinitP)
73 struct cpu_device *tmp;
77 hw_get_info(CPU_HARDWARE_DEVICE_ID,
78 (const struct hw_info **)&info);
80 EXPECT_NE(info, nullptr);
81 if (!info->open || !info->close)
83 info->open(info, NULL, (struct hw_common**)&tmp);
85 ret = info->close((struct hw_common *)tmp);
89 TEST_F(CPUHalTest, StartBoostP)
93 EXPECT_NE(cpu_dev, nullptr);
94 if (!cpu_dev->start_boost)
97 ret = cpu_dev->start_boost((void *)LOWBATTERY);
98 cpu_dev->stop_boost((void *)LOWBATTERY);
102 TEST_F(CPUHalTest, StopBoostP)
106 EXPECT_NE(cpu_dev, nullptr);
107 if (!cpu_dev->stop_boost)
110 cpu_dev->start_boost((void *)LOWBATTERY);
111 ret = cpu_dev->stop_boost((void *)LOWBATTERY);
115 int main(int argc, char **argv)
117 testing::InitGoogleTest(&argc, argv);
119 return RUN_ALL_TESTS();