tests: resource-monitor-tests: Add all resource attributes for testing 15/278515/4
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 20 Jul 2022 06:22:58 +0000 (15:22 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Sun, 7 Aug 2022 20:31:58 +0000 (05:31 +0900)
Add all defined resource and resources attributes for testing
and fix wrong usage of pass_resource_moniotor functions.

- PhysicalResourceMonitorTest's changes as following:
1. Add all resource types and resource attributes for testing
- memory / battery / system / display / disk / network resources and resource attributes
- the missing resource attributes for cpu/bus/gpu resources
2. Fix wrong usage of pass_resource_monitor_set_resource_attr function
3. Call pass_resource_monitor_update function to update resource attribute value

- ProcessResourceMonitorTest's changes as following:
1. Add process and process-group resources and resource attributes

Change-Id: I4820102c3c8f00bd73d751ce720f6162d682343a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
tests/integration-test/resource-monitor-tests.cpp

index 22ba73e..effe0cb 100644 (file)
@@ -20,6 +20,8 @@
 #include <gio/gio.h>
 #include <gtest/gtest.h>
 #include <gmock/gmock.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include <util/common.h>
 
@@ -33,7 +35,8 @@
 
 #include "resource-monitor.h"
 
-#define UNKNOWN_ID     9999
+#define UNKNOWN_ID             9999
+#define UNKNOWN_ATTR_MASK      0xffffffffffffffff
 
 using namespace std;
 
@@ -48,7 +51,8 @@ TEST_F(ResourceMonitorTest, pass_resource_monitor_init_and_exit)
        int id = pass_resource_monitor_init();
        EXPECT_TRUE(id > 0);
 
-       pass_resource_monitor_exit(id);
+       int ret = pass_resource_monitor_exit(id);
+       EXPECT_EQ(ret, 0);
 }
 
 TEST_F(ResourceMonitorTest, pass_resource_monitor_get_resource_count_valid)
@@ -64,6 +68,8 @@ TEST_F(ResourceMonitorTest, pass_resource_monitor_get_resource_count_valid)
                RESOURCE_TYPE_DISPLAY,
                RESOURCE_TYPE_SYSTEM,
                RESOURCE_TYPE_PROCESS_GROUP,
+               RESOURCE_TYPE_DISK,
+               RESOURCE_TYPE_NETWORK,
        };
 
        int id = pass_resource_monitor_init();
@@ -74,7 +80,8 @@ TEST_F(ResourceMonitorTest, pass_resource_monitor_get_resource_count_valid)
                EXPECT_TRUE(ret >= 0);
        }
 
-       pass_resource_monitor_exit(id);
+       int ret = pass_resource_monitor_exit(id);
+       EXPECT_EQ(ret, 0);
 }
 
 TEST_F(ResourceMonitorTest, pass_resource_monitor_get_resource_count_invalid)
@@ -93,7 +100,8 @@ TEST_F(ResourceMonitorTest, pass_resource_monitor_get_resource_count_invalid)
                EXPECT_EQ(ret, 0);
        }
 
-       pass_resource_monitor_exit(id);
+       int ret = pass_resource_monitor_exit(id);
+       EXPECT_EQ(ret, 0);
 }
 
 TEST_F(ResourceMonitorTest,
@@ -142,12 +150,14 @@ TEST_F(ResourceMonitorTest,
                EXPECT_EQ(ret, 0);
        }
 
-       pass_resource_monitor_exit(id);
+       int ret = pass_resource_monitor_exit(id);
+       EXPECT_EQ(ret, 0);
 }
 
 struct resource_attr_info {
        u_int64_t attr_id;
        int attr_type;
+       int array_type;
 };
 
 class PhysicalResourceInfo {
@@ -191,13 +201,15 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
                -1,
                0,
                CPU_CTRL_CLUSTER_ID,
-               5,
+               7,
                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, },
+                       { .attr_id = CPU_ATTR_CUR_GOVERNOR, .attr_type = DATA_TYPE_STRING, },
+                       { .attr_id = CPU_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
                }
        ),
 
@@ -208,13 +220,15 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
                -1,
                0,
                BUS_CTRL_DEVICE_ID,
-               5,
+               7,
                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, },
+                       { .attr_id = BUS_ATTR_CUR_GOVERNOR, .attr_type = DATA_TYPE_STRING, },
+                       { .attr_id = BUS_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
                }
        ),
 
@@ -225,7 +239,7 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
                -1,
                0,
                GPU_CTRL_DEVICE_ID,
