From fa4f3aefedd2663a44cb4ff4b049aada8e348e18 Mon Sep 17 00:00:00 2001 From: Roberto Scolaro Date: Wed, 14 Feb 2024 14:27:49 +0000 Subject: [PATCH] fix(test): use builtin parameter type converter Signed-off-by: Roberto Scolaro --- test/libsinsp_e2e/sys_call_test.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/test/libsinsp_e2e/sys_call_test.cpp b/test/libsinsp_e2e/sys_call_test.cpp index b5e6ace56c..a49a10e423 100644 --- a/test/libsinsp_e2e/sys_call_test.cpp +++ b/test/libsinsp_e2e/sys_call_test.cpp @@ -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(); if (addr == 0) { ignore_this_call = true; @@ -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 vmrss = e->get_param_by_name("vm_rss")->as(); EXPECT_EQ(e->get_thread_info(false)->m_vmsize_kb, vmsize); EXPECT_EQ(e->get_thread_info(false)->m_vmrss_kb, vmrss); @@ -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(); #ifdef __LP64__ EXPECT_EQ((uint64_t)p, addr); #else @@ -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(); + exit_vmrss = e->get_param_by_name("vm_rss")->as(); EXPECT_EQ(e->get_thread_info(false)->m_vmsize_kb, exit_vmsize); EXPECT_EQ(e->get_thread_info(false)->m_vmrss_kb, exit_vmrss); @@ -701,8 +697,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_size")->m_val, sizeof(uint32_t)); + exit_vmsize = e->get_param_by_name("vm_size")->as(); + exit_vmrss = e->get_param_by_name("vm_rss")->as(); EXPECT_EQ(e->get_thread_info(false)->m_vmsize_kb, exit_vmsize); EXPECT_EQ(e->get_thread_info(false)->m_vmrss_kb, exit_vmrss); @@ -710,15 +706,13 @@ TEST_F(sys_call_test, mmap) { 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(); 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(); EXPECT_EQ((uint64_t)p, res); EXPECT_GT(exit_vmsize, enter_vmsize + 500); EXPECT_GE(exit_vmrss, enter_vmrss);