test: intergration-test: Add resource-monitor-tests 45/277445/3
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 4 Jul 2022 22:37:38 +0000 (07:37 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 8 Jul 2022 09:03:23 +0000 (18:03 +0900)
In order that test the resource-monitor library and internal logic,
add resource-monitor-tests.

[Example, the result of resource-monitor-tests]
root:~> resource-monitor-tests
[==========] Running 16 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 4 tests from ResourceMonitorTest
[ RUN      ] ResourceMonitorTest.pass_resource_monitor_init_and_exit
[       OK ] ResourceMonitorTest.pass_resource_monitor_init_and_exit (0 ms)
[ RUN      ] ResourceMonitorTest.pass_resource_monitor_get_resource_count_valid
[       OK ] ResourceMonitorTest.pass_resource_monitor_get_resource_count_valid (2 ms)
[ RUN      ] ResourceMonitorTest.pass_resource_monitor_get_resource_count_invalid
[       OK ] ResourceMonitorTest.pass_resource_monitor_get_resource_count_invalid (0 ms)
[ RUN      ] ResourceMonitorTest.pass_resource_monitor_is_resource_attr_supported_invalid
[       OK ] ResourceMonitorTest.pass_resource_monitor_is_resource_attr_supported_invalid (1 ms)
[----------] 4 tests from ResourceMonitorTest (6 ms total)

[----------] 12 tests from ResourceMonitorTest/EachResourceMonitorTest
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_create_resource_and_delete/0
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_create_resource_and_delete/0 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_create_resource_and_delete/1
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_create_resource_and_delete/1 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_create_resource_and_delete/2
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_create_resource_and_delete/2 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_ctrl/0
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_ctrl/0 (1 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_ctrl/1
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_ctrl/1 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_ctrl/2
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_ctrl/2 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_attr/0
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_attr/0 (2 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_attr/1
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_attr/1 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_attr/2
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_set_resource_attr/2 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_get_value/0
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_get_value/0 (3 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_get_value/1
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_get_value/1 (0 ms)
[ RUN      ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_get_value/2
[       OK ] ResourceMonitorTest/EachResourceMonitorTest.pass_resource_monitor_get_value/2 (0 ms)
[----------] 12 tests from ResourceMonitorTest/EachResourceMonitorTest (15 ms total)

[----------] Global test environment tear-down
[==========] 16 tests from 2 test suites ran. (21 ms total)
[  PASSED  ] 16 tests.

Change-Id: Id15d6948849decedcbe0f48bee083667afdc996b
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
packaging/pass.spec
tests/integration-test/CMakeLists.txt
tests/integration-test/resource-monitor-tests.cpp [new file with mode: 0644]

index 74c735a..0168238 100644 (file)
@@ -127,6 +127,7 @@ systemctl daemon-reload
 %files -n %{unittest_name}
 %defattr(-,root,root,-)
 %{_bindir}/pass-tests
+%{_bindir}/resource-monitor-tests
 
 %files -n %{libpass_resource_monitor_name}
 %license LICENSE
index 2f12af5..69ec8ff 100644 (file)
@@ -3,12 +3,14 @@ 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
+       ${CMAKE_SOURCE_DIR}/lib/resource-monitor/resource-monitor.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_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/resource-monitor)
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(gtest_pkgs REQUIRED
@@ -35,3 +37,10 @@ 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/)
+
+SET(src ${CMAKE_SOURCE_DIR}/tests/integration-test/resource-monitor-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/resource-monitor-tests.cpp b/tests/integration-test/resource-monitor-tests.cpp
new file mode 100644 (file)
index 0000000..71fd72f
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ * 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 <stdlib.h>
+
+#include <gio/gio.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include <util/common.h>
+
+#include <vector>
+#include <memory>
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "resource-monitor.h"
+
+#define UNKNOWN_ID     9999
+
+using namespace std;
+
+class ResourceMonitorTest : public testing::Test {
+public:
+       void SetUp() override {}
+       void TearDown() override {}
+};
+
+TEST_F(ResourceMonitorTest, pass_resource_monitor_init_and_exit)
+{
+       int id = pass_resource_monitor_init();
+       EXPECT_TRUE(id > 0);
+
+       pass_resource_monitor_exit(id);
+}
+
+TEST_F(ResourceMonitorTest, pass_resource_monitor_get_resource_count_valid)
+{
+       int i;
+       int res_types[] = {
+               RESOURCE_TYPE_CPU,
+               RESOURCE_TYPE_BUS,
+               RESOURCE_TYPE_GPU,
+               RESOURCE_TYPE_MEMORY,
+               RESOURCE_TYPE_BATTERY,
+               RESOURCE_TYPE_PROCESS,
+               RESOURCE_TYPE_DISPLAY,
+               RESOURCE_TYPE_SYSTEM,
+               RESOURCE_TYPE_PROCESS_GROUP,
+       };
+
+       int id = pass_resource_monitor_init();
+       EXPECT_TRUE(id > 0);
+
+       for (i = 0; i < (int)ARRAY_SIZE(res_types); i++) {
+               int ret = pass_resource_monitor_get_resource_count(id, res_types[i]);
+               EXPECT_TRUE(ret >= 0);
+       }
+
+       pass_resource_monitor_exit(id);
+}
+
+TEST_F(ResourceMonitorTest, pass_resource_monitor_get_resource_count_invalid)
+{
+       int i;
+       int res_types[] = {
+               RESOURCE_TYPE_UNKNOWN,
+               RESOURCE_TYPE_NONSTANDARD,
+       };
+
+       int id = pass_resource_monitor_init();
+       EXPECT_TRUE(id > 0);
+
+       for (i = 0; i < (int)ARRAY_SIZE(res_types); i++) {
+               int ret = pass_resource_monitor_get_resource_count(id, res_types[i]);
+               EXPECT_EQ(ret, 0);
+       }
+
+       pass_resource_monitor_exit(id);
+}
+
+TEST_F(ResourceMonitorTest,
+       pass_resource_monitor_is_resource_attr_supported_invalid)
+{
+       int i, j;
+       int res_type = RESOURCE_TYPE_CPU;
+       u_int64_t res_attr_ids[] = {
+               BIT(50),
+               BIT(51),
+               BIT(52),
+       };
+
+       int id = pass_resource_monitor_init();
+       EXPECT_TRUE(id > 0);
+
+       int count = pass_resource_monitor_get_resource_count(id, res_type);
+       EXPECT_TRUE(count >= 0);
+
+       for (i = 0; i < count; i++) {
+               int res_id = pass_resource_monitor_create_resource(id, res_type);
+               EXPECT_TRUE(res_id >= 0);
+
+               int ret = pass_resource_monitor_set_resource_ctrl(id, res_id,
+                                                       CPU_CTRL_CLUSTER_ID, i);
+               EXPECT_EQ(ret, 0);
+
+               for (j = 0; j < (int)ARRAY_SIZE(res_attr_ids); j++) {
+                       bool supported = pass_resource_monitor_is_resource_attr_supported(
+                                                       id, res_id,
+                                                       res_attr_ids[j]);
+                       EXPECT_EQ(supported, false);
+
+                       supported = pass_resource_monitor_is_resource_attr_supported(
+                                                       UNKNOWN_ID, res_id,
+                                                       res_attr_ids[j]);
+                       EXPECT_EQ(supported, false);
+
+                       supported = pass_resource_monitor_is_resource_attr_supported(
+                                                       id, UNKNOWN_ID,
+                                                       res_attr_ids[j]);
+                       EXPECT_EQ(supported, false);
+               }
+
+               ret = pass_resource_monitor_delete_resource(id, res_id);
+               EXPECT_EQ(ret, 0);
+       }
+
+       pass_resource_monitor_exit(id);
+}
+
+struct resource_attr_info {
+       u_int64_t attr_id;
+       int attr_type;
+};
+
+class ResourceInfo {
+public:
+       const int type;
+       const char *name;
+       int mon_id;
+       int res_id;
+       int count;
+       const u_int64_t ctrl_id;
+       const int num_attrs;
+       vector<struct resource_attr_info> attrs;
+
+       ResourceInfo(
+               const int type_,
+               const char *name_,
+               int mon_id_,
+               int res_id_,
+               int count_,
+               const u_int64_t ctrl_id_,
+               const int num_attrs_,
+               vector<struct resource_attr_info> attrs_) :
+                       type(type_),
+                       name(name_),
+                       mon_id(mon_id_),
+                       res_id(res_id_),
+                       count(count_),
+                       ctrl_id(ctrl_id_),
+                       num_attrs(num_attrs_),
+                       attrs(attrs_) {}
+};
+
+class EachResourceMonitorTest : public ::testing::TestWithParam<ResourceInfo> {};
+
+INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, EachResourceMonitorTest,
+       ::testing::Values (
+       ResourceInfo (
+               RESOURCE_TYPE_CPU,
+               "RESOURCE_TYPE_CPU",
+               -1,
+               -1,
+               0,
+               CPU_CTRL_CLUSTER_ID,
+               5,
+               vector<struct resource_attr_info> {
+                       { .attr_id = CPU_ATTR_CUR_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = CPU_ATTR_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = CPU_ATTR_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = CPU_ATTR_AVAILABLE_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = CPU_ATTR_AVAILABLE_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
+               }
+       ),
+
+       ResourceInfo (
+               RESOURCE_TYPE_BUS,
+               "RESOURCE_TYPE_BUS",
+               -1,
+               -1,
+               0,
+               BUS_CTRL_DEVICE_ID,
+               5,
+               vector<struct resource_attr_info> {
+                       { .attr_id = BUS_ATTR_CUR_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BUS_ATTR_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BUS_ATTR_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BUS_ATTR_AVAILABLE_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BUS_ATTR_AVAILABLE_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
+               }
+       ),
+
+       ResourceInfo (
+               RESOURCE_TYPE_GPU,
+               "RESOURCE_TYPE_GPU",
+               -1,
+               -1,
+               0,
+               GPU_CTRL_DEVICE_ID,
+               6,
+               vector<struct resource_attr_info> {
+                       { .attr_id = GPU_ATTR_CUR_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = GPU_ATTR_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = GPU_ATTR_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = GPU_ATTR_AVAILABLE_MIN_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = GPU_ATTR_AVAILABLE_MAX_FREQ, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = GPU_ATTR_CUR_GOVERNOR, .attr_type = DATA_TYPE_STRING, },
+               }
+       )
+));
+
+TEST_P(EachResourceMonitorTest, pass_resource_monitor_create_resource_and_delete)
+{
+       auto res = GetParam();
+       int i;
+
+       res.mon_id = pass_resource_monitor_init();
+       ASSERT_TRUE(res.mon_id > 0);
+
+       res.count = pass_resource_monitor_get_resource_count(res.mon_id, res.type);
+       EXPECT_TRUE(res.count >= 0);
+
+       for (i = 0; i < res.count; i++) {
+               /* Test pass_resource_monitor_create_resource */
+               res.res_id = pass_resource_monitor_create_resource(res.mon_id, res.type);
+               EXPECT_TRUE(res.res_id >= 0);
+
+               /* Test pass_resource_monitor_delete_resource */
+               int ret = pass_resource_monitor_delete_resource(res.mon_id, res.res_id);
+               EXPECT_EQ(ret, 0);
+       }
+
+       pass_resource_monitor_exit(res.mon_id);
+}
+
+TEST_P(EachResourceMonitorTest, pass_resource_monitor_set_resource_ctrl)
+{
+       auto res = GetParam();
+       int i;
+
+       res.mon_id = pass_resource_monitor_init();
+       ASSERT_TRUE(res.mon_id > 0);
+
+       res.count = pass_resource_monitor_get_resource_count(res.mon_id, res.type);
+       EXPECT_TRUE(res.count >= 0);
+
+       for (i = 0; i < res.count; i++) {
+               res.res_id = pass_resource_monitor_create_resource(res.mon_id, res.type);
+               EXPECT_TRUE(res.res_id >= 0);
+
+               /* Test pass_resource_monitor_set_resource_ctrl */
+               int ret = pass_resource_monitor_set_resource_ctrl(res.mon_id, res.res_id,
+                                                               res.ctrl_id, i);
+               if (res.ctrl_id > 0 )
+                       EXPECT_EQ(ret, 0);
+               else
+                       EXPECT_NE(ret, 0);
+
+               ret = pass_resource_monitor_delete_resource(res.mon_id, res.res_id);
+               EXPECT_EQ(ret, 0);
+       }
+
+       pass_resource_monitor_exit(res.mon_id);
+}
+
+static int __pass_resource_monitor_set_resource_attr(int mon_id, int res_id, int num_attrs,
+                                               std::vector<struct resource_attr_info> attrs)
+{
+       int i, ret;
+       u_int64_t mask = 0;
+
+       for (i = 0; i < num_attrs; i++) {
+               bool supported = pass_resource_monitor_is_resource_attr_supported(
+                                               mon_id, res_id, attrs[i].attr_id);
+               if (supported)
+                       mask |= attrs[i].attr_id;
+       }
+
+       ret = pass_resource_monitor_set_resource_attr(mon_id, res_id, mask);
+       EXPECT_EQ(ret, 0);
+
+       return ret;
+}
+
+TEST_P(EachResourceMonitorTest, pass_resource_monitor_set_resource_attr)
+{
+       auto res = GetParam();
+       int i;
+
+       res.mon_id = pass_resource_monitor_init();
+       ASSERT_TRUE(res.mon_id > 0);
+
+       res.count = pass_resource_monitor_get_resource_count(res.mon_id, res.type);
+       EXPECT_TRUE(res.count >= 0);
+
+       for (i = 0; i < res.count; i++) {
+               res.res_id = pass_resource_monitor_create_resource(res.mon_id, res.type);
+               EXPECT_TRUE(res.res_id >= 0);
+
+               /*
+                * Test both pass_resource_monitor_set_resource_attr
+                * and pass_resource_monitor_is_resource_attr_supported
+                * */
+               int ret = pass_resource_monitor_set_resource_ctrl(res.mon_id, res.res_id,
+                                                               res.ctrl_id, i);
+               if (res.ctrl_id > 0 ) {
+                       ret = __pass_resource_monitor_set_resource_attr(res.mon_id,
+                                                                       res.res_id,
+                                                                       res.num_attrs,
+                                                                       res.attrs);
+                       EXPECT_EQ(ret, 0);
+               } else {
+                       EXPECT_NE(ret, 0);
+               }
+
+               ret = pass_resource_monitor_delete_resource(res.mon_id, res.res_id);
+               EXPECT_EQ(ret, 0);
+       }
+
+       pass_resource_monitor_exit(res.mon_id);
+}
+
+static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_attrs,
+                                       std::vector<struct resource_attr_info> attrs)
+{
+       int i, ret, err_count = 0;
+
+       for (i = 0; i < num_attrs; i++) {
+               bool supported = pass_resource_monitor_is_resource_attr_supported(
+                                               mon_id, res_id, attrs[i].attr_id);
+               if (!supported)
+                       continue;
+
+               switch (attrs[i].attr_type) {
+               case DATA_TYPE_INT:
+                       int32_t value_int32;
+                       ret = pass_resource_monitor_get_value_int(mon_id, res_id,
+                                               attrs[i].attr_id, &value_int32);
+                       EXPECT_EQ(ret, 0);
+                       break;
+               case DATA_TYPE_INT64:
+                       int64_t value_int64;
+                       ret = pass_resource_monitor_get_value_int64(mon_id, res_id,
+                                               attrs[i].attr_id, &value_int64);
+                       EXPECT_EQ(ret, 0);
+                       break;
+               case DATA_TYPE_UINT:
+                       u_int32_t value_uint32;
+                       ret = pass_resource_monitor_get_value_uint(mon_id, res_id,
+                                               attrs[i].attr_id, &value_uint32);
+                       EXPECT_EQ(ret, 0);
+                       break;
+               case DATA_TYPE_UINT64:
+                       u_int64_t value_uint64;
+                       ret = pass_resource_monitor_get_value_uint64(mon_id, res_id,
+                                               attrs[i].attr_id, &value_uint64);
+                       EXPECT_EQ(ret, 0);
+                       break;
+               case DATA_TYPE_DOUBLE:
+                       double value_double;
+                       ret = pass_resource_monitor_get_value_double(mon_id, res_id,
+                                               attrs[i].attr_id, &value_double);
+                       EXPECT_EQ(ret, 0);
+                       break;
+               case DATA_TYPE_STRING:
+                       char value_str[BUFF_MAX];
+                       ret = pass_resource_monitor_get_value_string(mon_id, res_id,
+                                               attrs[i].attr_id, value_str);
+                       EXPECT_EQ(ret, 0);
+                       break;
+               default:
+                       ret = -EINVAL;
+                       EXPECT_EQ(ret, 0);
+                       break;
+               }
+
+               if (ret < 0)
+                       err_count++;
+       }
+
+       return err_count ? -EINVAL : 0;
+}
+
+TEST_P(EachResourceMonitorTest, pass_resource_monitor_get_value)
+{
+       auto res = GetParam();
+       int i;
+
+       res.mon_id = pass_resource_monitor_init();
+       ASSERT_TRUE(res.mon_id > 0);
+
+       res.count = pass_resource_monitor_get_resource_count(res.mon_id, res.type);
+       EXPECT_TRUE(res.count >= 0);
+
+       for (i = 0; i < res.count; i++) {
+               res.res_id = pass_resource_monitor_create_resource(res.mon_id, res.type);
+               EXPECT_TRUE(res.res_id >= 0);
+
+               int ret = pass_resource_monitor_set_resource_ctrl(res.mon_id, res.res_id,
+                                                               res.ctrl_id, i);
+               if (res.ctrl_id > 0 ) {
+                       ret = __pass_resource_monitor_set_resource_attr(res.mon_id,
+                                                                       res.res_id,
+                                                                       res.num_attrs,
+                                                                       res.attrs);
+                       EXPECT_EQ(ret, 0);
+               } else {
+                       EXPECT_NE(ret, 0);
+               }
+
+               /* Test both pass_resource_monitor_get_value_[data type] */
+               ret = __pass_resource_monitor_get_value(res.mon_id,
+                                                       res.res_id,
+                                                       res.num_attrs,
+                                                       res.attrs);
+               EXPECT_EQ(ret, 0);
+
+               ret = pass_resource_monitor_delete_resource(res.mon_id, res.res_id);
+               EXPECT_EQ(ret, 0);
+       }
+
+       pass_resource_monitor_exit(res.mon_id);
+}
+
+int main(int argc, char *argv[])
+{
+       try {
+               testing::InitGoogleTest(&argc, argv);
+               return RUN_ALL_TESTS();
+       } catch (...) {
+               return EXIT_FAILURE;
+       }
+}