Skip to content

Commit 3a9a4c0

Browse files
LakshK98Laksh Kotian
andauthored
Add test for libbpf attach type by name (#264)
* add netevent test * add type test ntos * mend --------- Co-authored-by: Laksh Kotian <[email protected]>
1 parent 60a5758 commit 3a9a4c0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/neteventebpfext/neteventebpfext_unit/netevent_ebpfext_unit.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "cxplat_passed_test_log.h"
1212
#include "ebpf_netevent_hooks.h"
1313
#include "ebpf_netevent_program_attach_type_guids.h"
14+
#include "ebpf_structs.h"
1415
#include "netevent_ebpf_ext_helper.h"
1516
#include "netevent_ebpf_ext_program_info.h"
1617
#include "utils.h"
@@ -513,4 +514,13 @@ TEST_CASE("netevent_bpf_prog_run_test", "[neteventebpfext]")
513514
// Stop and unload the neteventebpfext extension driver (NPI client).
514515
REQUIRE(neteventebpfext_driver.stop() == true);
515516
REQUIRE(neteventebpfext_driver.unload() == true);
517+
}
518+
519+
TEST_CASE("libbpf attach type names", "[neteventebpfext][libbpf]")
520+
{
521+
enum bpf_attach_type attach_type;
522+
const char* type_str = libbpf_bpf_attach_type_str(BPF_ATTACH_TYPE_NETEVENT);
523+
524+
REQUIRE(libbpf_attach_type_by_name(type_str, &attach_type) == 0);
525+
REQUIRE(attach_type == BPF_ATTACH_TYPE_NETEVENT);
516526
}

tests/ntosebpfext/ntosebpfext_unit/ntos_ebpfext_unit.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#include "cxplat_fault_injection.h"
77
#include "cxplat_passed_test_log.h"
88
#include "ebpf_ntos_hooks.h"
9+
#include "ebpf_structs.h"
910
#include "ntos_ebpf_ext_helper.h"
1011
#include "watchdog.h"
1112

13+
#include <bpf/libbpf.h>
1214
#include <map>
1315
#include <stop_token>
1416
#include <thread>
@@ -231,4 +233,13 @@ TEST_CASE("process create and exit times", "[ntosebpfext]")
231233
REQUIRE((int)client_context.process_context.operation == PROCESS_OPERATION_DELETE);
232234
}
233235

236+
TEST_CASE("libbpf attach type names", "[ntosebpfext][libbpf]")
237+
{
238+
enum bpf_attach_type attach_type;
239+
const char* type_str = libbpf_bpf_attach_type_str(BPF_ATTACH_TYPE_PROCESS);
240+
241+
REQUIRE(libbpf_attach_type_by_name(type_str, &attach_type) == 0);
242+
REQUIRE(attach_type == BPF_ATTACH_TYPE_PROCESS);
243+
}
244+
234245
#pragma endregion process

0 commit comments

Comments
 (0)