#include <gio/gio.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <util/common.h>
#include "resource-monitor.h"
-#define UNKNOWN_ID 9999
+#define UNKNOWN_ID 9999
+#define UNKNOWN_ATTR_MASK 0xffffffffffffffff
using namespace std;
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)
RESOURCE_TYPE_DISPLAY,
RESOURCE_TYPE_SYSTEM,
RESOURCE_TYPE_PROCESS_GROUP,
+ RESOURCE_TYPE_DISK,
+ RESOURCE_TYPE_NETWORK,
};
int id = pass_resource_monitor_init();
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)
EXPECT_EQ(ret, 0);
}
- pass_resource_monitor_exit(id);
+ int ret = pass_resource_monitor_exit(id);
+ EXPECT_EQ(ret, 0);
}
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 {
-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, },
}
),
-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, },
}
),
-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, },
{ .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)
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();
/* 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);
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,
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();
* */
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,
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;
}
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,
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[])