Skip to content

Commit

Permalink
fix(test): use builtin parameter type converter
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo committed Feb 14, 2024
1 parent 74a091c commit fa4f3ae
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions test/libsinsp_e2e/sys_call_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,7 @@ TEST_F(sys_call_test, brk)

if (type == PPME_SYSCALL_BRK_4_E)
{
uint64_t addr;
memcpy(&addr,e->get_param_by_name("addr")->m_val, sizeof(uint64_t));
uint64_t addr = e->get_param_by_name("addr")->as<uint64_t>();
if (addr == 0)
{
ignore_this_call = true;
Expand All @@ -524,10 +523,8 @@ TEST_F(sys_call_test, brk)
return;
}

uint32_t vmsize;
memcpy(&vmsize, e->get_param_by_name("vm_size")->m_val, sizeof(uint32_t));
uint32_t vmrss;
memcpy(&vmrss, e->get_param_by_name("vm_rss")->m_val, sizeof(uint32_t));
uint32_t vmsize = e->get_param_by_name("vm_size")->as<uint32_t>();
uint32_t vmrss = e->get_param_by_name("vm_rss")->as<uint32_t>();

EXPECT_EQ(e->get_thread_info(false)->m_vmsize_kb, vmsize);
EXPECT_EQ(e->get_thread_info(false)->m_vmrss_kb, vmrss);
Expand Down Expand Up @@ -604,8 +601,7 @@ TEST_F(sys_call_test, mmap)
break;
case 7:
{
uint64_t addr;
memcpy(&addr, e->get_param_by_name("addr")->m_val, sizeof(uint64_t));
uint64_t addr = e->get_param_by_name("addr")->as<uint64_t>();
#ifdef __LP64__
EXPECT_EQ((uint64_t)p, addr);
#else
Expand All @@ -622,8 +618,8 @@ TEST_F(sys_call_test, mmap)
{
callnum++;

memcpy(&exit_vmsize, e->get_param_by_name("vm_size")->m_val, sizeof(uint32_t));
memcpy(&exit_vmrss, e->get_param_by_name("vm_rss")->m_val, sizeof(uint32_t));
exit_vmsize = e->get_param_by_name("vm_size")->as<uint32_t>();
exit_vmrss = e->get_param_by_name("vm_rss")->as<uint32_t>();
EXPECT_EQ(e->get_thread_info(false)->m_vmsize_kb, exit_vmsize);
EXPECT_EQ(e->get_thread_info(false)->m_vmrss_kb, exit_vmrss);

Expand Down Expand Up @@ -701,24 +697,22 @@ TEST_F(sys_call_test, mmap)
{
callnum++;

memcpy(&exit_vmsize, e->get_param_by_name("vm_size")->m_val, sizeof(uint32_t));
memcpy(&exit_vmrss, e->get_param_by_name("vm_size")->m_val, sizeof(uint32_t));
exit_vmsize = e->get_param_by_name("vm_size")->as<uint32_t>();
exit_vmrss = e->get_param_by_name("vm_rss")->as<uint32_t>();
EXPECT_EQ(e->get_thread_info(false)->m_vmsize_kb, exit_vmsize);
EXPECT_EQ(e->get_thread_info(false)->m_vmrss_kb, exit_vmrss);

switch (callnum)
{
case 4:
{
uint64_t res;
memcpy(&res, e->get_param_by_name("res")->m_val, sizeof(uint64_t));
uint64_t res = e->get_param_by_name("res")->as<uint64_t>();
EXPECT_EQ(-errno2, (int64_t)res);
break;
}
case 6:
{
uint64_t res;
memcpy(&res, e->get_param_by_name("res")->m_val, sizeof(uint64_t));
uint64_t res = e->get_param_by_name("res")->as<uint64_t>();
EXPECT_EQ((uint64_t)p, res);
EXPECT_GT(exit_vmsize, enter_vmsize + 500);
EXPECT_GE(exit_vmrss, enter_vmrss);
Expand Down

0 comments on commit fa4f3ae

Please sign in to comment.