Skip to content

Commit

Permalink
chore(userspace/libsinsp): apply review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
Co-authored-by: Luca Guerra <luca@guerra.sh>
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
  • Loading branch information
jasondellaluce and LucaGuerra committed Apr 9, 2024
1 parent 1ad68ad commit c4a1b84
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
12 changes: 2 additions & 10 deletions userspace/libsinsp/test/eventformatter.ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,18 @@ class sinsp_formatter_test : public sinsp_with_test_input
open_inspector();
}

void TearDown() override
{
m_last_res = false;
m_last_output.clear();
m_last_field_names.clear();
m_last_field_values.clear();
}

void format(const std::string& fmt,
sinsp_evt_formatter::output_format of = sinsp_evt_formatter::output_format::OF_NORMAL)
{
sinsp_evt_formatter f(&m_inspector, fmt, m_filter_list);
auto evt = generate_getcwd_exit_event();
auto evt = generate_getcwd_failed_entry_event();
f.get_field_names(m_last_field_names);
auto r1 = f.resolve_tokens(evt, m_last_field_values);
auto r2 = f.tostring_withformat(evt, m_last_output, of);
m_last_res = r1 && r2;
}

bool m_last_res;
bool m_last_res = false;
std::string m_last_output;
std::vector<std::string> m_last_field_names;
std::map<std::string,std::string> m_last_field_values;
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/test/filter_compiler.ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,5 @@ TEST_F(sinsp_with_test_input, filter_simple_evaluation)
// Basic case just to assert that the basic setup works
add_default_init_thread();
open_inspector();
ASSERT_TRUE(evaluate_filter_str(&m_inspector, "(evt.type = getcwd)", generate_getcwd_exit_event()));
ASSERT_TRUE(evaluate_filter_str(&m_inspector, "(evt.type = getcwd)", generate_getcwd_failed_entry_event()));
}
2 changes: 1 addition & 1 deletion userspace/libsinsp/test/sinsp_with_test_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ sinsp_evt* sinsp_with_test_input::generate_random_event(int64_t tid_caller)
return add_event_advance_ts(increasing_ts(), tid_caller, PPME_SYSCALL_GETCWD_E, 0);
}

sinsp_evt* sinsp_with_test_input::generate_getcwd_exit_event(int64_t tid_caller)
sinsp_evt* sinsp_with_test_input::generate_getcwd_failed_entry_event(int64_t tid_caller)
{
int64_t err = -1;
std::string path = "/test/dir";
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/test/sinsp_with_test_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class sinsp_with_test_input : public ::testing::Test
void remove_thread(int64_t tid_to_remove, int64_t reaper_tid);
sinsp_evt* generate_proc_exit_event(int64_t tid_to_remove, int64_t reaper_tid);
sinsp_evt* generate_random_event(int64_t tid_caller = INIT_TID);
sinsp_evt* generate_getcwd_exit_event(int64_t tid_caller = INIT_TID);
sinsp_evt* generate_getcwd_failed_entry_event(int64_t tid_caller = INIT_TID);

//=============================== PROCESS GENERATION ===========================

Expand Down

0 comments on commit c4a1b84

Please # to comment.