Skip to content

Commit

Permalink
update(test): fix failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: rohith-raju <rohithraju488@gmail.com>
  • Loading branch information
Rohith-Raju committed Jul 9, 2023
1 parent 61e1dc5 commit 0c6ad89
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions driver/ppm_flag_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ or GPL2.txt for full copies of the license.
#include <linux/capability.h>
#include <linux/eventpoll.h>
#include <linux/prctl.h>
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0))
#include <linux/pidfd.h>
#endif
#include "ppm.h"
#ifdef __NR_memfd_create
#include <uapi/linux/memfd.h>
Expand Down Expand Up @@ -2085,6 +2087,16 @@ static __always_inline uint32_t pidfd_open_flags_to_scap(uint32_t flags)
#ifdef PIDFD_NONBLOCK
if(flags & PIDFD_NONBLOCK) res |= PPM_PIDFD_NONBLOCK;
#endif

/*
PIDFD_NONBLOCK is available only on kernal versions > 5.10.00, hence used O_NONBLOCK
See https://elixir.bootlin.com/linux/v5.10.185/source/include/uapi/linux/pidfd.h#L10
*/

#ifdef O_NONBLOCK
if(flags & O_NONBLOCK) res |= PPM_PIDFD_NONBLOCK;
#endif

return res;
}

Expand Down
8 changes: 7 additions & 1 deletion test/drivers/test_suites/syscall_exit_suite/pidfd_open_x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@

#ifdef __NR_pidfd_open

#ifdef __NR_fork
TEST(SyscallExit, pidfd_openX_success)
{
auto evt_test = get_syscall_event_test(__NR_pidfd_open, EXIT_EVENT);

evt_test->enable_capture();

/*=============================== TRIGGER SYSCALL ===========================*/

/*
PIDFD_NONBLOCK is available only on kernal versions > 5.10.00, hence used O_NONBLOCK
See https://elixir.bootlin.com/linux/v5.10.185/source/include/uapi/linux/pidfd.h#L10
*/

int flags = O_NONBLOCK;
pid_t pid = syscall(__NR_fork);
if(pid == 0)
Expand Down Expand Up @@ -54,6 +59,7 @@ TEST(SyscallExit, pidfd_openX_success)
/*=============================== ASSERT PARAMETERS ===========================*/

}
#endif

TEST(SyscallExit, pidfd_openX_failure)
{
Expand Down
4 changes: 2 additions & 2 deletions userspace/libsinsp/test/public_sinsp_API/ppm_sc_codes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ const libsinsp::events::set<ppm_event_code> expected_sinsp_state_event_set = {
PPME_ASYNCEVENT_E,
PPME_SYSCALL_MEMFD_CREATE_E,
PPME_SYSCALL_MEMFD_CREATE_X,
PPME_SYSCALL_PIDFD_GETFD_E,
PPME_SYSCALL_PIDFD_GETFD_X
PPME_SYSCALL_PIDFD_OPEN_E,
PPME_SYSCALL_PIDFD_OPEN_X
};

const libsinsp::events::set<ppm_sc_code> expected_sinsp_state_sc_set = {
Expand Down

0 comments on commit 0c6ad89

Please sign in to comment.