tests: Move test code into tests directory and redefine the test role 71/276571/4
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 17 Jun 2022 09:03:11 +0000 (18:03 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 23 Jun 2022 06:08:11 +0000 (15:08 +0900)
 Move test code into tests directory and redefine the test role as
 following because unittest will be added for each module.
- intergraion test : Test the public interface of PASS daemon
- haltest : Test the HAL interface of PASS daemon

Change-Id: Ief0d07b38491454dc0dbb06a268e5c56de31a886
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt
packaging/pass.spec
tests/haltest/CMakeLists.txt [new file with mode: 0644]
tests/haltest/power-haltests.cpp [new file with mode: 0644]
tests/integration-test/CMakeLists.txt [new file with mode: 0644]
tests/integration-test/pass-tests.cpp [new file with mode: 0644]
unittest/CMakeLists.txt [deleted file]
unittest/pass-unittests.cpp [deleted file]
unittest/power-haltests.cpp [deleted file]

index 517d855ae5d43feb93eec0526087f14419b4345f..6116b4684c4e0c527052f502679d99c71ac0d1ce 100644 (file)
@@ -1,5 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(pass C)
+PROJECT(pass)
 
 ########################################################
 # PASS CMakeLists.txt
@@ -130,5 +130,6 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/systemd/ DESTINATION lib/systemd/s
                PATTERN "${PROJECT_NAME}.service"
                )
 
-ADD_SUBDIRECTORY(unittest)
+ADD_SUBDIRECTORY(tests/integration-test)
+ADD_SUBDIRECTORY(tests/haltest)
 ADD_SUBDIRECTORY(lib)
index 7c64eaed739a51f24c8ad8f05aee1797cd2e143d..29a506e533138e963a138e408e8d7af2015c86ee 100644 (file)
@@ -123,7 +123,7 @@ systemctl daemon-reload
 
 %files -n %{unittest_name}
 %defattr(-,root,root,-)
-%{_bindir}/pass-unittests
+%{_bindir}/pass-tests
 
 %files -n %{libpass_resource_monitor_name}
 %license LICENSE
