The existing pass-unittests have been tested pass-hal module.
When I tried to add pass-hal mocking class for testing pass-rescon module,
the multiple definition build error happen. So that I split out the unittest
like this.
Change-Id: If0927b34197caebec579a52359df76faa1c0308d
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
ADD_SUBDIRECTORY(tests/integration-test)
ADD_SUBDIRECTORY(tests/haltest)
-ADD_SUBDIRECTORY(tests/unittest)
+ADD_SUBDIRECTORY(tests/unittest/pass-hal-and-parser)
ADD_SUBDIRECTORY(lib)
make %{?jobs:-j%jobs}
%check
-(cd tests/unittest && LD_LIBRARY_PATH=../../ ctest -V)
+(cd tests/unittest/pass-hal-and-parser && LD_LIBRARY_PATH=../../ ctest -V)
%install
rm -rf %{buildroot}
--- /dev/null
+/*
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+extern "C" {
+#include "pass.h"
+#include "pass-hal.h"
+}
+
+#include "pass-hal-mock.hpp"
+
+using namespace std;
+using ::testing::Return;
+using ::testing::_;
+
+PassHalMock *gPassHalMock;
+
+int pass_hal_save_initdata(struct pass_resource *res)
+{
+ if (!gPassHalMock)
+ return -ENOTSUP;
+
+ return gPassHalMock->pass_hal_save_initdata(res);
+
+}
+
+int pass_hal_restore_initdata(struct pass_resource *res)
+{
+ if (!gPassHalMock)
+ return -ENOTSUP;
+
+ return gPassHalMock->pass_hal_restore_initdata(res);
+}
--- /dev/null
+/*
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+extern "C" {
+#include "pass.h"
+#include "pass-hal.h"
+}
+
+using namespace std;
+using ::testing::Return;
+using ::testing::_;
+
+class PassHalMockInterface {
+public:
+ virtual ~PassHalMockInterface() {};
+
+ virtual int pass_hal_save_initdata(struct pass_resource *res) = 0;
+ virtual int pass_hal_restore_initdata(struct pass_resource *res) = 0;
+};
+
+class PassHalMock:PassHalMockInterface {
+public:
+ MOCK_METHOD1(pass_hal_save_initdata, int (struct pass_resource *res));
+ MOCK_METHOD1(pass_hal_restore_initdata, int (struct pass_resource *res));
+};
+
+extern PassHalMock *gPassHalMock;
--- /dev/null
+/*
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <unistd.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+extern "C" {
+#include <util/common.h>
+
+#include "pass.h"
+#include "pass-hal.h"
+#include "pass-parser.h"
+#include "pass-rescon.h"
+}
+
+#include "hal-api-power-mock.hpp"
+#include "pass-hal-mock.hpp"
+
+#define FREQ_100MZ 100000
+#define CHARGING_CURRNT_1A 1000000
+#define DEFAULT_MINUS_INT -1
+#define DEFAULT_UP_THRESHOLD 90
+
+using namespace std;
+using ::testing::Return;
+using ::testing::_;
+
+class PassHalTest : public testing::Test {
+public:
+ void SetUp() override {
+ gHalApiPowerMock = new HalApiPowerMock();
+ }
+
+ void TearDown() override {
+ if (!gHalApiPowerMock)
+ return;
+
+ delete gHalApiPowerMock;
+ gHalApiPowerMock = NULL;
+ }
+};
+
+TEST_F(PassHalTest, pass_hal_get_resource) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock,
+ hal_power_get_backend(_)).WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_resource(&res);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_hal_get_resource(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_put_resource) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock,
+ hal_power_put_backend()).WillRepeatedly(Return(0));
+
+ ret = pass_hal_put_resource(&res);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_hal_put_resource(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_curr_governor) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_curr_governor(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_curr_governor(&res, buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_curr_governor(&res, NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_get_curr_governor(NULL, buf);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_curr_governor) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_curr_governor(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_curr_governor(&res, buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_curr_governor(&res, NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_curr_governor(NULL, buf);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_curr_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_curr_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_curr_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_curr_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_min_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_min_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_min_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_min_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_min_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_min_freq(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_min_freq(&res, FREQ_100MZ);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_min_freq(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_min_freq(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_max_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_max_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_max_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_max_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_max_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_max_freq(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_max_freq(&res, FREQ_100MZ);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_max_freq(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_max_freq(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_available_min_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_available_min_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_available_min_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_available_min_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_available_max_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_available_max_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_available_max_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_available_max_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_up_threshold) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_up_threshold(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_up_threshold(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_up_threshold(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_up_threshold) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_up_threshold(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_up_threshold(&res, DEFAULT_UP_THRESHOLD);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_up_threshold(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_up_threshold(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_online_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_state(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_online_state(&res, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_online_state(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_get_online_state(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_online_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_state(_, _, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_online_state(&res, 0, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_state(&res, 0, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_state(&res, 0, 10);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_state(&res, DEFAULT_MINUS_INT, 1);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_state(&res, 0, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_state(NULL, DEFAULT_MINUS_INT, 1);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_online_min_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_min_num (_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_online_min_num(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_online_min_num(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_online_min_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_min_num (_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_online_min_num(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_min_num(NULL, 2);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_min_num(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_online_max_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_max_num (_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_online_max_num(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_online_max_num(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_online_max_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_max_num (_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_online_max_num(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_max_num(NULL, 2);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_max_num(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_temp) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_temp(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_temp(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_temp(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_tmu_policy) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_policy(_, _,_))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_tmu_policy(&res, buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_tmu_policy(&res, NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_get_tmu_policy(NULL, buf);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_cooling_device_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_cooling_device_state(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_cooling_device_state(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_cooling_device_state(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_cooling_device_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_set_cooling_device_state(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_cooling_device_state(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_cooling_device_state(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_cooling_device_state(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_battery_charging_status) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_get_charging_status(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_battery_charging_status(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_battery_charging_status(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_battery_charging_status) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_set_charging_status(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_battery_charging_status(&res, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_battery_charging_status(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_battery_charging_status(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_battery_charging_status(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_battery_charging_current) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_get_charging_current(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_battery_charging_current(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_battery_charging_current(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_battery_charging_current) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_set_charging_current(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_battery_charging_current(&res, CHARGING_CURRNT_1A);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_battery_charging_current(&res, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_battery_charging_current(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_battery_charging_current(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_fault_around_bytes) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_memory_get_fault_around_bytes(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_fault_around_bytes(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_fault_around_bytes(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_fault_around_bytes) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_memory_set_fault_around_bytes(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_fault_around_bytes(&res, FREQ_100MZ);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_fault_around_bytes(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_fault_around_bytes(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_pmqos_data) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_misc_set_pmqos_data(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_pmqos_data(&res, (void *)buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_pmqos_data(NULL, (void *)buf);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_pmqos_data(NULL, NULL);
+ EXPECT_NE(ret, 0);
+}
+
+/* Unittest of pass-parser module */
+class PassParserTest : public testing::Test {
+public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+};
+
+TEST(PassParserTest, pass_parser_get_resource_config_valid) {
+ struct pass pass;
+ const char path_json[] = "./scripts/valid/pass.json";
+
+ int ret = pass_parser_get_resource_config(&pass, path_json);
+ ASSERT_EQ(ret, 0);
+
+ pass_parser_put_resource_config(&pass);
+}
+
+TEST(PassParserTest, pass_parser_get_resource_config_invalid) {
+ struct pass pass;
+ const char path_json[] = "./scripts/invalid/pass.json";
+
+ int ret = pass_parser_get_resource_config(&pass, path_json);
+ EXPECT_NE(ret, 0);
+}
+
+TEST(PassParserTest, pass_parser_get_each_resource_config_valid) {
+ struct pass pass;
+ const char path_json[] = "./scripts/valid/pass.json";
+ int i;
+
+ int ret = pass_parser_get_resource_config(&pass, path_json);
+ ASSERT_EQ(ret, 0);
+
+ for (i = 0; i < (int)pass.num_resources; i++) {
+ struct pass_resource *res = &pass.res[i];
+ ret = pass_parser_get_each_resource_config(res,
+ res->config_data.path_conf_file);
+ EXPECT_EQ(ret, 0);
+ if (ret < 0)
+ break;
+ }
+
+ for (i--; i >= 0; i--)
+ pass_parser_put_each_resource_config(&pass.res[i]);
+ pass_parser_put_resource_config(&pass);
+}
+
+class ResourceConfigInvalid {
+public:
+ const char *path_json;
+
+ ResourceConfigInvalid(
+ const char *path_json_) :
+ path_json(path_json_) {}
+};
+
+class PassParserInvalidTest : public ::testing::TestWithParam<ResourceConfigInvalid> {};
+
+INSTANTIATE_TEST_CASE_P (PassParserTest, PassParserInvalidTest,
+ ::testing::Values (
+ ResourceConfigInvalid ("./scripts/invalid-level/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-pmqos/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-thermal/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-thermal/pass1.json"),
+ ResourceConfigInvalid ("./scripts/invalid-header/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-battery/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-memory/pass.json")
+));
+
+TEST_P(PassParserInvalidTest, pass_parser_get_each_resource_config_invalid) {
+ auto param = GetParam();
+ struct pass pass;
+ unsigned int i;
+
+ int ret = pass_parser_get_resource_config(&pass, param.path_json);
+ EXPECT_EQ(ret, 0);
+
+ for (i = 0; i < pass.num_resources; i++) {
+ struct pass_resource *res = &pass.res[i];
+ ret = pass_parser_get_each_resource_config(res,
+ res->config_data.path_conf_file);
+ EXPECT_NE(ret, 0);
+ }
+
+ for (i = 0; i < pass.num_resources; i++)
+ pass_parser_put_each_resource_config(&pass.res[i]);
+ pass_parser_put_resource_config(&pass);
+}
+
+/* Unittest of pass-rescon module */
+class PassResconInitExitTest : public testing::Test {
+public:
+ void SetUp() override {
+ gPassHalMock = new PassHalMock();
+
+ EXPECT_CALL(*gPassHalMock,
+ pass_hal_save_initdata(_)).WillRepeatedly(Return(0));
+ EXPECT_CALL(*gPassHalMock,
+ pass_hal_restore_initdata(_)).WillRepeatedly(Return(0));
+ }
+
+ void TearDown() override {
+
+ if (!gPassHalMock)
+ return;
+
+ delete gPassHalMock;
+ gPassHalMock = NULL;
+ }
+};
+
+TEST(PassResconInitExitTest, pass_rescon_prepare_and_init_and_exit) {
+ struct pass_resource res;
+ res.config_data.res_type = PASS_RESOURCE_CPU_ID;
+ res.rescon = NULL;
+
+ int ret = pass_rescon_prepare(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_init(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_exit(&res);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_prepare(NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_init(NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_exit(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+#define INIT_LEVEL_VALUE 100
+struct pass_resource g_resource;
+
+class PassResconTest : public testing::Test {
+public:
+ void SetUp() override {
+ gPassHalMock = new PassHalMock();
+
+ EXPECT_CALL(*gPassHalMock,
+ pass_hal_save_initdata(_)).WillRepeatedly(Return(0));
+
+ pass_rescon_prepare(&g_resource);
+ pass_rescon_init(&g_resource);
+ }
+
+ void TearDown() override {
+ EXPECT_CALL(*gPassHalMock,
+ pass_hal_restore_initdata(_)).WillRepeatedly(Return(0));
+
+ pass_rescon_exit(&g_resource);
+
+ if (!gPassHalMock)
+ return;
+
+ delete gPassHalMock;
+ gPassHalMock = NULL;
+ }
+};
+
+TEST_F(PassResconTest, pass_rescon_set_init_level) {
+ int ret = pass_rescon_set_init_level(&g_resource, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_set_init_level(&g_resource, INIT_LEVEL_VALUE);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_set_init_level(NULL, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_init_level(&g_resource, -1);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_init_level(&g_resource, INT_MAX);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_set_curr_level) {
+ int ret = pass_rescon_set_curr_level(&g_resource, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_set_curr_level(&g_resource, INIT_LEVEL_VALUE);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_set_curr_level(NULL, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_curr_level(&g_resource, -1);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_curr_level(&g_resource, INT_MAX);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_set_prev_level) {
+ int ret = pass_rescon_set_prev_level(&g_resource, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_set_prev_level(&g_resource, INIT_LEVEL_VALUE);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_set_prev_level(NULL, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_prev_level(&g_resource, -1);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_prev_level(&g_resource, INT_MAX);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_set_min_level) {
+ int ret = pass_rescon_set_min_level(&g_resource, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_set_min_level(&g_resource, INIT_LEVEL_VALUE);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_set_min_level(NULL, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_min_level(&g_resource, -1);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_min_level(&g_resource, INT_MAX);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_set_max_level) {
+ int ret = pass_rescon_set_max_level(&g_resource, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_set_max_level(&g_resource, INIT_LEVEL_VALUE);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_set_max_level(NULL, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_max_level(&g_resource, -1);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_max_level(&g_resource, INT_MAX);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_set_init_scenario_level) {
+ int ret = pass_rescon_set_init_scenario_level(&g_resource, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_rescon_set_init_scenario_level(&g_resource, INIT_LEVEL_VALUE);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_set_init_scenario_level(NULL, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_init_scenario_level(&g_resource, -1);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_set_init_scenario_level(&g_resource, INT_MAX);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_get_init_level) {
+ int level = 0;
+ int ret = pass_rescon_get_init_level(&g_resource, &level);
+ EXPECT_EQ(ret, INIT_LEVEL_VALUE);
+
+ ret = pass_rescon_get_init_level(NULL, &level);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_get_init_level(&g_resource, NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_get_curr_level) {
+ int level = 0;
+ int ret = pass_rescon_get_curr_level(&g_resource, &level);
+ EXPECT_EQ(ret, INIT_LEVEL_VALUE);
+
+ ret = pass_rescon_get_curr_level(NULL, &level);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_get_curr_level(&g_resource, NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_get_prev_level) {
+ int level = 0;
+ int ret = pass_rescon_get_prev_level(&g_resource, &level);
+ EXPECT_EQ(ret, INIT_LEVEL_VALUE);
+
+ ret = pass_rescon_get_prev_level(NULL, &level);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_get_prev_level(&g_resource, NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_get_min_level) {
+ int level = 0;
+ int ret = pass_rescon_get_min_level(&g_resource, &level);
+ EXPECT_EQ(ret, INIT_LEVEL_VALUE);
+
+ ret = pass_rescon_get_min_level(NULL, &level);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_get_min_level(&g_resource, NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_get_max_level) {
+ int level = 0;
+ int ret = pass_rescon_get_max_level(&g_resource, &level);
+ EXPECT_EQ(ret, INIT_LEVEL_VALUE);
+
+ ret = pass_rescon_get_max_level(NULL, &level);
+ EXPECT_NE(ret, 0);
+ ret = pass_rescon_get_max_level(&g_resource, NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassResconTest, pass_rescon_sync) {
+ int ret = pass_rescon_sync(&g_resource);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_rescon_sync(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+/*
+int pass_rescon_sync(struct pass_resource *res);
+
+int pass_rescon_set_level_sync(struct pass_resource *res, int new_level);
+int pass_rescon_set_level(struct pass_resource *res, int new_level);
+
+int pass_rescon_set_scenario_level_sync(struct pass_resource *res,
+ int scenario_level);
+int pass_rescon_set_scenario_level(struct pass_resource *res,
+ int scenario_level);
+
+int pass_rescon_unset_scenario_level_sync(struct pass_resource *res,
+ int scenario_level);
+int pass_rescon_unset_scenario_level(struct pass_resource *res,
+ int scenario_level);
+
+*/
+
+int main(int argc, char *argv[])
+{
+ try {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+ } catch (...) {
+ return EXIT_FAILURE;
+ }
+}
+++ /dev/null
-ENABLE_TESTING()
-SET(PASS_UNITTEST "pass-unittests")
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Werror")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
-
-SET(PASS_SRCS
- ${CMAKE_SOURCE_DIR}/src/util/common.c
- ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c
- ${CMAKE_SOURCE_DIR}/src/pass/pass-rescon.c
- ${CMAKE_SOURCE_DIR}/src/pass/pass-parser.c
-)
-
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ PASS_UNITTEST_SRCS)
-ADD_EXECUTABLE(${PASS_UNITTEST} ${PASS_UNITTEST_SRCS} ${PASS_SRCS})
-
-TARGET_INCLUDE_DIRECTORIES(${PASS_UNITTEST} PUBLIC
- "${CMAKE_CURRENT_SOURCE_DIR}/../../include"
- "${CMAKE_SOURCE_DIR}"
- "${CMAKE_SOURCE_DIR}/src"
- "${CMAKE_SOURCE_DIR}/src/pass"
- "${CMAKE_SOURCE_DIR}/include"
-)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pass_unittest_pkgs REQUIRED
- glib-2.0
- gio-2.0
- gmock
- dlog
- json-c
- hal-api-power
-)
-
-FOREACH(flag ${pass_unittest_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-TARGET_LINK_LIBRARIES(${PASS_UNITTEST} ${pass_unittest_pkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(${PASS_UNITTEST} PROPERTIES COMPILE_FLAGS "-fPIE -fvisibility=default")
-SET_TARGET_PROPERTIES(${PASS_UNITTEST} PROPERTIES LINK_FLAGS "-pie")
-
-ADD_TEST(
- NAME ${PASS_UNITTEST}
- COMMAND ${PASS_UNITTEST}
-)
+++ /dev/null
-/*
- * Copyright (C) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <gio/gio.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-extern "C" {
-#include "pass.h"
-#include "pass-hal.h"
-#include "pass-parser.h"
-}
-
-#include "hal-api-power-mock.hpp"
-
-using namespace std;
-using ::testing::Return;
-using ::testing::_;
-
-HalApiPowerMock *gHalApiPowerMock;
-
-/**
- * Get and put power hal backend
- */
-int hal_power_get_backend(unsigned int res_type)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_get_backend(res_type);
-}
-int hal_power_put_backend(void)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_put_backend();
-}
-
-/**
- * DVFS (Dynamic Voltage Frequency Scaling) Operation for CPU/BUS/GPU H/W
- */
-/* Get and set the current governor. */
-int hal_power_dvfs_get_curr_governor(unsigned int res_type, char *res_name, char *governor)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_curr_governor(
- res_type, res_name, governor);
-}
-int hal_power_dvfs_set_curr_governor(unsigned int res_type, char *res_name, char *governor)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_set_curr_governor(
- res_type, res_name, governor);
-}
-int hal_power_dvfs_get_avail_governor(unsigned int res_type, char *res_name, char **avail_governor)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_avail_governor(
- res_type, res_name, avail_governor);
-}
-
-/* Get the current frequency. */
-int hal_power_dvfs_get_curr_freq(unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_curr_freq(
- res_type, res_name);
-}
-
-/* Get and set the minimum frequency. */
-int hal_power_dvfs_get_min_freq(unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_min_freq(
- res_type, res_name);
-}
-int hal_power_dvfs_set_min_freq(unsigned int res_type, char *res_name, int freq)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_set_min_freq(
- res_type, res_name, freq);
-}
-
-/* Get and set the maximum frequency. */
-int hal_power_dvfs_get_max_freq(unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_max_freq(
- res_type, res_name);
-}
-int hal_power_dvfs_set_max_freq(unsigned int res_type, char *res_name, int freq)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_set_max_freq(
- res_type, res_name, freq);
-}
-
-/* Get the minimum/maximum frequency which can be set to resource. */
-int hal_power_dvfs_get_available_min_freq(unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
- return gHalApiPowerMock->hal_power_dvfs_get_available_min_freq(
- res_type, res_name);
-}
-int hal_power_dvfs_get_available_max_freq(unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_available_max_freq(
- res_type, res_name);
-}
-
-/* Get and set the up_threshold to support boosting. */
-int hal_power_dvfs_get_up_threshold(unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_up_threshold(
- res_type, res_name);
-}
-int hal_power_dvfs_set_up_threshold(unsigned int res_type, char *res_name, int up_threshold)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_set_up_threshold(
- res_type, res_name, up_threshold);
-}
-
-/* Get the load_table of each resource to estimate the system load. */
-int hal_power_dvfs_get_load_table(unsigned int res_type, char *name, void *pass_cpu_load_table)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_dvfs_get_load_table(
- res_type, name, pass_cpu_load_table);
-}
-
-/**
- * CPU Hotplug Operation for CPU H/W
- */
-/* Get and set the online status of resource. */
-int hal_power_hotplug_get_online_state(unsigned int res_type, char *res_name, int cpu)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_hotplug_get_online_state(
- res_type, res_name, cpu);
-}
-int hal_power_hotplug_set_online_state(unsigned int res_type, char *res_name, int cpu, int on)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_hotplug_set_online_state(
- res_type, res_name, cpu, on);
-}
-
-/* Get and set the minimum number of online CPUs */
-int hal_power_hotplug_get_online_min_num (unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_hotplug_get_online_min_num (
- res_type, res_name);
-}
-int hal_power_hotplug_set_online_min_num (unsigned int res_type, char *res_name, int min_num)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_hotplug_set_online_min_num (
- res_type, res_name, min_num);
-}
-
-/* Get and set the maximum number of online CPUs */
-int hal_power_hotplug_get_online_max_num (unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_hotplug_get_online_max_num (
- res_type, res_name);
-}
-int hal_power_hotplug_set_online_max_num (unsigned int res_type, char *res_name, int max_num)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_hotplug_set_online_max_num (
- res_type, res_name, max_num);
-}
-
-/**
- * Thermal Operation for CPU/BUS/GPU H/W
- */
-/* Get the current temperature of resource. */
-int hal_power_thermal_get_temp(unsigned int res_type, char *res_thermal_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_thermal_get_temp(
- res_type, res_thermal_name);
-}
-
-/* Get the policy of thermal management unit. */
-int hal_power_thermal_get_policy(unsigned int res_type, char *res_thermal_name, char *policy)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_thermal_get_policy(
- res_type, res_thermal_name, policy);
-}
-
-/* Get and set the state of thermal cooling-device */
-int hal_power_thermal_get_cooling_device_state(unsigned int device_type, char *cooling_device_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_thermal_get_cooling_device_state(
- device_type, cooling_device_name);
-}
-int hal_power_thermal_set_cooling_device_state(unsigned int device_type, char *cooling_device_name, int state)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_thermal_set_cooling_device_state(
- device_type, cooling_device_name, state);
-}
-
-/* Get maximum state of thermal cooling-device */
-int hal_power_thermal_get_cooling_device_max_state(unsigned int device_type, char *cooling_device_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_thermal_get_cooling_device_max_state(
- device_type, cooling_device_name);
-}
-
-/* Get and set the battery charging state */
-int hal_power_battery_get_charging_status(unsigned int device_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_battery_get_charging_status(
- device_type, res_name);
-}
-int hal_power_battery_set_charging_status(unsigned int device_type, char *res_name, int state)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_battery_set_charging_status(
- device_type, res_name, state);
-}
-
-/* Get and set the battery charging current (unit: uA) */
-int hal_power_battery_get_charging_current(unsigned int device_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_battery_get_charging_current(
- device_type, res_name);
-}
-int hal_power_battery_set_charging_current(unsigned int device_type, char *res_name, int charing_current_uA)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_battery_set_charging_current(
- device_type, res_name, charing_current_uA);
-}
-
-/**
- * Memory Operation for Memory H/W
- */
-/* Get and set the /sys/kernel/debug/fault_around_bytes */
-int hal_power_memory_get_fault_around_bytes(unsigned int res_type, char *res_name)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_memory_get_fault_around_bytes(
- res_type, res_name);
-}
-int hal_power_memory_set_fault_around_bytes(unsigned int res_type, char *res_name, int fault_around_bytes)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_memory_set_fault_around_bytes(
- res_type, res_name, fault_around_bytes);
-}
-
-/**
- * Miscellaneous Operation for CPU/BUS/GPU H/W
- */
-int hal_power_misc_set_pmqos_data(unsigned int res_type, char *res_name, void *data)
-{
- if (!gHalApiPowerMock)
- return -ENOTSUP;
-
- return gHalApiPowerMock->hal_power_misc_set_pmqos_data(
- res_type, res_name, data);
-}
+++ /dev/null
-/*
- * Copyright (C) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <gio/gio.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-extern "C" {
-#include "pass.h"
-#include "pass-hal.h"
-#include "pass-parser.h"
-}
-
-using namespace std;
-using ::testing::Return;
-using ::testing::_;
-
-class HalApiPowerMockInterface {
-public:
- virtual ~HalApiPowerMockInterface() {};
-
- /**
- * Get and put power hal backend
- */
- virtual int hal_power_get_backend(unsigned int res_type) = 0;
- virtual int hal_power_put_backend(void) = 0;
-
- /**
- * DVFS (Dynamic Voltage Frequency Scaling) Operation for CPU/BUS/GPU H/W
- */
- /* Get and set the current governor. */
- virtual int hal_power_dvfs_get_curr_governor(unsigned int res_type, char *res_name, char *governor) = 0;
- virtual int hal_power_dvfs_set_curr_governor(unsigned int res_type, char *res_name, char *governor) = 0;
- virtual int hal_power_dvfs_get_avail_governor(unsigned int res_type, char *res_name, char **avail_governor) = 0;
-
- /* Get the current frequency. */
- virtual int hal_power_dvfs_get_curr_freq(unsigned int res_type, char *res_name) = 0;
-
- /* Get and set the minimum frequency. */
- virtual int hal_power_dvfs_get_min_freq(unsigned int res_type, char *res_name) = 0;
- virtual int hal_power_dvfs_set_min_freq(unsigned int res_type, char *res_name, int freq) = 0;
-
- /* Get and set the maximum frequency. */
- virtual int hal_power_dvfs_get_max_freq(unsigned int res_type, char *res_name) = 0;
- virtual int hal_power_dvfs_set_max_freq(unsigned int res_type, char *res_name, int freq) = 0;
-
- /* Get the minimum/maximum frequency which can be set to resource. */
- virtual int hal_power_dvfs_get_available_min_freq(unsigned int res_type, char *res_name) = 0;
- virtual int hal_power_dvfs_get_available_max_freq(unsigned int res_type, char *res_name) = 0;
-
- /* Get and set the up_threshold to support boosting. */
- virtual int hal_power_dvfs_get_up_threshold(unsigned int res_type, char *res_name) = 0;
- virtual int hal_power_dvfs_set_up_threshold(unsigned int res_type, char *res_name, int up_threshold) = 0;
-
- /* Get the load_table of each resource to estimate the system load. */
- virtual int hal_power_dvfs_get_load_table(unsigned int res_type, char *name, void *pass_cpu_load_table) = 0;
-
- /**
- * CPU Hotplug Operation for CPU H/W
- */
- /* Get and set the online status of resource. */
- virtual int hal_power_hotplug_get_online_state(unsigned int res_type, char *res_name, int cpu) = 0;
- virtual int hal_power_hotplug_set_online_state(unsigned int res_type, char *res_name, int cpu, int on) = 0;
-
- /* Get and set the minimum number of online CPUs */
- virtual int hal_power_hotplug_get_online_min_num (unsigned int res_type, char *res_name) = 0;
- virtual int hal_power_hotplug_set_online_min_num (unsigned int res_type, char *res_name, int min_num) = 0;
-
- /* Get and set the maximum number of online CPUs */
- virtual int hal_power_hotplug_get_online_max_num (unsigned int res_type, char *res_name) = 0;
- virtual int hal_power_hotplug_set_online_max_num (unsigned int res_type, char *res_name, int max_num) = 0;
-
- /**
- * Thermal Operation for CPU/BUS/GPU H/W
- */
- /* Get the current temperature of resource. */
- virtual int hal_power_thermal_get_temp(unsigned int res_type, char *res_thermal_name) = 0;
-
- /* Get the policy of thermal management unit. */
- virtual int hal_power_thermal_get_policy(unsigned int res_type, char *res_thermal_name, char *policy) = 0;
-
- /* Get and set the state of thermal cooling-device */
- virtual int hal_power_thermal_set_cooling_device_state(unsigned int device_type, char *cooling_device_name, int state) = 0;
- virtual int hal_power_thermal_get_cooling_device_state(unsigned int device_type, char *cooling_device_name) = 0;
-
- /* Get maximum state of thermal cooling-device */
- virtual int hal_power_thermal_get_cooling_device_max_state(unsigned int device_type, char *cooling_device_name) = 0;
-
- /* Get and set the battery charging state */
- virtual int hal_power_battery_set_charging_status(unsigned int device_type, char *res_name, int state) = 0;
- virtual int hal_power_battery_get_charging_status(unsigned int device_type, char *res_name) = 0;
-
- /* Get and set the battery charging current (unit: uA) */
- virtual int hal_power_battery_set_charging_current(unsigned int device_type, char *res_name, int charing_current_uA) = 0;
- virtual int hal_power_battery_get_charging_current(unsigned int device_type, char *res_name) = 0;
-
- /**
- * Memory Operation for Memory H/W
- */
- /* Get and set the /sys/kernel/debug/fault_around_bytes */
- virtual int hal_power_memory_get_fault_around_bytes(unsigned int res_type, char *res_name) = 0;
- virtual int hal_power_memory_set_fault_around_bytes(unsigned int res_type, char *res_name, int fault_around_bytes) = 0;
-
- /**
- * Miscellaneous Operation for CPU/BUS/GPU H/W
- */
- virtual int hal_power_misc_set_pmqos_data(unsigned int res_type, char *res_name, void *data) = 0;
-};
-
-class HalApiPowerMock:HalApiPowerMockInterface {
-public:
- MOCK_METHOD1(hal_power_get_backend, int (unsigned int res_type));
- MOCK_METHOD0(hal_power_put_backend, int (void));
-
- MOCK_METHOD3(hal_power_dvfs_get_curr_governor, int (unsigned int res_type, char *res_name, char *governor));
- MOCK_METHOD3(hal_power_dvfs_set_curr_governor, int (unsigned int res_type, char *res_name, char *governor));
- MOCK_METHOD3(hal_power_dvfs_get_avail_governor, int (unsigned int res_type, char *res_name, char **avail_governor));
-
- MOCK_METHOD2(hal_power_dvfs_get_curr_freq, int (unsigned int res_type, char *res_name));
-
- MOCK_METHOD2(hal_power_dvfs_get_min_freq, int (unsigned int res_type, char *res_name));
- MOCK_METHOD3(hal_power_dvfs_set_min_freq, int (unsigned int res_type, char *res_name, int freq));
-
- MOCK_METHOD2(hal_power_dvfs_get_max_freq, int (unsigned int res_type, char *res_name));
- MOCK_METHOD3(hal_power_dvfs_set_max_freq, int (unsigned int res_type, char *res_name, int freq));
-
- MOCK_METHOD2(hal_power_dvfs_get_available_min_freq, int (unsigned int res_type, char *res_name));
- MOCK_METHOD2(hal_power_dvfs_get_available_max_freq, int (unsigned int res_type, char *res_name));
-
- MOCK_METHOD2(hal_power_dvfs_get_up_threshold, int (unsigned int res_type, char *res_name));
- MOCK_METHOD3(hal_power_dvfs_set_up_threshold, int (unsigned int res_type, char *res_name, int up_threshold));
-
- MOCK_METHOD3(hal_power_dvfs_get_load_table, int (unsigned int res_type, char *name, void *pass_cpu_load_table));
-
- MOCK_METHOD3(hal_power_hotplug_get_online_state, int (unsigned int res_type, char *res_name, int cpu));
- MOCK_METHOD4(hal_power_hotplug_set_online_state, int (unsigned int res_type, char *res_name, int cpu, int on));
-
- MOCK_METHOD2(hal_power_hotplug_get_online_min_num, int (unsigned int res_type, char *res_name));
- MOCK_METHOD3(hal_power_hotplug_set_online_min_num, int (unsigned int res_type, char *res_name, int min_num));
-
- MOCK_METHOD2(hal_power_hotplug_get_online_max_num, int (unsigned int res_type, char *res_name));
- MOCK_METHOD3(hal_power_hotplug_set_online_max_num, int (unsigned int res_type, char *res_name, int max_num));
-
- MOCK_METHOD2(hal_power_thermal_get_temp, int (unsigned int res_type, char *res_thermal_name));
-
- MOCK_METHOD3(hal_power_thermal_get_policy, int (unsigned int res_type, char *res_thermal_name, char *policy));
-
- MOCK_METHOD3(hal_power_thermal_set_cooling_device_state, int (unsigned int device_type, char *cooling_device_name, int state));
- MOCK_METHOD2(hal_power_thermal_get_cooling_device_state, int (unsigned int device_type, char *cooling_device_name));
-
- MOCK_METHOD2(hal_power_thermal_get_cooling_device_max_state, int (unsigned int device_type, char *cooling_device_name));
-
- MOCK_METHOD3(hal_power_battery_set_charging_status, int (unsigned int device_type, char *res_name, int state));
- MOCK_METHOD2(hal_power_battery_get_charging_status, int (unsigned int device_type, char *res_name));
-
- MOCK_METHOD3(hal_power_battery_set_charging_current, int (unsigned int device_type, char *res_name, int charing_current_uA));
- MOCK_METHOD2(hal_power_battery_get_charging_current, int (unsigned int device_type, char *res_name));
-
- MOCK_METHOD2(hal_power_memory_get_fault_around_bytes, int (unsigned int res_type, char *res_name));
- MOCK_METHOD3(hal_power_memory_set_fault_around_bytes, int (unsigned int res_type, char *res_name, int fault_around_bytes));
-
- MOCK_METHOD3(hal_power_misc_set_pmqos_data, int (unsigned int res_type, char *res_name, void *data));
-
-};
-
-extern HalApiPowerMock *gHalApiPowerMock;
--- /dev/null
+ENABLE_TESTING()
+SET(PASS_UNITTEST "pass-hal-and-parser-unittests")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Werror")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
+
+SET(PASS_SRCS
+ ${CMAKE_SOURCE_DIR}/src/util/common.c
+ ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c
+ ${CMAKE_SOURCE_DIR}/src/pass/pass-rescon.c
+ ${CMAKE_SOURCE_DIR}/src/pass/pass-parser.c
+)
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ PASS_UNITTEST_SRCS)
+ADD_EXECUTABLE(${PASS_UNITTEST} ${PASS_UNITTEST_SRCS} ${PASS_SRCS})
+
+TARGET_INCLUDE_DIRECTORIES(${PASS_UNITTEST} PUBLIC
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../include"
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_SOURCE_DIR}/src"
+ "${CMAKE_SOURCE_DIR}/src/pass"
+ "${CMAKE_SOURCE_DIR}/include"
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pass_unittest_pkgs REQUIRED
+ glib-2.0
+ gio-2.0
+ gmock
+ dlog
+ json-c
+ hal-api-power
+)
+
+FOREACH(flag ${pass_unittest_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+TARGET_LINK_LIBRARIES(${PASS_UNITTEST} ${pass_unittest_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PASS_UNITTEST} PROPERTIES COMPILE_FLAGS "-fPIE -fvisibility=default")
+SET_TARGET_PROPERTIES(${PASS_UNITTEST} PROPERTIES LINK_FLAGS "-pie")
+
+ADD_TEST(
+ NAME ${PASS_UNITTEST}
+ COMMAND ${PASS_UNITTEST}
+)
--- /dev/null
+/*
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+extern "C" {
+#include "pass.h"
+#include "pass-hal.h"
+#include "pass-parser.h"
+}
+
+#include "hal-api-power-mock.hpp"
+
+using namespace std;
+using ::testing::Return;
+using ::testing::_;
+
+HalApiPowerMock *gHalApiPowerMock;
+
+/**
+ * Get and put power hal backend
+ */
+int hal_power_get_backend(unsigned int res_type)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_get_backend(res_type);
+}
+int hal_power_put_backend(void)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_put_backend();
+}
+
+/**
+ * DVFS (Dynamic Voltage Frequency Scaling) Operation for CPU/BUS/GPU H/W
+ */
+/* Get and set the current governor. */
+int hal_power_dvfs_get_curr_governor(unsigned int res_type, char *res_name, char *governor)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_curr_governor(
+ res_type, res_name, governor);
+}
+int hal_power_dvfs_set_curr_governor(unsigned int res_type, char *res_name, char *governor)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_set_curr_governor(
+ res_type, res_name, governor);
+}
+int hal_power_dvfs_get_avail_governor(unsigned int res_type, char *res_name, char **avail_governor)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_avail_governor(
+ res_type, res_name, avail_governor);
+}
+
+/* Get the current frequency. */
+int hal_power_dvfs_get_curr_freq(unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_curr_freq(
+ res_type, res_name);
+}
+
+/* Get and set the minimum frequency. */
+int hal_power_dvfs_get_min_freq(unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_min_freq(
+ res_type, res_name);
+}
+int hal_power_dvfs_set_min_freq(unsigned int res_type, char *res_name, int freq)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_set_min_freq(
+ res_type, res_name, freq);
+}
+
+/* Get and set the maximum frequency. */
+int hal_power_dvfs_get_max_freq(unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_max_freq(
+ res_type, res_name);
+}
+int hal_power_dvfs_set_max_freq(unsigned int res_type, char *res_name, int freq)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_set_max_freq(
+ res_type, res_name, freq);
+}
+
+/* Get the minimum/maximum frequency which can be set to resource. */
+int hal_power_dvfs_get_available_min_freq(unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+ return gHalApiPowerMock->hal_power_dvfs_get_available_min_freq(
+ res_type, res_name);
+}
+int hal_power_dvfs_get_available_max_freq(unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_available_max_freq(
+ res_type, res_name);
+}
+
+/* Get and set the up_threshold to support boosting. */
+int hal_power_dvfs_get_up_threshold(unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_up_threshold(
+ res_type, res_name);
+}
+int hal_power_dvfs_set_up_threshold(unsigned int res_type, char *res_name, int up_threshold)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_set_up_threshold(
+ res_type, res_name, up_threshold);
+}
+
+/* Get the load_table of each resource to estimate the system load. */
+int hal_power_dvfs_get_load_table(unsigned int res_type, char *name, void *pass_cpu_load_table)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_dvfs_get_load_table(
+ res_type, name, pass_cpu_load_table);
+}
+
+/**
+ * CPU Hotplug Operation for CPU H/W
+ */
+/* Get and set the online status of resource. */
+int hal_power_hotplug_get_online_state(unsigned int res_type, char *res_name, int cpu)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_hotplug_get_online_state(
+ res_type, res_name, cpu);
+}
+int hal_power_hotplug_set_online_state(unsigned int res_type, char *res_name, int cpu, int on)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_hotplug_set_online_state(
+ res_type, res_name, cpu, on);
+}
+
+/* Get and set the minimum number of online CPUs */
+int hal_power_hotplug_get_online_min_num (unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_hotplug_get_online_min_num (
+ res_type, res_name);
+}
+int hal_power_hotplug_set_online_min_num (unsigned int res_type, char *res_name, int min_num)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_hotplug_set_online_min_num (
+ res_type, res_name, min_num);
+}
+
+/* Get and set the maximum number of online CPUs */
+int hal_power_hotplug_get_online_max_num (unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_hotplug_get_online_max_num (
+ res_type, res_name);
+}
+int hal_power_hotplug_set_online_max_num (unsigned int res_type, char *res_name, int max_num)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_hotplug_set_online_max_num (
+ res_type, res_name, max_num);
+}
+
+/**
+ * Thermal Operation for CPU/BUS/GPU H/W
+ */
+/* Get the current temperature of resource. */
+int hal_power_thermal_get_temp(unsigned int res_type, char *res_thermal_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_thermal_get_temp(
+ res_type, res_thermal_name);
+}
+
+/* Get the policy of thermal management unit. */
+int hal_power_thermal_get_policy(unsigned int res_type, char *res_thermal_name, char *policy)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_thermal_get_policy(
+ res_type, res_thermal_name, policy);
+}
+
+/* Get and set the state of thermal cooling-device */
+int hal_power_thermal_get_cooling_device_state(unsigned int device_type, char *cooling_device_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_thermal_get_cooling_device_state(
+ device_type, cooling_device_name);
+}
+int hal_power_thermal_set_cooling_device_state(unsigned int device_type, char *cooling_device_name, int state)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_thermal_set_cooling_device_state(
+ device_type, cooling_device_name, state);
+}
+
+/* Get maximum state of thermal cooling-device */
+int hal_power_thermal_get_cooling_device_max_state(unsigned int device_type, char *cooling_device_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_thermal_get_cooling_device_max_state(
+ device_type, cooling_device_name);
+}
+
+/* Get and set the battery charging state */
+int hal_power_battery_get_charging_status(unsigned int device_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_battery_get_charging_status(
+ device_type, res_name);
+}
+int hal_power_battery_set_charging_status(unsigned int device_type, char *res_name, int state)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_battery_set_charging_status(
+ device_type, res_name, state);
+}
+
+/* Get and set the battery charging current (unit: uA) */
+int hal_power_battery_get_charging_current(unsigned int device_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_battery_get_charging_current(
+ device_type, res_name);
+}
+int hal_power_battery_set_charging_current(unsigned int device_type, char *res_name, int charing_current_uA)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_battery_set_charging_current(
+ device_type, res_name, charing_current_uA);
+}
+
+/**
+ * Memory Operation for Memory H/W
+ */
+/* Get and set the /sys/kernel/debug/fault_around_bytes */
+int hal_power_memory_get_fault_around_bytes(unsigned int res_type, char *res_name)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_memory_get_fault_around_bytes(
+ res_type, res_name);
+}
+int hal_power_memory_set_fault_around_bytes(unsigned int res_type, char *res_name, int fault_around_bytes)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_memory_set_fault_around_bytes(
+ res_type, res_name, fault_around_bytes);
+}
+
+/**
+ * Miscellaneous Operation for CPU/BUS/GPU H/W
+ */
+int hal_power_misc_set_pmqos_data(unsigned int res_type, char *res_name, void *data)
+{
+ if (!gHalApiPowerMock)
+ return -ENOTSUP;
+
+ return gHalApiPowerMock->hal_power_misc_set_pmqos_data(
+ res_type, res_name, data);
+}
--- /dev/null
+/*
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+extern "C" {
+#include "pass.h"
+#include "pass-hal.h"
+#include "pass-parser.h"
+}
+
+using namespace std;
+using ::testing::Return;
+using ::testing::_;
+
+class HalApiPowerMockInterface {
+public:
+ virtual ~HalApiPowerMockInterface() {};
+
+ /**
+ * Get and put power hal backend
+ */
+ virtual int hal_power_get_backend(unsigned int res_type) = 0;
+ virtual int hal_power_put_backend(void) = 0;
+
+ /**
+ * DVFS (Dynamic Voltage Frequency Scaling) Operation for CPU/BUS/GPU H/W
+ */
+ /* Get and set the current governor. */
+ virtual int hal_power_dvfs_get_curr_governor(unsigned int res_type, char *res_name, char *governor) = 0;
+ virtual int hal_power_dvfs_set_curr_governor(unsigned int res_type, char *res_name, char *governor) = 0;
+ virtual int hal_power_dvfs_get_avail_governor(unsigned int res_type, char *res_name, char **avail_governor) = 0;
+
+ /* Get the current frequency. */
+ virtual int hal_power_dvfs_get_curr_freq(unsigned int res_type, char *res_name) = 0;
+
+ /* Get and set the minimum frequency. */
+ virtual int hal_power_dvfs_get_min_freq(unsigned int res_type, char *res_name) = 0;
+ virtual int hal_power_dvfs_set_min_freq(unsigned int res_type, char *res_name, int freq) = 0;
+
+ /* Get and set the maximum frequency. */
+ virtual int hal_power_dvfs_get_max_freq(unsigned int res_type, char *res_name) = 0;
+ virtual int hal_power_dvfs_set_max_freq(unsigned int res_type, char *res_name, int freq) = 0;
+
+ /* Get the minimum/maximum frequency which can be set to resource. */
+ virtual int hal_power_dvfs_get_available_min_freq(unsigned int res_type, char *res_name) = 0;
+ virtual int hal_power_dvfs_get_available_max_freq(unsigned int res_type, char *res_name) = 0;
+
+ /* Get and set the up_threshold to support boosting. */
+ virtual int hal_power_dvfs_get_up_threshold(unsigned int res_type, char *res_name) = 0;
+ virtual int hal_power_dvfs_set_up_threshold(unsigned int res_type, char *res_name, int up_threshold) = 0;
+
+ /* Get the load_table of each resource to estimate the system load. */
+ virtual int hal_power_dvfs_get_load_table(unsigned int res_type, char *name, void *pass_cpu_load_table) = 0;
+
+ /**
+ * CPU Hotplug Operation for CPU H/W
+ */
+ /* Get and set the online status of resource. */
+ virtual int hal_power_hotplug_get_online_state(unsigned int res_type, char *res_name, int cpu) = 0;
+ virtual int hal_power_hotplug_set_online_state(unsigned int res_type, char *res_name, int cpu, int on) = 0;
+
+ /* Get and set the minimum number of online CPUs */
+ virtual int hal_power_hotplug_get_online_min_num (unsigned int res_type, char *res_name) = 0;
+ virtual int hal_power_hotplug_set_online_min_num (unsigned int res_type, char *res_name, int min_num) = 0;
+
+ /* Get and set the maximum number of online CPUs */
+ virtual int hal_power_hotplug_get_online_max_num (unsigned int res_type, char *res_name) = 0;
+ virtual int hal_power_hotplug_set_online_max_num (unsigned int res_type, char *res_name, int max_num) = 0;
+
+ /**
+ * Thermal Operation for CPU/BUS/GPU H/W
+ */
+ /* Get the current temperature of resource. */
+ virtual int hal_power_thermal_get_temp(unsigned int res_type, char *res_thermal_name) = 0;
+
+ /* Get the policy of thermal management unit. */
+ virtual int hal_power_thermal_get_policy(unsigned int res_type, char *res_thermal_name, char *policy) = 0;
+
+ /* Get and set the state of thermal cooling-device */
+ virtual int hal_power_thermal_set_cooling_device_state(unsigned int device_type, char *cooling_device_name, int state) = 0;
+ virtual int hal_power_thermal_get_cooling_device_state(unsigned int device_type, char *cooling_device_name) = 0;
+
+ /* Get maximum state of thermal cooling-device */
+ virtual int hal_power_thermal_get_cooling_device_max_state(unsigned int device_type, char *cooling_device_name) = 0;
+
+ /* Get and set the battery charging state */
+ virtual int hal_power_battery_set_charging_status(unsigned int device_type, char *res_name, int state) = 0;
+ virtual int hal_power_battery_get_charging_status(unsigned int device_type, char *res_name) = 0;
+
+ /* Get and set the battery charging current (unit: uA) */
+ virtual int hal_power_battery_set_charging_current(unsigned int device_type, char *res_name, int charing_current_uA) = 0;
+ virtual int hal_power_battery_get_charging_current(unsigned int device_type, char *res_name) = 0;
+
+ /**
+ * Memory Operation for Memory H/W
+ */
+ /* Get and set the /sys/kernel/debug/fault_around_bytes */
+ virtual int hal_power_memory_get_fault_around_bytes(unsigned int res_type, char *res_name) = 0;
+ virtual int hal_power_memory_set_fault_around_bytes(unsigned int res_type, char *res_name, int fault_around_bytes) = 0;
+
+ /**
+ * Miscellaneous Operation for CPU/BUS/GPU H/W
+ */
+ virtual int hal_power_misc_set_pmqos_data(unsigned int res_type, char *res_name, void *data) = 0;
+};
+
+class HalApiPowerMock:HalApiPowerMockInterface {
+public:
+ MOCK_METHOD1(hal_power_get_backend, int (unsigned int res_type));
+ MOCK_METHOD0(hal_power_put_backend, int (void));
+
+ MOCK_METHOD3(hal_power_dvfs_get_curr_governor, int (unsigned int res_type, char *res_name, char *governor));
+ MOCK_METHOD3(hal_power_dvfs_set_curr_governor, int (unsigned int res_type, char *res_name, char *governor));
+ MOCK_METHOD3(hal_power_dvfs_get_avail_governor, int (unsigned int res_type, char *res_name, char **avail_governor));
+
+ MOCK_METHOD2(hal_power_dvfs_get_curr_freq, int (unsigned int res_type, char *res_name));
+
+ MOCK_METHOD2(hal_power_dvfs_get_min_freq, int (unsigned int res_type, char *res_name));
+ MOCK_METHOD3(hal_power_dvfs_set_min_freq, int (unsigned int res_type, char *res_name, int freq));
+
+ MOCK_METHOD2(hal_power_dvfs_get_max_freq, int (unsigned int res_type, char *res_name));
+ MOCK_METHOD3(hal_power_dvfs_set_max_freq, int (unsigned int res_type, char *res_name, int freq));
+
+ MOCK_METHOD2(hal_power_dvfs_get_available_min_freq, int (unsigned int res_type, char *res_name));
+ MOCK_METHOD2(hal_power_dvfs_get_available_max_freq, int (unsigned int res_type, char *res_name));
+
+ MOCK_METHOD2(hal_power_dvfs_get_up_threshold, int (unsigned int res_type, char *res_name));
+ MOCK_METHOD3(hal_power_dvfs_set_up_threshold, int (unsigned int res_type, char *res_name, int up_threshold));
+
+ MOCK_METHOD3(hal_power_dvfs_get_load_table, int (unsigned int res_type, char *name, void *pass_cpu_load_table));
+
+ MOCK_METHOD3(hal_power_hotplug_get_online_state, int (unsigned int res_type, char *res_name, int cpu));
+ MOCK_METHOD4(hal_power_hotplug_set_online_state, int (unsigned int res_type, char *res_name, int cpu, int on));
+
+ MOCK_METHOD2(hal_power_hotplug_get_online_min_num, int (unsigned int res_type, char *res_name));
+ MOCK_METHOD3(hal_power_hotplug_set_online_min_num, int (unsigned int res_type, char *res_name, int min_num));
+
+ MOCK_METHOD2(hal_power_hotplug_get_online_max_num, int (unsigned int res_type, char *res_name));
+ MOCK_METHOD3(hal_power_hotplug_set_online_max_num, int (unsigned int res_type, char *res_name, int max_num));
+
+ MOCK_METHOD2(hal_power_thermal_get_temp, int (unsigned int res_type, char *res_thermal_name));
+
+ MOCK_METHOD3(hal_power_thermal_get_policy, int (unsigned int res_type, char *res_thermal_name, char *policy));
+
+ MOCK_METHOD3(hal_power_thermal_set_cooling_device_state, int (unsigned int device_type, char *cooling_device_name, int state));
+ MOCK_METHOD2(hal_power_thermal_get_cooling_device_state, int (unsigned int device_type, char *cooling_device_name));
+
+ MOCK_METHOD2(hal_power_thermal_get_cooling_device_max_state, int (unsigned int device_type, char *cooling_device_name));
+
+ MOCK_METHOD3(hal_power_battery_set_charging_status, int (unsigned int device_type, char *res_name, int state));
+ MOCK_METHOD2(hal_power_battery_get_charging_status, int (unsigned int device_type, char *res_name));
+
+ MOCK_METHOD3(hal_power_battery_set_charging_current, int (unsigned int device_type, char *res_name, int charing_current_uA));
+ MOCK_METHOD2(hal_power_battery_get_charging_current, int (unsigned int device_type, char *res_name));
+
+ MOCK_METHOD2(hal_power_memory_get_fault_around_bytes, int (unsigned int res_type, char *res_name));
+ MOCK_METHOD3(hal_power_memory_set_fault_around_bytes, int (unsigned int res_type, char *res_name, int fault_around_bytes));
+
+ MOCK_METHOD3(hal_power_misc_set_pmqos_data, int (unsigned int res_type, char *res_name, void *data));
+
+};
+
+extern HalApiPowerMock *gHalApiPowerMock;
--- /dev/null
+/*
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <unistd.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+extern "C" {
+#include <util/common.h>
+
+#include "pass.h"
+#include "pass-hal.h"
+#include "pass-parser.h"
+}
+
+#include "hal-api-power-mock.hpp"
+
+#define FREQ_100MZ 100000
+#define CHARGING_CURRNT_1A 1000000
+#define DEFAULT_MINUS_INT -1
+#define DEFAULT_UP_THRESHOLD 90
+
+using namespace std;
+using ::testing::Return;
+using ::testing::_;
+
+class PassHalTest : public testing::Test {
+public:
+ void SetUp() override {
+ gHalApiPowerMock = new HalApiPowerMock();
+ }
+
+ void TearDown() override {
+ if (!gHalApiPowerMock)
+ return;
+
+ delete gHalApiPowerMock;
+ gHalApiPowerMock = NULL;
+ }
+};
+
+TEST_F(PassHalTest, pass_hal_get_resource) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock,
+ hal_power_get_backend(_)).WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_resource(&res);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_hal_get_resource(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_put_resource) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock,
+ hal_power_put_backend()).WillRepeatedly(Return(0));
+
+ ret = pass_hal_put_resource(&res);
+ EXPECT_EQ(ret, 0);
+
+ ret = pass_hal_put_resource(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_curr_governor) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_curr_governor(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_curr_governor(&res, buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_curr_governor(&res, NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_get_curr_governor(NULL, buf);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_curr_governor) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_curr_governor(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_curr_governor(&res, buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_curr_governor(&res, NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_curr_governor(NULL, buf);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_curr_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_curr_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_curr_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_curr_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_min_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_min_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_min_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_min_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_min_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_min_freq(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_min_freq(&res, FREQ_100MZ);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_min_freq(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_min_freq(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_max_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_max_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_max_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_max_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_max_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_max_freq(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_max_freq(&res, FREQ_100MZ);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_max_freq(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_max_freq(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_available_min_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_available_min_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_available_min_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_available_min_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_available_max_freq) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_available_max_freq(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_available_max_freq(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_available_max_freq(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_up_threshold) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_up_threshold(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_up_threshold(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_up_threshold(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_up_threshold) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_up_threshold(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_up_threshold(&res, DEFAULT_UP_THRESHOLD);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_up_threshold(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_up_threshold(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_online_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_state(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_online_state(&res, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_online_state(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_get_online_state(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_online_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_state(_, _, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_online_state(&res, 0, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_state(&res, 0, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_state(&res, 0, 10);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_state(&res, DEFAULT_MINUS_INT, 1);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_state(&res, 0, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_state(NULL, DEFAULT_MINUS_INT, 1);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_online_min_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_min_num (_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_online_min_num(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_online_min_num(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_online_min_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_min_num (_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_online_min_num(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_min_num(NULL, 2);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_min_num(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_online_max_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_max_num (_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_online_max_num(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_online_max_num(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_online_max_num) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_max_num (_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_online_max_num(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_online_max_num(NULL, 2);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_online_max_num(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_temp) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_temp(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_temp(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_temp(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_tmu_policy) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_policy(_, _,_))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_tmu_policy(&res, buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_tmu_policy(&res, NULL);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_get_tmu_policy(NULL, buf);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_cooling_device_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_cooling_device_state(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_cooling_device_state(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_cooling_device_state(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_cooling_device_state) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_set_cooling_device_state(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_cooling_device_state(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_cooling_device_state(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_cooling_device_state(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_battery_charging_status) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_get_charging_status(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_battery_charging_status(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_battery_charging_status(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_battery_charging_status) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_set_charging_status(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_battery_charging_status(&res, 0);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_battery_charging_status(&res, 1);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_battery_charging_status(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_battery_charging_status(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_battery_charging_current) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_get_charging_current(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_battery_charging_current(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_battery_charging_current(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_battery_charging_current) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_set_charging_current(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_battery_charging_current(&res, CHARGING_CURRNT_1A);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_battery_charging_current(&res, 0);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_battery_charging_current(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_battery_charging_current(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_get_fault_around_bytes) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_memory_get_fault_around_bytes(_, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_get_fault_around_bytes(&res);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_get_fault_around_bytes(NULL);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_fault_around_bytes) {
+ struct pass_resource res;
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_memory_set_fault_around_bytes(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_fault_around_bytes(&res, FREQ_100MZ);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_fault_around_bytes(&res, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_fault_around_bytes(NULL, DEFAULT_MINUS_INT);
+ EXPECT_NE(ret, 0);
+}
+
+TEST_F(PassHalTest, pass_hal_set_pmqos_data) {
+ struct pass_resource res;
+ char buf[BUFF_MAX];
+ int ret;
+
+ EXPECT_CALL(*gHalApiPowerMock, hal_power_misc_set_pmqos_data(_, _, _))
+ .WillRepeatedly(Return(0));
+
+ ret = pass_hal_set_pmqos_data(&res, (void *)buf);
+ EXPECT_EQ(ret, 0);
+ ret = pass_hal_set_pmqos_data(NULL, (void *)buf);
+ EXPECT_NE(ret, 0);
+ ret = pass_hal_set_pmqos_data(NULL, NULL);
+ EXPECT_NE(ret, 0);
+}
+
+/* Unittest of pass-parser module */
+class PassParserTest : public testing::Test {
+public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+};
+
+TEST(PassParserTest, pass_parser_get_resource_config_valid) {
+ struct pass pass;
+ const char path_json[] = "./scripts/valid/pass.json";
+
+ int ret = pass_parser_get_resource_config(&pass, path_json);
+ ASSERT_EQ(ret, 0);
+
+ pass_parser_put_resource_config(&pass);
+}
+
+TEST(PassParserTest, pass_parser_get_resource_config_invalid) {
+ struct pass pass;
+ const char path_json[] = "./scripts/invalid/pass.json";
+
+ int ret = pass_parser_get_resource_config(&pass, path_json);
+ EXPECT_NE(ret, 0);
+}
+
+TEST(PassParserTest, pass_parser_get_each_resource_config_valid) {
+ struct pass pass;
+ const char path_json[] = "./scripts/valid/pass.json";
+ int i;
+
+ int ret = pass_parser_get_resource_config(&pass, path_json);
+ ASSERT_EQ(ret, 0);
+
+ for (i = 0; i < (int)pass.num_resources; i++) {
+ struct pass_resource *res = &pass.res[i];
+ ret = pass_parser_get_each_resource_config(res,
+ res->config_data.path_conf_file);
+ EXPECT_EQ(ret, 0);
+ if (ret < 0)
+ break;
+ }
+
+ for (i--; i >= 0; i--)
+ pass_parser_put_each_resource_config(&pass.res[i]);
+ pass_parser_put_resource_config(&pass);
+}
+
+class ResourceConfigInvalid {
+public:
+ const char *path_json;
+
+ ResourceConfigInvalid(
+ const char *path_json_) :
+ path_json(path_json_) {}
+};
+
+class PassParserInvalidTest : public ::testing::TestWithParam<ResourceConfigInvalid> {};
+
+INSTANTIATE_TEST_CASE_P (PassParserTest, PassParserInvalidTest,
+ ::testing::Values (
+ ResourceConfigInvalid ("./scripts/invalid-level/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-pmqos/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-thermal/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-thermal/pass1.json"),
+ ResourceConfigInvalid ("./scripts/invalid-header/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-battery/pass.json"),
+ ResourceConfigInvalid ("./scripts/invalid-memory/pass.json")
+));
+
+TEST_P(PassParserInvalidTest, pass_parser_get_each_resource_config_invalid) {
+ auto param = GetParam();
+ struct pass pass;
+ unsigned int i;
+
+ int ret = pass_parser_get_resource_config(&pass, param.path_json);
+ EXPECT_EQ(ret, 0);
+
+ for (i = 0; i < pass.num_resources; i++) {
+ struct pass_resource *res = &pass.res[i];
+ ret = pass_parser_get_each_resource_config(res,
+ res->config_data.path_conf_file);
+ EXPECT_NE(ret, 0);
+ }
+
+ for (i = 0; i < pass.num_resources; i++)
+ pass_parser_put_each_resource_config(&pass.res[i]);
+ pass_parser_put_resource_config(&pass);
+}
+
+int main(int argc, char *argv[])
+{
+ try {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+ } catch (...) {
+ return EXIT_FAILURE;
+ }
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ //"battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
+ //"battery_charging_currnt_uA" : 2048000
+ }, {
+ "level" : 1,
+ //"battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
+ //"battery,charging_currnt_uA" : 1024000
+ }, {
+ //"level" : 2,
+ //"battery,charging_status" : 3, // POWER_SUPPLY_STATUS_NOT_CHARGING
+ //"battery,charging_currnt_uA" : 1024000
+ }
+ ],
+
+ "pmqos_support" : false,
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 45, "threshold": 42},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 45, "end": 50, "threshold": 47},
+ "timer_interval_ms" : 3000,
+ "target_level" : 1
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 50, "end": 55, "threshold": 52},
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 55, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "battery",
+ "device_name" : "battery",
+ "device_config_path" : "./scripts/invalid-battery/pass-battery.json",
+ "thermal_device_name" : "thermal_zone5",
+ "cooling_device_name" : null
+ }
+ ]
+}
--- /dev/null
+{
+ "support" : true,
+ //"init_level" : 0,
+ //"level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 138000000,
+ "dvfs,maximum_frequency_khz" : 413000000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 138000000,
+ "dvfs,maximum_frequency_khz" : 138000000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 138000000,
+ "dvfs,maximum_frequency_khz" : 275000000
+ }, {
+ "level" : 3,
+ "dvfs,minimum_frequency_khz" : 413000000,
+ "dvfs,maximum_frequency_khz" : 413000000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 3
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 1
+ }, {
+ "name" : "Doze",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 3
+ }
+ ],
+
+ "thermal_support" : false,
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "bus",
+ "device_name" : "devfreq0",
+ "device_config_path" : "./scripts/invalid-bus/pass-bus0.json",
+ "thermal_device_name" : null
+ }
+ ]
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 1500000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ //"level" : 2,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 600000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 1
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 75, "threshold": 72},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 75, "end": 80, "threshold": 77 },
+ "timer_interval_ms" : 3000,
+ "target_level" : 0
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 80, "end": 85, "threshold": 82 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 85, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "cpu",
+ "device_name" : "cpu0",
+ "device_config_path" : "./scripts/invalid-level/pass-cpu0.json",
+ "thermal_device_name" : "thermal_zone0",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 0
+ }
+ ]
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "memory,fault_around_bytes" : 4096
+ }, {
+ //"level" : 1,
+ //"memory,fault_around_bytes" : 65536
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list" :
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 0
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 0
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : false,
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "memory",
+ "device_name" : "memory",
+ "device_config_path" : "./scripts/invalid-memory/pass-memory.json"
+ }
+ ]
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 1500000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 600000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 1
+ }, {
+ //"name" : "UltraPowerSaving",
+ //"target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 75, "threshold": 72},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 75, "end": 80, "threshold": 77 },
+ "timer_interval_ms" : 3000,
+ "target_level" : 0
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 80, "end": 85, "threshold": 82 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 85, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "cpu",
+ "device_name" : "cpu0",
+ "device_config_path" : "./scripts/invalid-pmqos/pass-cpu0.json",
+ "thermal_device_name" : "thermal_zone0",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 0
+ }
+ ]
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 1500000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 600000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 1
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 75, "threshold": 72},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ //"name" : "Warning",
+ //"temperature" : { "start": 75, "end": 80, "threshold": 77 },
+ //"timer_interval_ms" : 3000,
+ //"target_level" : 0
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 80, "end": 85, "threshold": 82 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 85, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 1500000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 600000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 1
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 75, "threshold": 72},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 75, "end": 80, "threshold": 77 },
+ "timer_interval_ms" : 3000,
+ "target_level" : 0
+ }, {
+ "name" : "LimitAction",
+ "temperature" :
+ {
+ //"start": 80, "end": 85, "threshold": 82
+ },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 85, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "cpu",
+ "device_name" : "cpu0",
+ "device_config_path" : "./scripts/invalid-thermal/pass-cpu.json",
+ "thermal_device_name" : "thermal_zone0",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 0
+ }
+ ]
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "cpu",
+ "device_name" : "cpu0",
+ "device_config_path" : "./scripts/invalid-thermal/pass-cpu1.json",
+ "thermal_device_name" : "thermal_zone0",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 0
+ }
+ ]
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ //"device_type" : "cpu",
+ //"device_name" : "cpu0",
+ //"device_config_path" : "./scripts/valid/pass-cpu0.json",
+ "thermal_device_name" : "thermal_zone0",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 0
+ }, {
+ //"device_type" : "cpu",
+ "device_name" : "cpu4",
+ "device_config_path" : "./scripts/valid/pass-cpu4.json",
+ "thermal_device_name" : "thermal_zone1",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 4
+ }, {
+ "device_type" : "bus",
+ "device_name" : "devfreq0",
+ //"device_config_path" : "./scripts/valid/pass-bus.json",
+ "thermal_device_name" : null
+ }, {
+ "device_type" : "bus",
+ //"device_name" : "devfreq5",
+ "device_config_path" : "./scripts/valid/pass-bus1.json",
+ "thermal_device_name" : null
+ }, {
+ "device_type" : "gpu",
+ "device_name" : "devfreq10",
+ //"device_config_path" : "./scripts/vaild/pass-gpu.json",
+ "thermal_device_name" : "thermal_zone3"
+ }, {
+ "device_type" : "memory",
+ "device_name" : "memory",
+ //"device_config_path" : "./scripts/valid/pass-memory.json"
+ }, {
+ "device_type" : "battery",
+ //"device_name" : "battery",
+ "device_config_path" : "./scripts/valid/pass-battery.json",
+ "thermal_device_name" : "thermal_zone5",
+ "cooling_device_name" : null
+ }
+ ]
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
+ "battery_charging_currnt_uA" : 2048000
+ }, {
+ "level" : 1,
+ "battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
+ "battery,charging_currnt_uA" : 1024000
+ }, {
+ "level" : 2,
+ "battery,charging_status" : 3, // POWER_SUPPLY_STATUS_NOT_CHARGING
+ "battery,charging_currnt_uA" : 1024000
+ }
+ ],
+
+ "pmqos_support" :false,
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 45, "threshold": 42},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 45, "end": 50, "threshold": 47},
+ "timer_interval_ms" : 3000,
+ "target_level" : 1
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 50, "end": 55, "threshold": 52},
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 55, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 138000000,
+ "dvfs,maximum_frequency_khz" : 413000000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 138000000,
+ "dvfs,maximum_frequency_khz" : 138000000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 138000000,
+ "dvfs,maximum_frequency_khz" : 275000000
+ }, {
+ "level" : 3,
+ "dvfs,minimum_frequency_khz" : 413000000,
+ "dvfs,maximum_frequency_khz" : 413000000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 3
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 1
+ }, {
+ "name" : "Doze",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 3
+ }
+ ],
+
+ "thermal_support" : false,
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 200000000,
+ "dvfs,maximum_frequency_khz" : 600000000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 200000000,
+ "dvfs,maximum_frequency_khz" : 200000000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 200000000,
+ "dvfs,maximum_frequency_khz" : 400000000
+ }, {
+ "level" : 3,
+ "dvfs,minimum_frequency_khz" : 400000000,
+ "dvfs,maximum_frequency_khz" : 400000000
+ }, {
+ "level" : 4,
+ "dvfs,minimum_frequency_khz" : 600000000,
+ "dvfs,maximum_frequency_khz" : 600000000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 3
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 1
+ }, {
+ "name" : "Doze",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 4
+ }
+ ],
+
+ "thermal_support" : false,
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 1500000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 600000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 1
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 75, "threshold": 72},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 75, "end": 80, "threshold": 77 },
+ "timer_interval_ms" : 3000,
+ "target_level" : 0
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 80, "end": 85, "threshold": 82 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 85, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 1500000,
+ "dvfs,maximum_frequency_khz" : 1500000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 600000,
+ "dvfs,maximum_frequency_khz" : 600000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 1
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 2
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 75, "threshold": 72},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 75, "end": 80, "threshold": 77 },
+ "timer_interval_ms" : 3000,
+ "target_level" : 0
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 80, "end": 85, "threshold": 82 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 85, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 2
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "dvfs,minimum_frequency_khz" : 100000000,
+ "dvfs,maximum_frequency_khz" : 800000000
+ }, {
+ "level" : 1,
+ "dvfs,minimum_frequency_khz" : 100000000,
+ "dvfs,maximum_frequency_khz" : 200000000
+ }, {
+ "level" : 2,
+ "dvfs,minimum_frequency_khz" : 600000000,
+ "dvfs,maximum_frequency_khz" : 80000000
+ }, {
+ "level" : 3,
+ "dvfs,minimum_frequency_khz" : 100000000,
+ "dvfs,maximum_frequency_khz" : 400000000
+ }, {
+ "level" : 4,
+ "dvfs,minimum_frequency_khz" : 100000000,
+ "dvfs,maximum_frequency_khz" : 600000000
+ }, {
+ "level" : 5,
+ "dvfs,minimum_frequency_khz" : 800000000,
+ "dvfs,maximum_frequency_khz" : 800000000
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list":
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 2
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 1
+ }, {
+ "name" : "Doze",
+ "target_level" : 3
+ }, {
+ "name" : "Performance",
+ "target_level" : 2
+ }
+ ],
+
+ "thermal_support" : true,
+ "thermal_timer_interval_ms" : 5000,
+ "thermal_scenario_list":
+ [
+ {
+ "name" : "Release",
+ "temperature" : { "start": 0, "end": 75, "threshold": 72},
+ "timer_interval_ms" : 5000,
+ "target_level" : 0
+ }, {
+ "name" : "Warning",
+ "temperature" : { "start": 75, "end": 85, "threshold": 77 },
+ "timer_interval_ms" : 3000,
+ "target_level" : 0
+ }, {
+ "name" : "LimitAction",
+ "temperature" : { "start": 85, "end": 95, "threshold": 87 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 4
+ }, {
+ "name" : "Shutdown",
+ "temperature" : { "start": 95, "end": 100 },
+ "timer_interval_ms" : 1000,
+ "target_level" : 3
+ }
+ ],
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "support" : true,
+ "init_level" : 0,
+ "level_list" :
+ [
+ {
+ "level" : 0,
+ "memory,fault_around_bytes" : 4096
+ }, {
+ "level" : 1,
+ "memory,fault_around_bytes" : 65536
+ }
+ ],
+
+ "pmqos_support" : true,
+ "pmqos_scenario_list" :
+ [
+ {
+ "name" : "AppLaunch",
+ "target_level" : 0
+ }, {
+ "name" : "UltraPowerSaving",
+ "target_level" : 0
+ }, {
+ "name" : "Performance",
+ "target_level" : 1
+ }
+ ],
+
+ "thermal_support" : false,
+
+ "cpuhp_support" : false
+}
--- /dev/null
+{
+ "device_list" :
+ [
+ {
+ "device_type" : "cpu",
+ "device_name" : "cpu0",
+ "device_config_path" : "./scripts/valid/pass-cpu0.json",
+ "thermal_device_name" : "thermal_zone0",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 0
+ }, {
+ "device_type" : "cpu",
+ "device_name" : "cpu4",
+ "device_config_path" : "./scripts/valid/pass-cpu4.json",
+ "thermal_device_name" : "thermal_zone1",
+ "cpu,number_of_cpus" : 4,
+ "cpu,first_cpu" : 4
+ }, {
+ "device_type" : "bus",
+ "device_name" : "devfreq0",
+ "device_config_path" : "./scripts/valid/pass-bus0.json",
+ "thermal_device_name" : null
+ }, {
+ "device_type" : "bus",
+ "device_name" : "devfreq5",
+ "device_config_path" : "./scripts/valid/pass-bus1.json",
+ "thermal_device_name" : null
+ }, {
+ "device_type" : "gpu",
+ "device_name" : "devfreq10",
+ "device_config_path" : "./scripts/valid/pass-gpu.json",
+ "thermal_device_name" : "thermal_zone3"
+ }, {
+ "device_type" : "memory",
+ "device_name" : "memory",
+ "device_config_path" : "./scripts/valid/pass-memory.json"
+ }, {
+ "device_type" : "battery",
+ "device_name" : "battery",
+ "device_config_path" : "./scripts/valid/pass-battery.json",
+ "thermal_device_name" : "thermal_zone5",
+ "cooling_device_name" : null
+ }
+ ]
+}
+++ /dev/null
-/*
- * Copyright (C) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iostream>
-#include <unistd.h>
-
-#include <gio/gio.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-extern "C" {
-#include <util/common.h>
-
-#include "pass.h"
-#include "pass-hal.h"
-#include "pass-parser.h"
-}
-
-#include "hal-api-power-mock.hpp"
-
-#define FREQ_100MZ 100000
-#define CHARGING_CURRNT_1A 1000000
-#define DEFAULT_MINUS_INT -1
-#define DEFAULT_UP_THRESHOLD 90
-
-using namespace std;
-using ::testing::Return;
-using ::testing::_;
-
-class PassHalTest : public testing::Test {
-public:
- void SetUp() override {
- gHalApiPowerMock = new HalApiPowerMock();
- }
-
- void TearDown() override {
- if (!gHalApiPowerMock)
- return;
-
- delete gHalApiPowerMock;
- gHalApiPowerMock = NULL;
- }
-};
-
-TEST_F(PassHalTest, pass_hal_get_resource) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock,
- hal_power_get_backend(_)).WillRepeatedly(Return(0));
-
- ret = pass_hal_get_resource(&res);
- EXPECT_EQ(ret, 0);
-
- ret = pass_hal_get_resource(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_put_resource) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock,
- hal_power_put_backend()).WillRepeatedly(Return(0));
-
- ret = pass_hal_put_resource(&res);
- EXPECT_EQ(ret, 0);
-
- ret = pass_hal_put_resource(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_curr_governor) {
- struct pass_resource res;
- char buf[BUFF_MAX];
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_curr_governor(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_curr_governor(&res, buf);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_curr_governor(&res, NULL);
- EXPECT_NE(ret, 0);
- ret = pass_hal_get_curr_governor(NULL, buf);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_curr_governor) {
- struct pass_resource res;
- char buf[BUFF_MAX];
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_curr_governor(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_curr_governor(&res, buf);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_curr_governor(&res, NULL);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_curr_governor(NULL, buf);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_curr_freq) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_curr_freq(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_curr_freq(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_curr_freq(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_min_freq) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_min_freq(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_min_freq(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_min_freq(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_min_freq) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_min_freq(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_min_freq(&res, FREQ_100MZ);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_min_freq(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_min_freq(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_max_freq) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_max_freq(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_max_freq(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_max_freq(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_max_freq) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_max_freq(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_max_freq(&res, FREQ_100MZ);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_max_freq(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_max_freq(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_available_min_freq) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_available_min_freq(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_available_min_freq(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_available_min_freq(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_available_max_freq) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_available_max_freq(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_available_max_freq(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_available_max_freq(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_up_threshold) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_get_up_threshold(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_up_threshold(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_up_threshold(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_up_threshold) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_dvfs_set_up_threshold(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_up_threshold(&res, DEFAULT_UP_THRESHOLD);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_up_threshold(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_up_threshold(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_online_state) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_state(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_online_state(&res, 0);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_online_state(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_get_online_state(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_online_state) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_state(_, _, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_online_state(&res, 0, 1);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_online_state(&res, 0, 0);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_online_state(&res, 0, 10);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_online_state(&res, DEFAULT_MINUS_INT, 1);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_online_state(&res, 0, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_online_state(NULL, DEFAULT_MINUS_INT, 1);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_online_min_num) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_min_num (_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_online_min_num(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_online_min_num(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_online_min_num) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_min_num (_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_online_min_num(&res, 1);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_online_min_num(NULL, 2);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_online_min_num(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_online_max_num) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_get_online_max_num (_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_online_max_num(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_online_max_num(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_online_max_num) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_hotplug_set_online_max_num (_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_online_max_num(&res, 1);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_online_max_num(NULL, 2);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_online_max_num(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_temp) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_temp(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_temp(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_temp(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_tmu_policy) {
- struct pass_resource res;
- char buf[BUFF_MAX];
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_policy(_, _,_))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_tmu_policy(&res, buf);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_tmu_policy(&res, NULL);
- EXPECT_NE(ret, 0);
- ret = pass_hal_get_tmu_policy(NULL, buf);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_cooling_device_state) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_get_cooling_device_state(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_cooling_device_state(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_cooling_device_state(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_cooling_device_state) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_thermal_set_cooling_device_state(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_cooling_device_state(&res, 1);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_cooling_device_state(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_cooling_device_state(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_battery_charging_status) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_get_charging_status(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_battery_charging_status(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_battery_charging_status(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_battery_charging_status) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_set_charging_status(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_battery_charging_status(&res, 0);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_battery_charging_status(&res, 1);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_battery_charging_status(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_battery_charging_status(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_battery_charging_current) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_get_charging_current(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_battery_charging_current(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_battery_charging_current(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_battery_charging_current) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_battery_set_charging_current(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_battery_charging_current(&res, CHARGING_CURRNT_1A);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_battery_charging_current(&res, 0);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_battery_charging_current(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_battery_charging_current(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_get_fault_around_bytes) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_memory_get_fault_around_bytes(_, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_get_fault_around_bytes(&res);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_get_fault_around_bytes(NULL);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_fault_around_bytes) {
- struct pass_resource res;
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_memory_set_fault_around_bytes(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_fault_around_bytes(&res, FREQ_100MZ);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_fault_around_bytes(&res, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_fault_around_bytes(NULL, DEFAULT_MINUS_INT);
- EXPECT_NE(ret, 0);
-}
-
-TEST_F(PassHalTest, pass_hal_set_pmqos_data) {
- struct pass_resource res;
- char buf[BUFF_MAX];
- int ret;
-
- EXPECT_CALL(*gHalApiPowerMock, hal_power_misc_set_pmqos_data(_, _, _))
- .WillRepeatedly(Return(0));
-
- ret = pass_hal_set_pmqos_data(&res, (void *)buf);
- EXPECT_EQ(ret, 0);
- ret = pass_hal_set_pmqos_data(NULL, (void *)buf);
- EXPECT_NE(ret, 0);
- ret = pass_hal_set_pmqos_data(NULL, NULL);
- EXPECT_NE(ret, 0);
-}
-
-/* Unittest of pass-parser module */
-class PassParserTest : public testing::Test {
-public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-};
-
-TEST(PassParserTest, pass_parser_get_resource_config_valid) {
- struct pass pass;
- const char path_json[] = "./scripts/valid/pass.json";
-
- int ret = pass_parser_get_resource_config(&pass, path_json);
- ASSERT_EQ(ret, 0);
-
- pass_parser_put_resource_config(&pass);
-}
-
-TEST(PassParserTest, pass_parser_get_resource_config_invalid) {
- struct pass pass;
- const char path_json[] = "./scripts/invalid/pass.json";
-
- int ret = pass_parser_get_resource_config(&pass, path_json);
- EXPECT_NE(ret, 0);
-}
-
-TEST(PassParserTest, pass_parser_get_each_resource_config_valid) {
- struct pass pass;
- const char path_json[] = "./scripts/valid/pass.json";
- int i;
-
- int ret = pass_parser_get_resource_config(&pass, path_json);
- ASSERT_EQ(ret, 0);
-
- for (i = 0; i < (int)pass.num_resources; i++) {
- struct pass_resource *res = &pass.res[i];
- ret = pass_parser_get_each_resource_config(res,
- res->config_data.path_conf_file);
- EXPECT_EQ(ret, 0);
- if (ret < 0)
- break;
- }
-
- for (i--; i >= 0; i--)
- pass_parser_put_each_resource_config(&pass.res[i]);
- pass_parser_put_resource_config(&pass);
-}
-
-class ResourceConfigInvalid {
-public:
- const char *path_json;
-
- ResourceConfigInvalid(
- const char *path_json_) :
- path_json(path_json_) {}
-};
-
-class PassParserInvalidTest : public ::testing::TestWithParam<ResourceConfigInvalid> {};
-
-INSTANTIATE_TEST_CASE_P (PassParserTest, PassParserInvalidTest,
- ::testing::Values (
- ResourceConfigInvalid ("./scripts/invalid-level/pass.json"),
- ResourceConfigInvalid ("./scripts/invalid-pmqos/pass.json"),
- ResourceConfigInvalid ("./scripts/invalid-thermal/pass.json"),
- ResourceConfigInvalid ("./scripts/invalid-thermal/pass1.json"),
- ResourceConfigInvalid ("./scripts/invalid-header/pass.json"),
- ResourceConfigInvalid ("./scripts/invalid-battery/pass.json"),
- ResourceConfigInvalid ("./scripts/invalid-memory/pass.json")
-));
-
-TEST_P(PassParserInvalidTest, pass_parser_get_each_resource_config_invalid) {
- auto param = GetParam();
- struct pass pass;
- unsigned int i;
-
- int ret = pass_parser_get_resource_config(&pass, param.path_json);
- EXPECT_EQ(ret, 0);
-
- for (i = 0; i < pass.num_resources; i++) {
- struct pass_resource *res = &pass.res[i];
- ret = pass_parser_get_each_resource_config(res,
- res->config_data.path_conf_file);
- EXPECT_NE(ret, 0);
- }
-
- for (i = 0; i < pass.num_resources; i++)
- pass_parser_put_each_resource_config(&pass.res[i]);
- pass_parser_put_resource_config(&pass);
-}
-
-int main(int argc, char *argv[])
-{
- try {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
- } catch (...) {
- return EXIT_FAILURE;
- }
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- //"battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
- //"battery_charging_currnt_uA" : 2048000
- }, {
- "level" : 1,
- //"battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
- //"battery,charging_currnt_uA" : 1024000
- }, {
- //"level" : 2,
- //"battery,charging_status" : 3, // POWER_SUPPLY_STATUS_NOT_CHARGING
- //"battery,charging_currnt_uA" : 1024000
- }
- ],
-
- "pmqos_support" : false,
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 45, "threshold": 42},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 45, "end": 50, "threshold": 47},
- "timer_interval_ms" : 3000,
- "target_level" : 1
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 50, "end": 55, "threshold": 52},
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 55, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "battery",
- "device_name" : "battery",
- "device_config_path" : "./scripts/invalid-battery/pass-battery.json",
- "thermal_device_name" : "thermal_zone5",
- "cooling_device_name" : null
- }
- ]
-}
+++ /dev/null
-{
- "support" : true,
- //"init_level" : 0,
- //"level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 138000000,
- "dvfs,maximum_frequency_khz" : 413000000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 138000000,
- "dvfs,maximum_frequency_khz" : 138000000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 138000000,
- "dvfs,maximum_frequency_khz" : 275000000
- }, {
- "level" : 3,
- "dvfs,minimum_frequency_khz" : 413000000,
- "dvfs,maximum_frequency_khz" : 413000000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 3
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 1
- }, {
- "name" : "Doze",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 3
- }
- ],
-
- "thermal_support" : false,
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "bus",
- "device_name" : "devfreq0",
- "device_config_path" : "./scripts/invalid-bus/pass-bus0.json",
- "thermal_device_name" : null
- }
- ]
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 1500000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- //"level" : 2,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 600000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 1
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 75, "threshold": 72},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 75, "end": 80, "threshold": 77 },
- "timer_interval_ms" : 3000,
- "target_level" : 0
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 80, "end": 85, "threshold": 82 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 85, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "cpu",
- "device_name" : "cpu0",
- "device_config_path" : "./scripts/invalid-level/pass-cpu0.json",
- "thermal_device_name" : "thermal_zone0",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 0
- }
- ]
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "memory,fault_around_bytes" : 4096
- }, {
- //"level" : 1,
- //"memory,fault_around_bytes" : 65536
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list" :
- [
- {
- "name" : "AppLaunch",
- "target_level" : 0
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 0
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : false,
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "memory",
- "device_name" : "memory",
- "device_config_path" : "./scripts/invalid-memory/pass-memory.json"
- }
- ]
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 1500000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 600000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 1
- }, {
- //"name" : "UltraPowerSaving",
- //"target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 75, "threshold": 72},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 75, "end": 80, "threshold": 77 },
- "timer_interval_ms" : 3000,
- "target_level" : 0
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 80, "end": 85, "threshold": 82 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 85, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "cpu",
- "device_name" : "cpu0",
- "device_config_path" : "./scripts/invalid-pmqos/pass-cpu0.json",
- "thermal_device_name" : "thermal_zone0",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 0
- }
- ]
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 1500000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 600000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 1
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 75, "threshold": 72},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- //"name" : "Warning",
- //"temperature" : { "start": 75, "end": 80, "threshold": 77 },
- //"timer_interval_ms" : 3000,
- //"target_level" : 0
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 80, "end": 85, "threshold": 82 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 85, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 1500000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 600000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 1
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 75, "threshold": 72},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 75, "end": 80, "threshold": 77 },
- "timer_interval_ms" : 3000,
- "target_level" : 0
- }, {
- "name" : "LimitAction",
- "temperature" :
- {
- //"start": 80, "end": 85, "threshold": 82
- },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 85, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "cpu",
- "device_name" : "cpu0",
- "device_config_path" : "./scripts/invalid-thermal/pass-cpu.json",
- "thermal_device_name" : "thermal_zone0",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 0
- }
- ]
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "cpu",
- "device_name" : "cpu0",
- "device_config_path" : "./scripts/invalid-thermal/pass-cpu1.json",
- "thermal_device_name" : "thermal_zone0",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 0
- }
- ]
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- //"device_type" : "cpu",
- //"device_name" : "cpu0",
- //"device_config_path" : "./scripts/valid/pass-cpu0.json",
- "thermal_device_name" : "thermal_zone0",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 0
- }, {
- //"device_type" : "cpu",
- "device_name" : "cpu4",
- "device_config_path" : "./scripts/valid/pass-cpu4.json",
- "thermal_device_name" : "thermal_zone1",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 4
- }, {
- "device_type" : "bus",
- "device_name" : "devfreq0",
- //"device_config_path" : "./scripts/valid/pass-bus.json",
- "thermal_device_name" : null
- }, {
- "device_type" : "bus",
- //"device_name" : "devfreq5",
- "device_config_path" : "./scripts/valid/pass-bus1.json",
- "thermal_device_name" : null
- }, {
- "device_type" : "gpu",
- "device_name" : "devfreq10",
- //"device_config_path" : "./scripts/vaild/pass-gpu.json",
- "thermal_device_name" : "thermal_zone3"
- }, {
- "device_type" : "memory",
- "device_name" : "memory",
- //"device_config_path" : "./scripts/valid/pass-memory.json"
- }, {
- "device_type" : "battery",
- //"device_name" : "battery",
- "device_config_path" : "./scripts/valid/pass-battery.json",
- "thermal_device_name" : "thermal_zone5",
- "cooling_device_name" : null
- }
- ]
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
- "battery_charging_currnt_uA" : 2048000
- }, {
- "level" : 1,
- "battery,charging_status" : 0, // POWER_SUPPLY_STATUS_UNKNOWN
- "battery,charging_currnt_uA" : 1024000
- }, {
- "level" : 2,
- "battery,charging_status" : 3, // POWER_SUPPLY_STATUS_NOT_CHARGING
- "battery,charging_currnt_uA" : 1024000
- }
- ],
-
- "pmqos_support" :false,
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 45, "threshold": 42},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 45, "end": 50, "threshold": 47},
- "timer_interval_ms" : 3000,
- "target_level" : 1
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 50, "end": 55, "threshold": 52},
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 55, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 138000000,
- "dvfs,maximum_frequency_khz" : 413000000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 138000000,
- "dvfs,maximum_frequency_khz" : 138000000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 138000000,
- "dvfs,maximum_frequency_khz" : 275000000
- }, {
- "level" : 3,
- "dvfs,minimum_frequency_khz" : 413000000,
- "dvfs,maximum_frequency_khz" : 413000000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 3
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 1
- }, {
- "name" : "Doze",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 3
- }
- ],
-
- "thermal_support" : false,
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 200000000,
- "dvfs,maximum_frequency_khz" : 600000000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 200000000,
- "dvfs,maximum_frequency_khz" : 200000000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 200000000,
- "dvfs,maximum_frequency_khz" : 400000000
- }, {
- "level" : 3,
- "dvfs,minimum_frequency_khz" : 400000000,
- "dvfs,maximum_frequency_khz" : 400000000
- }, {
- "level" : 4,
- "dvfs,minimum_frequency_khz" : 600000000,
- "dvfs,maximum_frequency_khz" : 600000000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 3
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 1
- }, {
- "name" : "Doze",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 4
- }
- ],
-
- "thermal_support" : false,
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 1500000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 600000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 1
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 75, "threshold": 72},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 75, "end": 80, "threshold": 77 },
- "timer_interval_ms" : 3000,
- "target_level" : 0
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 80, "end": 85, "threshold": 82 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 85, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 1500000,
- "dvfs,maximum_frequency_khz" : 1500000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 600000,
- "dvfs,maximum_frequency_khz" : 600000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 1
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 2
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 75, "threshold": 72},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 75, "end": 80, "threshold": 77 },
- "timer_interval_ms" : 3000,
- "target_level" : 0
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 80, "end": 85, "threshold": 82 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 85, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 2
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "dvfs,minimum_frequency_khz" : 100000000,
- "dvfs,maximum_frequency_khz" : 800000000
- }, {
- "level" : 1,
- "dvfs,minimum_frequency_khz" : 100000000,
- "dvfs,maximum_frequency_khz" : 200000000
- }, {
- "level" : 2,
- "dvfs,minimum_frequency_khz" : 600000000,
- "dvfs,maximum_frequency_khz" : 80000000
- }, {
- "level" : 3,
- "dvfs,minimum_frequency_khz" : 100000000,
- "dvfs,maximum_frequency_khz" : 400000000
- }, {
- "level" : 4,
- "dvfs,minimum_frequency_khz" : 100000000,
- "dvfs,maximum_frequency_khz" : 600000000
- }, {
- "level" : 5,
- "dvfs,minimum_frequency_khz" : 800000000,
- "dvfs,maximum_frequency_khz" : 800000000
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list":
- [
- {
- "name" : "AppLaunch",
- "target_level" : 2
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 1
- }, {
- "name" : "Doze",
- "target_level" : 3
- }, {
- "name" : "Performance",
- "target_level" : 2
- }
- ],
-
- "thermal_support" : true,
- "thermal_timer_interval_ms" : 5000,
- "thermal_scenario_list":
- [
- {
- "name" : "Release",
- "temperature" : { "start": 0, "end": 75, "threshold": 72},
- "timer_interval_ms" : 5000,
- "target_level" : 0
- }, {
- "name" : "Warning",
- "temperature" : { "start": 75, "end": 85, "threshold": 77 },
- "timer_interval_ms" : 3000,
- "target_level" : 0
- }, {
- "name" : "LimitAction",
- "temperature" : { "start": 85, "end": 95, "threshold": 87 },
- "timer_interval_ms" : 1000,
- "target_level" : 4
- }, {
- "name" : "Shutdown",
- "temperature" : { "start": 95, "end": 100 },
- "timer_interval_ms" : 1000,
- "target_level" : 3
- }
- ],
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "support" : true,
- "init_level" : 0,
- "level_list" :
- [
- {
- "level" : 0,
- "memory,fault_around_bytes" : 4096
- }, {
- "level" : 1,
- "memory,fault_around_bytes" : 65536
- }
- ],
-
- "pmqos_support" : true,
- "pmqos_scenario_list" :
- [
- {
- "name" : "AppLaunch",
- "target_level" : 0
- }, {
- "name" : "UltraPowerSaving",
- "target_level" : 0
- }, {
- "name" : "Performance",
- "target_level" : 1
- }
- ],
-
- "thermal_support" : false,
-
- "cpuhp_support" : false
-}
+++ /dev/null
-{
- "device_list" :
- [
- {
- "device_type" : "cpu",
- "device_name" : "cpu0",
- "device_config_path" : "./scripts/valid/pass-cpu0.json",
- "thermal_device_name" : "thermal_zone0",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 0
- }, {
- "device_type" : "cpu",
- "device_name" : "cpu4",
- "device_config_path" : "./scripts/valid/pass-cpu4.json",
- "thermal_device_name" : "thermal_zone1",
- "cpu,number_of_cpus" : 4,
- "cpu,first_cpu" : 4
- }, {
- "device_type" : "bus",
- "device_name" : "devfreq0",
- "device_config_path" : "./scripts/valid/pass-bus0.json",
- "thermal_device_name" : null
- }, {
- "device_type" : "bus",
- "device_name" : "devfreq5",
- "device_config_path" : "./scripts/valid/pass-bus1.json",
- "thermal_device_name" : null
- }, {
- "device_type" : "gpu",
- "device_name" : "devfreq10",
- "device_config_path" : "./scripts/valid/pass-gpu.json",
- "thermal_device_name" : "thermal_zone3"
- }, {
- "device_type" : "memory",
- "device_name" : "memory",
- "device_config_path" : "./scripts/valid/pass-memory.json"
- }, {
- "device_type" : "battery",
- "device_name" : "battery",
- "device_config_path" : "./scripts/valid/pass-battery.json",
- "thermal_device_name" : "thermal_zone5",
- "cooling_device_name" : null
- }
- ]
-}