Skip to content

Commit 46be640

Browse files
committed
update
1 parent 1ced728 commit 46be640

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

runtime/unit-test/maps/test_map_handler.cpp

+34-20
Original file line numberDiff line numberDiff line change
@@ -234,27 +234,41 @@ TEST_CASE("Test map handler")
234234
{
235235
auto rb_ptr = ((uint64_t)1 << 32);
236236
std::vector<std::thread> thds;
237-
thds.push_back(std::thread([=]() {
238-
for (int i = 1; i <= 100; i++) {
239-
void *ptr = (void *)(uintptr_t)
240-
bpf_ringbuf_reserve(rb_ptr,
241-
sizeof(int),
242-
0, 0, 0);
243-
REQUIRE(ptr != nullptr);
244-
memcpy(ptr, &i, sizeof(int));
245-
if (i % 2 == 0) {
246-
// discard it
247-
bpf_ringbuf_discard(
248-
(uintptr_t)ptr, 0, 0, 0,
249-
0);
250-
} else {
251-
// submit it
252-
bpf_ringbuf_submit(
253-
(uintptr_t)ptr, 0, 0, 0,
254-
0);
237+
SECTION("Test with reserve+commit")
238+
{
239+
thds.push_back(std::thread([=]() {
240+
for (int i = 1; i <= 100; i++) {
241+
void *ptr = (void *)(uintptr_t)
242+
bpf_ringbuf_reserve(
243+
rb_ptr,
244+
sizeof(int), 0,
245+
0, 0);
246+
REQUIRE(ptr != nullptr);
247+
memcpy(ptr, &i, sizeof(int));
248+
if (i % 2 == 0) {
249+
// discard it
250+
bpf_ringbuf_discard(
251+
(uintptr_t)ptr,
252+
0, 0, 0, 0);
253+
} else {
254+
// submit it
255+
bpf_ringbuf_submit(
256+
(uintptr_t)ptr,
257+
0, 0, 0, 0);
258+
}
255259
}
256-
}
257-
}));
260+
}));
261+
}
262+
SECTION("Test with output")
263+
{
264+
thds.push_back(std::thread([=]() {
265+
for (int i = 1; i <= 100; i += 2) {
266+
bpf_ringbuf_output(
267+
rb_ptr, (uintptr_t)&i,
268+
sizeof(i), 0, 0);
269+
}
270+
}));
271+
}
258272
auto impl = map.try_get_ringbuf_map_impl()
259273
.value()
260274
->create_impl_shared_ptr();

runtime/unit-test/runtime/test_helpers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ TEST_CASE("Test helpers probe_read/probe_write_user/probe_read_str", "[helper]")
5353
}
5454
SECTION("probe write user")
5555
{
56-
REQUIRE(bpftime_probe_read((uintptr_t)&buf2, sizeof(buf1),
57-
(uintptr_t)&buf1, 0, 0) == 0);
56+
REQUIRE(bpftime_probe_write_user((uintptr_t)&buf2, sizeof(buf1),
57+
(uintptr_t)&buf1, 0, 0) == 0);
5858
}
5959
SECTION("bpf_probe_read_str")
6060
{

0 commit comments

Comments
 (0)