diff --git a/tests/haltest/CMakeLists.txt b/tests/haltest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1f0e9a3
--- /dev/null
@@ -0,0 +1,37 @@
+PROJECT(pass C CXX)
+
+SET(SRCS ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c
+       ${CMAKE_SOURCE_DIR}/src/pass/pass-parser.c
+       ${CMAKE_SOURCE_DIR}/src/util/common.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/pass)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(gtest_pkgs REQUIRED
+       glib-2.0
+       gio-2.0
+       gmock
+       dlog
+       json-c
+       hal-api-power
+)
+
+FOREACH(flag ${gtest_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+SET(src ${CMAKE_SOURCE_DIR}/tests/haltest/power-haltests.cpp)
+GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+MESSAGE("${src_name}")
+ADD_EXECUTABLE(${src_name} ${SRCS} ${src})
+TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal)
+INSTALL(TARGETS ${src_name} DESTINATION /usr/bin/hal)
diff --git a/tests/haltest/power-haltests.cpp b/tests/haltest/power-haltests.cpp
new file mode 100644 (file)
index 0000000..bf91eaa
--- /dev/null
@@ -0,0 +1,573 @@
+/*
+ * Copyright (C) 2018 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 <stdlib.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+
+#include <util/gdbus-definition.h>
+
+extern "C" {
+#include "pass-hal.h"
+#include "pass-parser.h"
+}
+
+using namespace std;
+
+class PowerHaltest : public testing::Test {
+       public:
+               virtual void SetUp() {}
+               virtual void TearDown() {}
+};
+
+static struct pass g_pass;
+
+static int haltest_is_failed(struct pass_resource *res, int ret)
+{
+       char *res_name = res->config_data.res_name;
+       /*
+        * If -EPERM, function is not supported according to h/w resource type.
+        * And if -ENOTSUP, function is not implemented on hal package.
+        * It means that this function is not necessary on two error case
+        * when calling the HAL functions.
+        */
+       if (ret < 0) {
+               if (ret == -EPERM || ret == -ENOTSUP)
+                       return 0;
+
+               cout << "Failed to test HAL of '" << res_name << "'" << endl;
+               return 1;
+       }
+       return 0;
+}
+
+static gint32 pass_test_method_call(const gchar *path, const gchar *intf,
+                                       const gchar *method, GVariant *body)
+{
+       const gchar *type;
+       GVariant *ret;
+       GError *err = NULL;
+       GDBusMessage *msg, *reply;
+       GDBusConnection *conn;
+       gint32 r;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (err)
+               return -1;
+
+       msg = g_dbus_message_new_method_call(DBUS_PASS_BUS_NAME, path,
+                                                       intf, method);
+       if (!msg)
+               return -1;
+
+       if (body)
+               g_dbus_message_set_body(msg, body);
+
+       reply = g_dbus_connection_send_message_with_reply_sync(conn, msg,
+                                               G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+                                               G_MAXINT, NULL, NULL, &err);
+       if (err) {
+               g_object_unref(msg);
+               g_clear_error(&err);
+               return -1;
+       }
+
+       ret = g_variant_get_child_value(g_dbus_message_get_body(reply), 0);
+       type = g_variant_get_type_string(ret);
+       if (type[0] == 'i')
+               r = g_variant_get_int32(ret);
+       else
+               r = -1;
+
+       g_variant_unref(ret);
+
+       g_dbus_connection_flush(conn, NULL, NULL, NULL);
+       g_object_unref(msg);
+       g_object_unref(reply);
+       g_clear_error(&err);
+
+       return r;
+}
+
+TEST_F(PowerHaltest, GetResourceConfig_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+       char path_json[] = "/hal/etc/pass/pass.json";
+
+       /* Stop PASS daemon before HAL testing */
+       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
+                                       "stop", NULL);
+       ASSERT_EQ(ret, 0) << "PassServiceStop Failed";
+
+       ret = pass_parser_get_resource_config(&g_pass, path_json);
+       ASSERT_EQ(ret, 0) << "GetResourceConfig Failed";
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_resource(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetResourceConfig Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetCurrGovernor_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+       char governor[BUFF_MAX];
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_curr_governor(res, governor);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetCurrGovernor Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetCurrGovernor_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+       char governor[BUFF_MAX];
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_curr_governor(res, governor);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetCurrGovernor Failed";
+               }
+
+               ret = pass_hal_set_curr_governor(res, governor);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "SetCurrGovernor Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetCurrFreq_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_curr_freq(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetCurrFreq Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetMinFreq_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_min_freq(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetMinFreq Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetMinFreq_HandlesValidInput)
+{
+       int ret = 0;
+       int min_freq = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               min_freq = pass_hal_get_available_min_freq(res);
+               if (haltest_is_failed(res, min_freq)) {
+                       ASSERT_EQ(min_freq, 0) << "GetAvailableMinFreq Failed";
+               }
+
+               if (min_freq >= 0) {
+                       ret = pass_hal_set_min_freq(res, min_freq);
+                       if (haltest_is_failed(res, ret)) {
+                               ASSERT_EQ(ret, 0) << "SetMinFreq Failed";
+                       }
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetMaxFreq_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_max_freq(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetMaxFreq Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetMaxFreq_HandlesValidInput)
+{
+       int ret = 0;
+       int max_freq = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               max_freq = pass_hal_get_available_max_freq(res);
+               if (haltest_is_failed(res, max_freq)) {
+                       ASSERT_EQ(max_freq, 0) << "GetAvailableMaxFreq Failed";
+               }
+
+               if (max_freq >= 0) {
+                       ret = pass_hal_set_max_freq(res, max_freq);
+                       if (haltest_is_failed(res, ret)) {
+                               ASSERT_EQ(ret, 0) << "SetMaxFreq Failed";
+                       }
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetAvailableMinFreq_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_available_min_freq(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetAvailableMinFreq Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetAvailableMaxFreq_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_available_max_freq(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetAvailableMaxFreq Failed";
+               }
+       }
+}
+
+
+TEST_F(PowerHaltest, GetUpThreshold_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_up_threshold(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetUpThreshold Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetUpThreshold_HandlesValidInput)
+{
+       int ret = 0;
+       int up_threshold = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               up_threshold = pass_hal_get_up_threshold(res);
+               if (haltest_is_failed(res, up_threshold)) {
+                       ASSERT_EQ(up_threshold, 0) << "GetUpThreshold Failed";
+               }
+
+               if (up_threshold >= 0) {
+                       ret = pass_hal_set_up_threshold(res, up_threshold);
+                       if (haltest_is_failed(res, ret)) {
+                               ASSERT_EQ(ret, 0) << "SetUpThreshold Failed";
+                       }
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetTemperature_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_temp(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetTemperature Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetTmuPolicy_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+       char policy[BUFF_MAX];
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_tmu_policy(res, policy);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetTmuPolicy Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetOnlineState_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i, j;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               for (j = 0; j < res->config_data.num_cpus; j++) {
+                       ret = pass_hal_get_online_state(res, j);
+                       if (haltest_is_failed(res, ret)) {
+                               ASSERT_EQ(ret, 0) << "GetOnlineState Failed";
+                       }
+               }
+
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetOnlineState Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetOnlineState_HandlesValidInput)
+{
+       int ret = 0;
+       int online_state = 0;
+       unsigned int i, j;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               for (j = 0; j < res->config_data.num_cpus; j++) {
+                       online_state = pass_hal_get_online_state(res, j);
+                       if (haltest_is_failed(res, online_state)) {
+                               ASSERT_EQ(online_state, 0) << "GetOnlineState Failed";
+                       }
+
+                       if (online_state >= 0) {
+                               ret = pass_hal_set_online_state(res, j, online_state);
+                               if (haltest_is_failed(res, ret)) {
+                                       ASSERT_EQ(ret, 0) << "SetOnlineState Failed";
+                               }
+                       }
+               }
+       }
+}
+
+
+TEST_F(PowerHaltest, GetOnlineMinNum_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_online_min_num(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetOnlineMinNum Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetOnlineMinNum_HandlesValidInput)
+{
+       int ret = 0;
+       int online_min_num = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               online_min_num = pass_hal_get_online_min_num(res);
+               if (haltest_is_failed(res, online_min_num)) {
+                       ASSERT_EQ(online_min_num, 0) << "GetOnlineMinNum Failed";
+               }
+
+               if (online_min_num >= 0) {
+                       ret = pass_hal_set_online_min_num(res, online_min_num);
+                       if (haltest_is_failed(res, ret)) {
+                               ASSERT_EQ(ret, 0) << "SetOnlineMinNum Failed";
+                       }
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetOnlineMaxNum_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_online_max_num(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetOnlineMaxNum Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetOnlineMaxNum_HandlesValidInput)
+{
+       int ret = 0;
+       int online_max_num = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               online_max_num = pass_hal_get_online_max_num(res);
+               if (haltest_is_failed(res, online_max_num)) {
+                       ASSERT_EQ(online_max_num, 0) << "GetOnlineMaxNum Failed";
+               }
+
+               if (online_max_num >= 0) {
+                       ret = pass_hal_set_online_max_num(res, online_max_num);
+                       if (haltest_is_failed(res, ret)) {
+                               ASSERT_EQ(ret, 0) << "SetOnlineMaxNum Failed";
+                       }
+               }
+       }
+}
+
+TEST_F(PowerHaltest, GetFaultAroundBytes_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_get_fault_around_bytes(res);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "GetFaultAroundBytes Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetFaultAroundBytes_HandlesValidInput)
+{
+       int ret = 0;
+       int fault_around_bytes = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               fault_around_bytes = pass_hal_get_fault_around_bytes(res);
+               if (haltest_is_failed(res, fault_around_bytes)) {
+                       ASSERT_EQ(fault_around_bytes, 0) << "GetFaultAroundBytes Failed";
+               }
+
+               if (fault_around_bytes >= 0) {
+                       ret = pass_hal_set_fault_around_bytes(res, fault_around_bytes);
+                       if (haltest_is_failed(res, ret)) {
+                               ASSERT_EQ(ret, 0) << "SetFaultAroundBytes Failed";
+                       }
+               }
+       }
+}
+
+TEST_F(PowerHaltest, SetPmqosData_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+       char applaunch_scenario[] = "AppLaunch";
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_set_pmqos_data(res, applaunch_scenario);
+               if (haltest_is_failed(res, ret)) {
+                       ASSERT_EQ(ret, 0) << "SetPmqosData Failed";
+               }
+       }
+}
+
+TEST_F(PowerHaltest, PutResourceConfig_HandlesValidInput)
+{
+       int ret = 0;
+       unsigned int i;
+
+       for (i = 0; i < g_pass.num_resources; i++) {
+               struct pass_resource *res = &g_pass.res[i];
+
+               ret = pass_hal_put_resource(res);
+               if (ret < 0) {
+                       pass_parser_put_resource_config(&g_pass);
+
+                       /* Even if tc is failed, need to restart PASS daemon */
+                       pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
+                                       "start", NULL);
+                       ASSERT_EQ(ret, 0) << "PutResourceConfig Failed";
+               }
+       }
+
+       /* Restart PASS daemon before HAL testing */
+       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
+                                       "start", NULL);
+       ASSERT_EQ(ret, 0) << "PassServiceStart Failed";
+}
+
+int main(int argc, char *argv[])
+{
+       int ret;
+
+       try {
+               testing::InitGoogleTest(&argc, argv);
+               ret = RUN_ALL_TESTS();
+       } catch (...) {
+               ret = EXIT_FAILURE;
+       }
+
+       return ret;
+}
diff --git a/tests/integration-test/CMakeLists.txt b/tests/integration-test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2f12af5
--- /dev/null
@@ -0,0 +1,37 @@
+PROJECT(pass C CXX)
+
+SET(SRCS ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c
+       ${CMAKE_SOURCE_DIR}/src/pass/pass-parser.c
+       ${CMAKE_SOURCE_DIR}/src/util/common.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/pass)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(gtest_pkgs REQUIRED
+       glib-2.0
+       gio-2.0
+       gmock
+       dlog
+       json-c
+       hal-api-power
+)
+
+FOREACH(flag ${gtest_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+SET(src ${CMAKE_SOURCE_DIR}/tests/integration-test/pass-tests.cpp)
+GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+MESSAGE("${src_name}")
+ADD_EXECUTABLE(${src_name} ${SRCS} ${src})
+TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal)
+INSTALL(TARGETS ${src_name} DESTINATION /usr/bin/)
diff --git a/tests/integration-test/pass-tests.cpp b/tests/integration-test/pass-tests.cpp
new file mode 100644 (file)
index 0000000..af53948
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2018 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 <stdlib.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+
+#include <util/gdbus-definition.h>
+
+class PowerMgntTest : public testing::Test {
+public:
+       static void SetUpTestCase() {
+               int ret = 0;
+               ASSERT_EQ(ret, 0);
+       }
+       static void TearDownTestCase() {
+               int ret = 0;
+               ASSERT_EQ(ret, 0);
+       }
+       void TearDown() override {
+       }
+};
+
+static gint32 pass_test_method_call(const gchar *path, const gchar *intf,
+                                       const gchar *method, GVariant *body)
+{
+       const gchar *type;
+       GVariant *ret;
+       GError *err = NULL;
+       GDBusMessage *msg, *reply;
+       GDBusConnection *conn;
+       gint32 r;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (err)
+               return -1;
+
+       msg = g_dbus_message_new_method_call(DBUS_PASS_BUS_NAME, path,
+                                                       intf, method);
+       if (!msg)
+               return -1;
+
+       if (body)
+               g_dbus_message_set_body(msg, body);
+
+       reply = g_dbus_connection_send_message_with_reply_sync(conn, msg,
+                                               G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+                                               G_MAXINT, NULL, NULL, &err);
+       if (err) {
+               g_object_unref(msg);
+               g_clear_error(&err);
+               return -1;
+       }
+
+       ret = g_variant_get_child_value(g_dbus_message_get_body(reply), 0);
+       type = g_variant_get_type_string(ret);
+       if (type[0] == 'i')
+               r = g_variant_get_int32(ret);
+       else
+               r = -1;
+
+       g_variant_unref(ret);
+
+       g_dbus_connection_flush(conn, NULL, NULL, NULL);
+       g_object_unref(msg);
+       g_object_unref(reply);
+       g_clear_error(&err);
+
+       return r;
+}
+
+TEST_F(PowerMgntTest, PmqosSendDbus_HandlesValidAppLaunch)
+{
+       gint32 ret;
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                               DBUS_PMQOS_INTERFACE,
+                                               "AppLaunch",
+                                               g_variant_new("(i)", 3000));
+       ASSERT_EQ(ret, 0) << "AppLaunch Failed";
+}
+
+TEST_F(PowerMgntTest, PmqosSendDbus_HandlesValidMultipleAppLaunch)
+{
+       gint32 ret;
+       int i;
+
+       for (i = 0; i < 3; i++) {
+               ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                               DBUS_PMQOS_INTERFACE,
+                                               "AppLaunch",
+                                               g_variant_new("(i)", 3000));
+               ASSERT_EQ(ret, 0) << "MultipleAppLaunch Failed";
+       }
+}
+
+TEST_F(PowerMgntTest, PmqosSendDbus_HandlesValidUltraPowerSaving)
+{
+       gint32 ret;
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "AppLaunch",
+                                       g_variant_new("(i)", 3000));
+       ASSERT_EQ(ret, 0) << "AppLaunch Failed";
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "UltraPowerSaving",
+                                       g_variant_new("(i)", 3000));
+       ASSERT_EQ(ret, 0) << "UltraPowerSaving Failed";
+}
+
+TEST_F(PowerMgntTest, PmqosSendDbus_HandlesInvalidInput)
+{
+       gint32 ret;
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "stop",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PmQosStop Failed";
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "AppLaunch",
+                                       g_variant_new("(i)", 3000));
+       ASSERT_EQ(ret, -1) << "AppLaunch Failed";
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "start",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PmQosStart Failed";
+}
+
+TEST_F(PowerMgntTest, PmqosSendDbus_RestartsPmqos)
+{
+       gint32 ret;
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "start",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PmQosStart Failed";
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "stop",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PmQosStop Failed";
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "start",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PmQosStart Failed";
+
+       ret = pass_test_method_call(DBUS_PMQOS_PATH,
+                                       DBUS_PMQOS_INTERFACE,
+                                       "AppLaunch",
+                                       g_variant_new("(i)", 3000));
+       ASSERT_EQ(ret, 0) << "PmQosStop  Failed";
+}
+
+TEST_F(PowerMgntTest, ThermalMonitorSendDbus_RestartsThermalMonitor)
+{
+       gint32 ret;
+
+       ret = pass_test_method_call(DBUS_THERMAL_PATH,
+                                       DBUS_THERMAL_INTERFACE,
+                                       "start",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "ThermalMonitorStart Failed";
+
+       ret = pass_test_method_call(DBUS_THERMAL_PATH,
+                                       DBUS_THERMAL_INTERFACE,
+                                       "stop",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "ThermalMonitorStop Failed";
+
+       ret = pass_test_method_call(DBUS_THERMAL_PATH,
+                                       DBUS_THERMAL_INTERFACE,
+                                       "start",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "ThermalMonitorStart Failed";
+}
+
+TEST_F(PowerMgntTest, CoreSendDbus_RestartsCore)
+{
+       gint32 ret;
+
+       ret = pass_test_method_call(DBUS_CORE_PATH,
+                                       DBUS_CORE_INTERFACE,
+                                       "start",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PassCoreStart Failed";
+
+       ret = pass_test_method_call(DBUS_CORE_PATH,
+                                       DBUS_CORE_INTERFACE,
+                                       "stop",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PassCoreStop Failed";
+
+       ret = pass_test_method_call(DBUS_CORE_PATH,
+                                       DBUS_CORE_INTERFACE,
+                                       "start",
+                                       NULL);
+       ASSERT_EQ(ret, 0) << "PassCoreStart Failed";
+}
+
+TEST_F(PowerMgntTest, RestartsPowerMgntService)
+{
+       gint32 ret;
+
+       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
+                                       "start", NULL);
+       ASSERT_EQ(ret, 0) << "PassServiceStart Failed";
+
+       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
+                                       "stop", NULL);
+       ASSERT_EQ(ret, 0) << "PassServiceStop Failed";
+
+       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
+                                       "start", NULL);
+       ASSERT_EQ(ret, 0) << "PassServiceStart Failed";
+}
+
+int main(int argc, char *argv[])
+{
+       int ret;
+
+       try {
+               testing::InitGoogleTest(&argc, argv);
+               ret = RUN_ALL_TESTS();
+       } catch (...) {
+               ret = EXIT_FAILURE;
+       }
+
+       return ret;
+}
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
deleted file mode 100644 (file)
index 802fa58..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-PROJECT(pass C CXX)
-
-SET(SRCS ${CMAKE_SOURCE_DIR}/src/pass/pass-hal.c
-       ${CMAKE_SOURCE_DIR}/src/pass/pass-parser.c
-       ${CMAKE_SOURCE_DIR}/src/util/common.c
-)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/pass)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(gtest_pkgs REQUIRED
-       glib-2.0
-       gio-2.0
-       gmock
-       dlog
-       json-c
-       hal-api-power
-)
-
-FOREACH(flag ${gtest_pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE -fPIC")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-
-SET(src ${CMAKE_SOURCE_DIR}/unittest/power-haltests.cpp)
-GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
-MESSAGE("${src_name}")
-ADD_EXECUTABLE(${src_name} ${SRCS} ${src})
-TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal)
-INSTALL(TARGETS ${src_name} DESTINATION /usr/bin/hal)
-
-SET(src ${CMAKE_SOURCE_DIR}/unittest/pass-unittests.cpp)
-GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
-MESSAGE("${src_name}")
-ADD_EXECUTABLE(${src_name} ${SRCS} ${src})
-TARGET_LINK_LIBRARIES(${src_name} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl -L${LIBDIR}/hal)
-INSTALL(TARGETS ${src_name} DESTINATION /usr/bin/)
diff --git a/unittest/pass-unittests.cpp b/unittest/pass-unittests.cpp
deleted file mode 100644 (file)
index af53948..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2018 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 <stdlib.h>
-
-#include <gio/gio.h>
-#include <gtest/gtest.h>
-
-#include <util/gdbus-definition.h>
-
-class PowerMgntTest : public testing::Test {
-public:
-       static void SetUpTestCase() {
-               int ret = 0;
-               ASSERT_EQ(ret, 0);
-       }
-       static void TearDownTestCase() {
-               int ret = 0;
-               ASSERT_EQ(ret, 0);
-       }
-       void TearDown() override {
-       }
-};
-
-static gint32 pass_test_method_call(const gchar *path, const gchar *intf,
-                                       const gchar *method, GVariant *body)
-{
-       const gchar *type;
-       GVariant *ret;
-       GError *err = NULL;
-       GDBusMessage *msg, *reply;
-       GDBusConnection *conn;
-       gint32 r;
-
-       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (err)
-               return -1;
-
-       msg = g_dbus_message_new_method_call(DBUS_PASS_BUS_NAME, path,
-                                                       intf, method);
-       if (!msg)
-               return -1;
-
-       if (body)
-               g_dbus_message_set_body(msg, body);
-
-       reply = g_dbus_connection_send_message_with_reply_sync(conn, msg,
-                                               G_DBUS_SEND_MESSAGE_FLAGS_NONE,
-                                               G_MAXINT, NULL, NULL, &err);
-       if (err) {
-               g_object_unref(msg);
-               g_clear_error(&err);
-               return -1;
-       }
-
-       ret = g_variant_get_child_value(g_dbus_message_get_body(reply), 0);
-       type = g_variant_get_type_string(ret);
-       if (type[0] == 'i')
-               r = g_variant_get_int32(ret);
-       else
-               r = -1;
-
-       g_variant_unref(ret);
-
-       g_dbus_connection_flush(conn, NULL, NULL, NULL);
-       g_object_unref(msg);
-       g_object_unref(reply);
-       g_clear_error(&err);
-
-       return r;
-}
-
-TEST_F(PowerMgntTest, PmqosSendDbus_HandlesValidAppLaunch)
-{
-       gint32 ret;
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                               DBUS_PMQOS_INTERFACE,
-                                               "AppLaunch",
-                                               g_variant_new("(i)", 3000));
-       ASSERT_EQ(ret, 0) << "AppLaunch Failed";
-}
-
-TEST_F(PowerMgntTest, PmqosSendDbus_HandlesValidMultipleAppLaunch)
-{
-       gint32 ret;
-       int i;
-
-       for (i = 0; i < 3; i++) {
-               ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                               DBUS_PMQOS_INTERFACE,
-                                               "AppLaunch",
-                                               g_variant_new("(i)", 3000));
-               ASSERT_EQ(ret, 0) << "MultipleAppLaunch Failed";
-       }
-}
-
-TEST_F(PowerMgntTest, PmqosSendDbus_HandlesValidUltraPowerSaving)
-{
-       gint32 ret;
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "AppLaunch",
-                                       g_variant_new("(i)", 3000));
-       ASSERT_EQ(ret, 0) << "AppLaunch Failed";
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "UltraPowerSaving",
-                                       g_variant_new("(i)", 3000));
-       ASSERT_EQ(ret, 0) << "UltraPowerSaving Failed";
-}
-
-TEST_F(PowerMgntTest, PmqosSendDbus_HandlesInvalidInput)
-{
-       gint32 ret;
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "stop",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PmQosStop Failed";
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "AppLaunch",
-                                       g_variant_new("(i)", 3000));
-       ASSERT_EQ(ret, -1) << "AppLaunch Failed";
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "start",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PmQosStart Failed";
-}
-
-TEST_F(PowerMgntTest, PmqosSendDbus_RestartsPmqos)
-{
-       gint32 ret;
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "start",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PmQosStart Failed";
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "stop",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PmQosStop Failed";
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "start",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PmQosStart Failed";
-
-       ret = pass_test_method_call(DBUS_PMQOS_PATH,
-                                       DBUS_PMQOS_INTERFACE,
-                                       "AppLaunch",
-                                       g_variant_new("(i)", 3000));
-       ASSERT_EQ(ret, 0) << "PmQosStop  Failed";
-}
-
-TEST_F(PowerMgntTest, ThermalMonitorSendDbus_RestartsThermalMonitor)
-{
-       gint32 ret;
-
-       ret = pass_test_method_call(DBUS_THERMAL_PATH,
-                                       DBUS_THERMAL_INTERFACE,
-                                       "start",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "ThermalMonitorStart Failed";
-
-       ret = pass_test_method_call(DBUS_THERMAL_PATH,
-                                       DBUS_THERMAL_INTERFACE,
-                                       "stop",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "ThermalMonitorStop Failed";
-
-       ret = pass_test_method_call(DBUS_THERMAL_PATH,
-                                       DBUS_THERMAL_INTERFACE,
-                                       "start",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "ThermalMonitorStart Failed";
-}
-
-TEST_F(PowerMgntTest, CoreSendDbus_RestartsCore)
-{
-       gint32 ret;
-
-       ret = pass_test_method_call(DBUS_CORE_PATH,
-                                       DBUS_CORE_INTERFACE,
-                                       "start",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PassCoreStart Failed";
-
-       ret = pass_test_method_call(DBUS_CORE_PATH,
-                                       DBUS_CORE_INTERFACE,
-                                       "stop",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PassCoreStop Failed";
-
-       ret = pass_test_method_call(DBUS_CORE_PATH,
-                                       DBUS_CORE_INTERFACE,
-                                       "start",
-                                       NULL);
-       ASSERT_EQ(ret, 0) << "PassCoreStart Failed";
-}
-
-TEST_F(PowerMgntTest, RestartsPowerMgntService)
-{
-       gint32 ret;
-
-       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
-                                       "start", NULL);
-       ASSERT_EQ(ret, 0) << "PassServiceStart Failed";
-
-       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
-                                       "stop", NULL);
-       ASSERT_EQ(ret, 0) << "PassServiceStop Failed";
-
-       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
-                                       "start", NULL);
-       ASSERT_EQ(ret, 0) << "PassServiceStart Failed";
-}
-
-int main(int argc, char *argv[])
-{
-       int ret;
-
-       try {
-               testing::InitGoogleTest(&argc, argv);
-               ret = RUN_ALL_TESTS();
-       } catch (...) {
-               ret = EXIT_FAILURE;
-       }
-
-       return ret;
-}
diff --git a/unittest/power-haltests.cpp b/unittest/power-haltests.cpp
deleted file mode 100644 (file)
index bf91eaa..0000000
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- * Copyright (C) 2018 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 <stdlib.h>
-
-#include <gio/gio.h>
-#include <gtest/gtest.h>
-
-#include <util/gdbus-definition.h>
-
-extern "C" {
-#include "pass-hal.h"
-#include "pass-parser.h"
-}
-
-using namespace std;
-
-class PowerHaltest : public testing::Test {
-       public:
-               virtual void SetUp() {}
-               virtual void TearDown() {}
-};
-
-static struct pass g_pass;
-
-static int haltest_is_failed(struct pass_resource *res, int ret)
-{
-       char *res_name = res->config_data.res_name;
-       /*
-        * If -EPERM, function is not supported according to h/w resource type.
-        * And if -ENOTSUP, function is not implemented on hal package.
-        * It means that this function is not necessary on two error case
-        * when calling the HAL functions.
-        */
-       if (ret < 0) {
-               if (ret == -EPERM || ret == -ENOTSUP)
-                       return 0;
-
-               cout << "Failed to test HAL of '" << res_name << "'" << endl;
-               return 1;
-       }
-       return 0;
-}
-
-static gint32 pass_test_method_call(const gchar *path, const gchar *intf,
-                                       const gchar *method, GVariant *body)
-{
-       const gchar *type;
-       GVariant *ret;
-       GError *err = NULL;
-       GDBusMessage *msg, *reply;
-       GDBusConnection *conn;
-       gint32 r;
-
-       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if (err)
-               return -1;
-
-       msg = g_dbus_message_new_method_call(DBUS_PASS_BUS_NAME, path,
-                                                       intf, method);
-       if (!msg)
-               return -1;
-
-       if (body)
-               g_dbus_message_set_body(msg, body);
-
-       reply = g_dbus_connection_send_message_with_reply_sync(conn, msg,
-                                               G_DBUS_SEND_MESSAGE_FLAGS_NONE,
-                                               G_MAXINT, NULL, NULL, &err);
-       if (err) {
-               g_object_unref(msg);
-               g_clear_error(&err);
-               return -1;
-       }
-
-       ret = g_variant_get_child_value(g_dbus_message_get_body(reply), 0);
-       type = g_variant_get_type_string(ret);
-       if (type[0] == 'i')
-               r = g_variant_get_int32(ret);
-       else
-               r = -1;
-
-       g_variant_unref(ret);
-
-       g_dbus_connection_flush(conn, NULL, NULL, NULL);
-       g_object_unref(msg);
-       g_object_unref(reply);
-       g_clear_error(&err);
-
-       return r;
-}
-
-TEST_F(PowerHaltest, GetResourceConfig_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-       char path_json[] = "/hal/etc/pass/pass.json";
-
-       /* Stop PASS daemon before HAL testing */
-       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
-                                       "stop", NULL);
-       ASSERT_EQ(ret, 0) << "PassServiceStop Failed";
-
-       ret = pass_parser_get_resource_config(&g_pass, path_json);
-       ASSERT_EQ(ret, 0) << "GetResourceConfig Failed";
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_resource(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetResourceConfig Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetCurrGovernor_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-       char governor[BUFF_MAX];
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_curr_governor(res, governor);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetCurrGovernor Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetCurrGovernor_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-       char governor[BUFF_MAX];
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_curr_governor(res, governor);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetCurrGovernor Failed";
-               }
-
-               ret = pass_hal_set_curr_governor(res, governor);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "SetCurrGovernor Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetCurrFreq_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_curr_freq(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetCurrFreq Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetMinFreq_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_min_freq(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetMinFreq Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetMinFreq_HandlesValidInput)
-{
-       int ret = 0;
-       int min_freq = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               min_freq = pass_hal_get_available_min_freq(res);
-               if (haltest_is_failed(res, min_freq)) {
-                       ASSERT_EQ(min_freq, 0) << "GetAvailableMinFreq Failed";
-               }
-
-               if (min_freq >= 0) {
-                       ret = pass_hal_set_min_freq(res, min_freq);
-                       if (haltest_is_failed(res, ret)) {
-                               ASSERT_EQ(ret, 0) << "SetMinFreq Failed";
-                       }
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetMaxFreq_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_max_freq(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetMaxFreq Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetMaxFreq_HandlesValidInput)
-{
-       int ret = 0;
-       int max_freq = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               max_freq = pass_hal_get_available_max_freq(res);
-               if (haltest_is_failed(res, max_freq)) {
-                       ASSERT_EQ(max_freq, 0) << "GetAvailableMaxFreq Failed";
-               }
-
-               if (max_freq >= 0) {
-                       ret = pass_hal_set_max_freq(res, max_freq);
-                       if (haltest_is_failed(res, ret)) {
-                               ASSERT_EQ(ret, 0) << "SetMaxFreq Failed";
-                       }
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetAvailableMinFreq_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_available_min_freq(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetAvailableMinFreq Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetAvailableMaxFreq_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_available_max_freq(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetAvailableMaxFreq Failed";
-               }
-       }
-}
-
-
-TEST_F(PowerHaltest, GetUpThreshold_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_up_threshold(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetUpThreshold Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetUpThreshold_HandlesValidInput)
-{
-       int ret = 0;
-       int up_threshold = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               up_threshold = pass_hal_get_up_threshold(res);
-               if (haltest_is_failed(res, up_threshold)) {
-                       ASSERT_EQ(up_threshold, 0) << "GetUpThreshold Failed";
-               }
-
-               if (up_threshold >= 0) {
-                       ret = pass_hal_set_up_threshold(res, up_threshold);
-                       if (haltest_is_failed(res, ret)) {
-                               ASSERT_EQ(ret, 0) << "SetUpThreshold Failed";
-                       }
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetTemperature_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_temp(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetTemperature Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetTmuPolicy_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-       char policy[BUFF_MAX];
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_tmu_policy(res, policy);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetTmuPolicy Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetOnlineState_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i, j;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               for (j = 0; j < res->config_data.num_cpus; j++) {
-                       ret = pass_hal_get_online_state(res, j);
-                       if (haltest_is_failed(res, ret)) {
-                               ASSERT_EQ(ret, 0) << "GetOnlineState Failed";
-                       }
-               }
-
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetOnlineState Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetOnlineState_HandlesValidInput)
-{
-       int ret = 0;
-       int online_state = 0;
-       unsigned int i, j;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               for (j = 0; j < res->config_data.num_cpus; j++) {
-                       online_state = pass_hal_get_online_state(res, j);
-                       if (haltest_is_failed(res, online_state)) {
-                               ASSERT_EQ(online_state, 0) << "GetOnlineState Failed";
-                       }
-
-                       if (online_state >= 0) {
-                               ret = pass_hal_set_online_state(res, j, online_state);
-                               if (haltest_is_failed(res, ret)) {
-                                       ASSERT_EQ(ret, 0) << "SetOnlineState Failed";
-                               }
-                       }
-               }
-       }
-}
-
-
-TEST_F(PowerHaltest, GetOnlineMinNum_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_online_min_num(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetOnlineMinNum Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetOnlineMinNum_HandlesValidInput)
-{
-       int ret = 0;
-       int online_min_num = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               online_min_num = pass_hal_get_online_min_num(res);
-               if (haltest_is_failed(res, online_min_num)) {
-                       ASSERT_EQ(online_min_num, 0) << "GetOnlineMinNum Failed";
-               }
-
-               if (online_min_num >= 0) {
-                       ret = pass_hal_set_online_min_num(res, online_min_num);
-                       if (haltest_is_failed(res, ret)) {
-                               ASSERT_EQ(ret, 0) << "SetOnlineMinNum Failed";
-                       }
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetOnlineMaxNum_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_online_max_num(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetOnlineMaxNum Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetOnlineMaxNum_HandlesValidInput)
-{
-       int ret = 0;
-       int online_max_num = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               online_max_num = pass_hal_get_online_max_num(res);
-               if (haltest_is_failed(res, online_max_num)) {
-                       ASSERT_EQ(online_max_num, 0) << "GetOnlineMaxNum Failed";
-               }
-
-               if (online_max_num >= 0) {
-                       ret = pass_hal_set_online_max_num(res, online_max_num);
-                       if (haltest_is_failed(res, ret)) {
-                               ASSERT_EQ(ret, 0) << "SetOnlineMaxNum Failed";
-                       }
-               }
-       }
-}
-
-TEST_F(PowerHaltest, GetFaultAroundBytes_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_get_fault_around_bytes(res);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "GetFaultAroundBytes Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetFaultAroundBytes_HandlesValidInput)
-{
-       int ret = 0;
-       int fault_around_bytes = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               fault_around_bytes = pass_hal_get_fault_around_bytes(res);
-               if (haltest_is_failed(res, fault_around_bytes)) {
-                       ASSERT_EQ(fault_around_bytes, 0) << "GetFaultAroundBytes Failed";
-               }
-
-               if (fault_around_bytes >= 0) {
-                       ret = pass_hal_set_fault_around_bytes(res, fault_around_bytes);
-                       if (haltest_is_failed(res, ret)) {
-                               ASSERT_EQ(ret, 0) << "SetFaultAroundBytes Failed";
-                       }
-               }
-       }
-}
-
-TEST_F(PowerHaltest, SetPmqosData_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-       char applaunch_scenario[] = "AppLaunch";
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_set_pmqos_data(res, applaunch_scenario);
-               if (haltest_is_failed(res, ret)) {
-                       ASSERT_EQ(ret, 0) << "SetPmqosData Failed";
-               }
-       }
-}
-
-TEST_F(PowerHaltest, PutResourceConfig_HandlesValidInput)
-{
-       int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < g_pass.num_resources; i++) {
-               struct pass_resource *res = &g_pass.res[i];
-
-               ret = pass_hal_put_resource(res);
-               if (ret < 0) {
-                       pass_parser_put_resource_config(&g_pass);
-
-                       /* Even if tc is failed, need to restart PASS daemon */
-                       pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
-                                       "start", NULL);
-                       ASSERT_EQ(ret, 0) << "PutResourceConfig Failed";
-               }
-       }
-
-       /* Restart PASS daemon before HAL testing */
-       ret = pass_test_method_call(DBUS_CORE_PATH, DBUS_CORE_INTERFACE,
-                                       "start", NULL);
-       ASSERT_EQ(ret, 0) << "PassServiceStart Failed";
-}
-
-int main(int argc, char *argv[])
-{
-       int ret;
-
-       try {
-               testing::InitGoogleTest(&argc, argv);
-               ret = RUN_ALL_TESTS();
-       } catch (...) {
-               ret = EXIT_FAILURE;
-       }
-
-       return ret;
-}