-               6,
+               7,
                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, },
@@ -233,8 +247,114 @@ INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, PhysicalResourceMonitorTest,
                        { .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, },
+                       { .attr_id = GPU_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+               }
+       ),
+
+       PhysicalResourceInfo (
+               RESOURCE_TYPE_MEMORY,
+               "RESOURCE_TYPE_MEMORY",
+               -1,
+               -1,
+               0,
+               0,
+               9,
+               vector<struct resource_attr_info> {
+                       { .attr_id = MEMORY_ATTR_TOTAL, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_AVAILABLE, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_FREE, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_BUFFER, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_CACHED, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_CMA_TOTAL, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_CMA_FREE, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_SWAP_TOTAL, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = MEMORY_ATTR_SWAP_FREE, .attr_type = DATA_TYPE_UINT64, },
+               }
+       ),
+
+       PhysicalResourceInfo (
+               RESOURCE_TYPE_BATTERY,
+               "RESOURCE_TYPE_BATTERY",
+               -1,
+               -1,
+               0,
+               0,
+               7,
+               vector<struct resource_attr_info> {
+                       { .attr_id = BATTERY_ATTR_CAPACITY, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BATTERY_ATTR_STATUS, .attr_type = DATA_TYPE_STRING, },
+                       { .attr_id = BATTERY_ATTR_TEMPERATURE, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BATTERY_ATTR_VOLTAGE_NOW, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BATTERY_ATTR_CURRENT_NOW, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BATTERY_ATTR_PRESENT, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = BATTERY_ATTR_ONLINE, .attr_type = DATA_TYPE_INT, },
+               }
+       ),
+
+       PhysicalResourceInfo (
+               RESOURCE_TYPE_DISPLAY,
+               "RESOURCE_TYPE_DISPLAY",
+               -1,
+               -1,
+               0,
+               DISPLAY_CTRL_DEVICE_ID,
+               2,
+               vector<struct resource_attr_info> {
+                       { .attr_id = DISPLAY_ATTR_FPS, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = DISPLAY_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+               }
+       ),
+
+       PhysicalResourceInfo (
+               RESOURCE_TYPE_SYSTEM,
+               "RESOURCE_TYPE_SYSTEM",
+               -1,
+               -1,
+               0,
+               0,
+               8,
+               vector<struct resource_attr_info> {
+                       { .attr_id = SYSTEM_ATTR_CPU_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = SYSTEM_ATTR_CPU_USER_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = SYSTEM_ATTR_CPU_SYS_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = SYSTEM_ATTR_PER_CPU_UTIL, .attr_type = DATA_TYPE_ARRAY, },
+                       { .attr_id = SYSTEM_ATTR_PER_CPU_USER_UTIL, .attr_type = DATA_TYPE_ARRAY, },
+                       { .attr_id = SYSTEM_ATTR_PER_CPU_SYS_UTIL, .attr_type = DATA_TYPE_ARRAY, },
+                       { .attr_id = SYSTEM_ATTR_POSSIBLE_CPU, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = SYSTEM_ATTR_ONLINE_CPU, .attr_type = DATA_TYPE_INT, },
+               }
+       ),
+
+       PhysicalResourceInfo (
+               RESOURCE_TYPE_DISK,
+               "RESOURCE_TYPE_DISK",
+               -1,
+               -1,
+               0,
+               DISK_CTRL_DEVICE_ID,
+               5,
+               vector<struct resource_attr_info> {
+                       { .attr_id = DISK_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+                       { .attr_id = DISK_ATTR_READ_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = DISK_ATTR_WRITE_PER_SEC, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = DISK_ATTR_READ_TOTAL, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = DISK_ATTR_WRITE_TOTAL, .attr_type = DATA_TYPE_UINT64, },
+               }
+       ),
+
+       PhysicalResourceInfo (
+               RESOURCE_TYPE_NETWORK,
+               "RESOURCE_TYPE_NETWORK",
+               -1,
+               -1,
+               0,
+               NETWORK_CTRL_DEVICE_ID,
+               1,
+               vector<struct resource_attr_info> {
+                       { .attr_id = NETWORK_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
                }
        )
+
 ));
 
 TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_create_resource_and_delete)
@@ -261,6 +381,36 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_create_resource_and_de
        pass_resource_monitor_exit(res.mon_id);
 }
 
+TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_get_resource_timestamp)
+{
+       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++) {
+               int64_t start, end;
+
+               res.res_id = pass_resource_monitor_create_resource(res.mon_id, res.type);
+               EXPECT_TRUE(res.res_id >= 0);
+
+               /* Test pass_resource_monitor_get_resource_timestamp */
+               int ret = pass_resource_monitor_get_resource_timestamp(
+                                                       res.mon_id, res.res_id,
+                                                       &start, &end);
+               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);
+}
+
 TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_set_resource_ctrl)
 {
        auto res = GetParam();
@@ -279,7 +429,7 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_set_resource_ctrl)
                /* 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 )
+               if (res.ctrl_id > 0)
                        EXPECT_EQ(ret, 0);
                else
                        EXPECT_NE(ret, 0);
@@ -288,7 +438,8 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_set_resource_ctrl)
                EXPECT_EQ(ret, 0);
        }
 
-       pass_resource_monitor_exit(res.mon_id);
+       int ret = pass_resource_monitor_exit(res.mon_id);
+       EXPECT_EQ(ret, 0);
 }
 
 static int __pass_resource_monitor_set_resource_attr(int mon_id, int res_id, int num_attrs,
@@ -310,6 +461,25 @@ static int __pass_resource_monitor_set_resource_attr(int mon_id, int res_id, int
        return ret;
 }
 
+static int __pass_resource_monitor_unset_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_unset_resource_attr(mon_id, res_id, mask);
+       EXPECT_EQ(ret, 0);
+
+       return ret;
+}
+
 TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_set_resource_attr)
 {
        auto res = GetParam();
@@ -331,21 +501,108 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_set_resource_attr)
                 * */
                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);
+               if (res.ctrl_id > 0)
                        EXPECT_EQ(ret, 0);
-               } else {
+               else
                        EXPECT_NE(ret, 0);
-               }
+
+               ret = __pass_resource_monitor_set_resource_attr(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 ret = pass_resource_monitor_exit(res.mon_id);
+       EXPECT_EQ(ret, 0);
+}
+
+TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_unset_resource_attr_valid)
+{
+       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)
+                       EXPECT_EQ(ret, 0);
+               else
+                       EXPECT_NE(ret, 0);
+
+               ret = __pass_resource_monitor_set_resource_attr(res.mon_id,
+                                                               res.res_id,
+                                                               res.num_attrs,
+                                                               res.attrs);
+               EXPECT_EQ(ret, 0);
+
+               /* Test pass_resource_monitor_unset_resource_attr */
+               ret = __pass_resource_monitor_unset_resource_attr(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);
+       }
+
+       int ret = pass_resource_monitor_exit(res.mon_id);
+       EXPECT_EQ(ret, 0);
+}
+
+TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_unset_resource_attr_invalid)
+{
+       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)
+                       EXPECT_EQ(ret, 0);
+               else
+                       EXPECT_NE(ret, 0);
+
+               ret = __pass_resource_monitor_set_resource_attr(res.mon_id,
+                                                               res.res_id,
+                                                               res.num_attrs,
+                                                               res.attrs);
+               EXPECT_EQ(ret, 0);
+
+               /* Test pass_resource_monitor_unset_resource_attr */
+               ret = pass_resource_monitor_unset_resource_attr(res.mon_id,
+                                                               res.res_id,
+                                                               UNKNOWN_ATTR_MASK);
+               EXPECT_NE(ret, 0);
+
+               ret = pass_resource_monitor_delete_resource(res.mon_id, res.res_id);
+               EXPECT_EQ(ret, 0);
+       }
+
+       int ret = pass_resource_monitor_exit(res.mon_id);
+       EXPECT_EQ(ret, 0);
 }
 
 static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_attrs,
@@ -396,9 +653,70 @@ static int __pass_resource_monitor_get_value(int mon_id, int res_id, int num_att
                                                attrs[i].attr_id, value_str);
                        EXPECT_EQ(ret, 0);
                        break;
