Skip to content

Commit

Permalink
cleanup(libsinsp): cleaned up libsinsp tests by removing ifdefs.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
FedeDP committed Mar 2, 2023
1 parent 0c30c89 commit 5b86740
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 296 deletions.
4 changes: 2 additions & 2 deletions userspace/libscap/linux/scap_ppm_sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ int scap_get_modifies_state_ppm_sc(OUT uint8_t ppm_sc_array[PPM_SC_MAX])
for (int event_nr = 2; event_nr < PPM_EVENT_MAX; event_nr++)
{
if (g_event_info[event_nr].flags & EF_MODIFIES_STATE &&
(g_event_info[event_nr].category & EC_SYSCALL ||
g_event_info[event_nr].category & EC_TRACEPOINT))
(g_event_info[event_nr].category & EC_SYSCALL))
// TODO || g_event_info[event_nr].category & EC_TRACEPOINT))
{
events_array[event_nr] = 1;
}
Expand Down
1 change: 0 additions & 1 deletion userspace/libsinsp/events/sinsp_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ std::unordered_set<std::string> libsinsp::events::event_set_to_names(const libsi

libsinsp::events::set<ppm_event_code> libsinsp::events::names_to_event_set(const std::unordered_set<std::string>& events)
{
libsinsp::events::set<ppm_event_code> ppm_event_set = {};
std::unordered_set<std::string> remaining_events = events;
libsinsp::events::set<ppm_event_code> ppm_event_set;

Expand Down
33 changes: 0 additions & 33 deletions userspace/libsinsp/test/public_sinsp_API/events_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ limitations under the License.

#include <gtest/gtest.h>
#include <sinsp.h>
#include <sys/syscall.h>
#include "../test_utils.h"
// We need to include syscall compat tables
#ifdef __x86_64__
#include "syscall_compat_x86_64.h"
#elif __aarch64__
#include "syscall_compat_aarch64.h"
#elif __s390x__
#include "syscall_compat_s390x.h"
#endif /* __x86_64__ */

TEST(events_set, check_size)
{
Expand Down Expand Up @@ -150,8 +141,6 @@ TEST(events_set, names_to_event_set)
PPME_SYSCALL_EXECVEAT_E, PPME_SYSCALL_EXECVEAT_X, PPME_GENERIC_E, PPME_GENERIC_X};
ASSERT_PPM_EVENT_CODES_EQ(event_set_truth, event_set);
ASSERT_EQ(event_set.size(), 8); // enter/exit events for each event name, special case "openat" has 4 PPME instead of 2
ASSERT_TRUE(event_codes.contains(PPME_GENERIC_X));
ASSERT_EQ(event_codes.size(), 6); // enter/exit events for each event name
}

// Tests that no generic ppm sc is mapped to an event too
Expand All @@ -177,43 +166,21 @@ TEST(events_set, event_set_to_names)
TEST(events_set, sc_set_to_event_set)
{
libsinsp::events::set<ppm_sc_code> sc_set = {
#ifdef __NR_kill
PPM_SC_KILL,
#endif

#ifdef __NR_sendto
PPM_SC_SENDTO,
#endif

#ifdef __NR_setresuid
PPM_SC_SETRESUID, // note: corner case PPM_SC_SETRESUID32 would fail
#endif

#ifdef __NR_alarm
PPM_SC_ALARM,
#endif
};

libsinsp::events::set<ppm_event_code> event_set_truth = {
#ifdef __NR_kill
PPME_SYSCALL_KILL_E,
PPME_SYSCALL_KILL_X,
#endif

#ifdef __NR_sendto
PPME_SOCKET_SENDTO_E,
PPME_SOCKET_SENDTO_X,
#endif

#ifdef __NR_setresuid
PPME_SYSCALL_SETRESUID_E,
PPME_SYSCALL_SETRESUID_X,
#endif

#ifdef __NR_alarm
PPME_GENERIC_E,
PPME_GENERIC_X,
#endif
};

auto event_set = libsinsp::events::sc_set_to_event_set(sc_set);
Expand Down
Loading

0 comments on commit 5b86740

Please sign in to comment.