Skip to content

Commit 196708b

Browse files
committed
Modified specific netsh_test to include all eBPF program types.
1 parent 5351c84 commit 196708b

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

tests/end_to_end/netsh_test.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,15 +1108,14 @@ TEST_CASE("show processes", "[netsh][processes]")
11081108
}
11091109
}
11101110

1111-
#if !defined(CONFIG_BPF_JIT_DISABLED) || !defined(CONFIG_BPF_INTERPRETER_DISABLED)
1112-
1113-
TEST_CASE("pin/unpin program", "[netsh][pin]")
1111+
static void
1112+
_test_pin_unpin_program(ebpf_execution_type_t execution_type)
11141113
{
11151114
_test_helper_netsh test_helper;
11161115
test_helper.initialize();
11171116
int result = 0;
1118-
auto output =
1119-
_run_netsh_command(handle_ebpf_add_program, L"bindmonitor.o", nullptr, L"pinpath=bindmonitor", &result);
1117+
const wchar_t* file_name = (execution_type == EBPF_EXECUTION_NATIVE ? L"bindmonitor_um.dll" : L"bindmonitor.o");
1118+
auto output = _run_netsh_command(handle_ebpf_add_program, file_name, nullptr, L"pinpath=bindmonitor", &result);
11201119
REQUIRE(result == EBPF_SUCCESS);
11211120
const char prefix[] = "Loaded with ID";
11221121
REQUIRE(output.substr(0, sizeof(prefix) - 1) == prefix);
@@ -1155,6 +1154,9 @@ TEST_CASE("pin/unpin program", "[netsh][pin]")
11551154
_run_netsh_command(handle_ebpf_delete_program, sid.c_str(), nullptr, nullptr, &result);
11561155
}
11571156

1157+
DECLARE_ALL_TEST_CASES("pin/unpin program", "[netsh][pin]", _test_pin_unpin_program);
1158+
1159+
#if !defined(CONFIG_BPF_JIT_DISABLED) || !defined(CONFIG_BPF_INTERPRETER_DISABLED)
11581160
TEST_CASE("pin/unpin map", "[netsh][pin]")
11591161
{
11601162
_test_helper_netsh test_helper;

tests/end_to_end/netsh_test_helper.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,33 @@
1919
#pragma region
2020
// Mock Netsh.exe APIs.
2121

22+
#define CONCAT(s1, s2) s1 s2
23+
#define DECLARE_TEST_CASE(_name, _group, _function, _suffix, _execution_type) \
24+
TEST_CASE(CONCAT(_name, _suffix), _group) { _function(_execution_type); }
25+
#define DECLARE_NATIVE_TEST(_name, _group, _function) \
26+
DECLARE_TEST_CASE(_name, _group, _function, "-native", EBPF_EXECUTION_NATIVE)
27+
#if !defined(CONFIG_BPF_JIT_DISABLED)
28+
#define DECLARE_JIT_TEST(_name, _group, _function) \
29+
DECLARE_TEST_CASE(_name, _group, _function, "-jit", EBPF_EXECUTION_JIT)
30+
#else
31+
#define DECLARE_JIT_TEST(_name, _group, _function)
32+
#endif
33+
#if !defined(CONFIG_BPF_INTERPRETER_DISABLED)
34+
#define DECLARE_INTERPRET_TEST(_name, _group, _function) \
35+
DECLARE_TEST_CASE(_name, _group, _function, "-interpret", EBPF_EXECUTION_INTERPRET)
36+
#else
37+
#define DECLARE_INTERPRET_TEST(_name, _group, _function)
38+
#endif
39+
40+
#define DECLARE_ALL_TEST_CASES(_name, _group, _function) \
41+
DECLARE_JIT_TEST(_name, _group, _function) \
42+
DECLARE_NATIVE_TEST(_name, _group, _function) \
43+
DECLARE_INTERPRET_TEST(_name, _group, _function)
44+
45+
#define DECLARE_JIT_TEST_CASES(_name, _group, _function) \
46+
DECLARE_JIT_TEST(_name, _group, _function) \
47+
DECLARE_NATIVE_TEST(_name, _group, _function)
48+
2249
// This function has incorrect SAL annotations, but it's declared in public headers so we can't fix it.
2350
DWORD WINAPI
2451
PreprocessCommand(

0 commit comments

Comments
 (0)