+               case DATA_TYPE_ARRAY:
+                       int length;
+
+                       switch (attrs[i].array_type) {
+                               case DATA_TYPE_INT:
+                               {
+                                       int32_t *array = NULL;
+                                       ret = pass_resource_monitor_get_array_int(mon_id, res_id,
+                                                       attrs[i].attr_id, &array, &length);
+                                       EXPECT_EQ(ret, 0);
+                                       break;
+                               }
+                               case DATA_TYPE_INT64:
+                               {
+                                       int64_t *array = NULL;;
+                                       ret = pass_resource_monitor_get_array_int64(mon_id, res_id,
+                                                       attrs[i].attr_id, &array, &length);
+                                       EXPECT_EQ(ret, 0);
+                                       break;
+                               }
+                               case DATA_TYPE_UINT:
+                               {
+                                       u_int32_t *array = NULL;
+                                       ret = pass_resource_monitor_get_array_uint(mon_id, res_id,
+                                                       attrs[i].attr_id, &array, &length);
+                                       EXPECT_EQ(ret, 0);
+                                       break;
+                               }
+                               case DATA_TYPE_UINT64:
+                               {
+                                       u_int64_t *array = NULL;
+                                       ret = pass_resource_monitor_get_array_uint64(mon_id, res_id,
+                                                       attrs[i].attr_id, &array, &length);
+                                       EXPECT_EQ(ret, 0);
+                                       break;
+                               }
+                               case DATA_TYPE_DOUBLE:
+                               {
+                                       double *array = NULL;
+                                       ret = pass_resource_monitor_get_array_double(mon_id, res_id,
+                                                       attrs[i].attr_id, &array, &length);
+                                       EXPECT_EQ(ret, 0);
+                                       break;
+                               }
+                               case DATA_TYPE_STRING:
+                               {
+                                       char **array = NULL;
+                                       ret = pass_resource_monitor_get_array_string(mon_id, res_id,
+                                                       attrs[i].attr_id, &array, &length);
+                                       EXPECT_EQ(ret, 0);
+                                       break;
+                               }
+                               default:
+                               {
+                                       /* Unknown data type */
+                                       ret = -EINVAL;
+                                       EXPECT_TRUE(false);
+                               }
+                       }
+                       break;
                default:
+                       /* Unknown data type */
                        ret = -EINVAL;
-                       EXPECT_EQ(ret, 0);
+                       EXPECT_TRUE(false);
                        break;
                }
 
@@ -426,17 +744,24 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_get_value)
 
                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);
+               if (res.ctrl_id > 0)
                        EXPECT_EQ(ret, 0);
-               } else {
+               else
                        EXPECT_NE(ret, 0);
-               }
 
-               /* Test both pass_resource_monitor_get_value_[data type] */
+               ret = __pass_resource_monitor_set_resource_attr(res.mon_id,
+                                                               res.res_id,
+                                                               res.num_attrs,
+                                                               res.attrs);
+               EXPECT_EQ(ret, 0);
+
+               /*
+                * Test both pass_resource_monitor_update
+                * and pass_resource_monitor_get_value_[data type]
+                */
+               ret = pass_resource_monitor_update(res.mon_id);
+               EXPECT_EQ(ret, 0);
+
                ret = __pass_resource_monitor_get_value(res.mon_id,
                                                        res.res_id,
                                                        res.num_attrs,
@@ -447,7 +772,137 @@ TEST_P(PhysicalResourceMonitorTest, pass_resource_monitor_get_value)
                EXPECT_EQ(ret, 0);
        }
 
