Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(tests): add some exceptions in sinsp test framework #2140

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions userspace/libscap/scap_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ int32_t scap_event_encode_params_v(const struct scap_sized_buffer event_buf,
}
break;
default:
ASSERT(false);
snprintf(error,
SCAP_LASTERR_SIZE,
"unexpected param %d length %zu for event with type %d",
Expand Down
10 changes: 8 additions & 2 deletions userspace/libsinsp/test/sinsp_with_test_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

if(ret != SCAP_INPUT_TOO_SMALL) {
va_end(args2);
return nullptr;
throw std::runtime_error(std::string("cannot compute the size of the event: ") + error);
}

event_buf.buf = malloc(event_size);
Expand All @@ -127,7 +127,7 @@
free(event_buf.buf);
event_buf.size = 0;
va_end(args2);
return nullptr;
throw std::runtime_error(std::string("cannot encode the event: ") + error);
}

scap_evt* event = static_cast<scap_evt*>(event_buf.buf);
Expand All @@ -150,6 +150,12 @@
}

scap_evt* event = create_event_v(ts, tid, event_type, n, args);
if(event == nullptr) {
std::stringstream ss;

Check warning on line 154 in userspace/libsinsp/test/sinsp_with_test_input.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/test/sinsp_with_test_input.cpp#L154

Added line #L154 was not covered by tests
ss << "cannot create event type: " << event_type << ", ts: " << ts << ", tid: " << tid
<< ", n: " << n;
throw std::runtime_error(ss.str());
}

uint64_t evtoffset = m_events.size() - m_test_data.event_count;
m_events.push_back(event);
Expand Down
Loading