-       pass_resource_monitor_exit(res.mon_id);
+       int ret = pass_resource_monitor_exit(res.mon_id);
+       EXPECT_EQ(ret, 0);
+}
+
+class ProcessResourceInfo {
+public:
+       const int type;
+       const char *name;
+       int mon_id;
+       int res_id;
+       const u_int64_t ctrl_id;
+       const int num_attrs;
+       vector<struct resource_attr_info> attrs;
+
+       ProcessResourceInfo(
+               const int type_,
+               const char *name_,
+               int mon_id_,
+               int res_id_,
+               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_),
+                       ctrl_id(ctrl_id_),
+                       num_attrs(num_attrs_),
+                       attrs(attrs_) {}
+};
+
+class ProcessResourceMonitorTest : public ::testing::TestWithParam<ProcessResourceInfo> {};
+
+INSTANTIATE_TEST_CASE_P (ResourceMonitorTest, ProcessResourceMonitorTest,
+       ::testing::Values (
+       ProcessResourceInfo (
+               RESOURCE_TYPE_PROCESS,
+               "RESOURCE_TYPE_PROCESS",
+               -1,
+               -1,
+               PROCESS_CTRL_TGID,
+               13,
+               vector<struct resource_attr_info> {
+                       { .attr_id = PROCESS_ATTR_CPU_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = PROCESS_ATTR_MEM_VIRT, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_ATTR_MEM_RSS, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_ATTR_MEM_RSS_PERCENT, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = PROCESS_ATTR_DISK_READ_BPS, .attr_type = DATA_TYPE_UINT, },
+                       { .attr_id = PROCESS_ATTR_DISK_WRITE_BPS, .attr_type = DATA_TYPE_UINT, },
+                       { .attr_id = PROCESS_ATTR_NAME, .attr_type = DATA_TYPE_STRING, },
+                       { .attr_id = PROCESS_ATTR_PGID, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = PROCESS_ATTR_PPID, .attr_type = DATA_TYPE_INT, },
+                       { .attr_id = PROCESS_ATTR_MEM_PSS, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_ATTR_MEM_SWAP, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_ATTR_MEM_SWAP_PSS, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_ATTR_MEM_GPU, .attr_type = DATA_TYPE_UINT64, },
+               }
+       ),
+
+       ProcessResourceInfo (
+               RESOURCE_TYPE_PROCESS_GROUP,
+               "RESOURCE_TYPE_PROCESS_GROUP",
+               -1,
+               -1,
+               PROCESS_GROUP_CTRL_ROOT_PID,
+               11,
+               vector<struct resource_attr_info> {
+                       { .attr_id = PROCESS_GROUP_ATTR_PID_LIST, .attr_type = DATA_TYPE_ARRAY, .array_type = DATA_TYPE_INT, },
+                       { .attr_id = PROCESS_GROUP_ATTR_NAME_LIST, .attr_type = DATA_TYPE_ARRAY, .array_type = DATA_TYPE_STRING, },
+                       { .attr_id = PROCESS_GROUP_ATTR_CPU_UTIL, .attr_type = DATA_TYPE_DOUBLE, },
+                       { .attr_id = PROCESS_GROUP_ATTR_DISK_READ_BPS, .attr_type = DATA_TYPE_UINT, },
+                       { .attr_id = PROCESS_GROUP_ATTR_DISK_WRITE_BPS, .attr_type = DATA_TYPE_UINT, },
+                       { .attr_id = PROCESS_GROUP_ATTR_MEM_VIRT, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_GROUP_ATTR_MEM_RSS, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_GROUP_ATTR_MEM_PSS, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_GROUP_ATTR_MEM_SWAP, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_GROUP_ATTR_MEM_SWAP_PSS, .attr_type = DATA_TYPE_UINT64, },
+                       { .attr_id = PROCESS_GROUP_ATTR_MEM_GPU, .attr_type = DATA_TYPE_UINT64, },
+               }
+       )
+));
+
+TEST_P(ProcessResourceMonitorTest, pass_resource_monitor_get_value)
+{
+       auto res = GetParam();
+       int64_t start, end;
+
+       /* Test pass_resource_monitor_init */
+       res.mon_id = pass_resource_monitor_init();
+       ASSERT_TRUE(res.mon_id > 0);
+
+       /* 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_set_resource_ctrl */
+       int ret = pass_resource_monitor_set_resource_ctrl(res.mon_id, res.res_id,
+                                                       res.ctrl_id, getpid());
+       EXPECT_EQ(ret, 0);
+
+       /* Test pass_resource_monitor_set_resource_attr */
+       ret = __pass_resource_monitor_set_resource_attr(res.mon_id, res.res_id,
+                                                       res.num_attrs, res.attrs);
+       EXPECT_EQ(ret, 0);
+
+       /* Test pass_resource_monitor_update */
+       ret = pass_resource_monitor_update(res.mon_id);
+       EXPECT_EQ(ret, 0);
+
+       /* Test pass_resource_monitor_get_value */
+       ret = __pass_resource_monitor_get_value(res.mon_id, res.res_id,
+                                               res.num_attrs, res.attrs);
+       EXPECT_EQ(ret, 0);
+
+       /* Test pass_resource_monitor_get_resource_timestamp */
+       ret = pass_resource_monitor_get_resource_timestamp(res.mon_id, res.res_id,
+                                               &start, &end);
+       EXPECT_EQ(ret, 0);
+
+       /* Test pass_resource_monitor_unset_resource_attr */
+       ret = __pass_resource_monitor_unset_resource_attr(res.mon_id, res.res_id,
+                                                       res.num_attrs, res.attrs);
+       EXPECT_EQ(ret, 0);
+
+       /* Test pass_resource_monitor_delete_resource */
+       ret = pass_resource_monitor_delete_resource(res.mon_id, res.res_id);
+       EXPECT_EQ(ret, 0);
+
+       /* Test pass_resource_monitor_exit */
+       ret = pass_resource_monitor_exit(res.mon_id);
+       EXPECT_EQ(ret, 0);
 }
 
 int main(int argc, char *argv[])