diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 64c2ed84b0..5735cfcfa6 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -102,6 +102,23 @@ jobs: capture_etw: true leak_detection: true + # Run the unit tests for NativeOnly build in GitHub. + unit_tests_native_only: + # Always run this job. + needs: regular_native-only + uses: ./.github/workflows/reusable-test.yml + with: + name: unit_tests + pre_test: appverif -enable Exceptions Handles Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe + # Exclude [processes] test that CodeCoverage can't work with. + test_command: .\unit_tests.exe -d yes ~[processes] + build_artifact: Build-x64 + environment: windows-2022 + code_coverage: true + gather_dumps: true + capture_etw: true + leak_detection: true + # Run the netebpfext unit tests in GitHub. netebpf_ext_unit_tests: # Always run this job. diff --git a/tests/end_to_end/end_to_end.cpp b/tests/end_to_end/end_to_end.cpp index e30fadd4eb..4296ea598b 100644 --- a/tests/end_to_end/end_to_end.cpp +++ b/tests/end_to_end/end_to_end.cpp @@ -1663,15 +1663,10 @@ _xdp_reflect_packet_test(ebpf_execution_type_t execution_type, ADDRESS_FAMILY ad program_info_provider_t xdp_program_info; REQUIRE(xdp_program_info.initialize(EBPF_PROGRAM_TYPE_XDP_TEST) == EBPF_SUCCESS); uint32_t ifindex = 0; + const char* file_name = (execution_type == EBPF_EXECUTION_NATIVE ? "reflect_packet_um.dll" : "reflect_packet.o"); program_load_attach_helper_t program_helper; program_helper.initialize( - SAMPLE_PATH "reflect_packet.o", - BPF_PROG_TYPE_XDP_TEST, - "reflect_packet", - execution_type, - &ifindex, - sizeof(ifindex), - hook); + file_name, BPF_PROG_TYPE_XDP_TEST, "reflect_packet", execution_type, &ifindex, sizeof(ifindex), hook); // Dummy UDP datagram with fake IP and MAC addresses. udp_packet_t packet(address_family); @@ -1698,6 +1693,18 @@ _xdp_reflect_packet_test(ebpf_execution_type_t execution_type, ADDRESS_FAMILY ad } } +static void +_xdp_reflect_packet_test_v4(ebpf_execution_type_t execution_type) +{ + _xdp_reflect_packet_test(execution_type, AF_INET); +} + +static void +_xdp_reflect_packet_test_v6(ebpf_execution_type_t execution_type) +{ + _xdp_reflect_packet_test(execution_type, AF_INET6); +} + static void _xdp_encap_reflect_packet_test(ebpf_execution_type_t execution_type, ADDRESS_FAMILY address_family) { @@ -1708,15 +1715,11 @@ _xdp_encap_reflect_packet_test(ebpf_execution_type_t execution_type, ADDRESS_FAM program_info_provider_t xdp_program_info; REQUIRE(xdp_program_info.initialize(EBPF_PROGRAM_TYPE_XDP_TEST) == EBPF_SUCCESS); uint32_t ifindex = 0; + const char* file_name = + (execution_type == EBPF_EXECUTION_NATIVE ? "encap_reflect_packet_um.dll" : "encap_reflect_packet.o"); program_load_attach_helper_t program_helper; program_helper.initialize( - SAMPLE_PATH "encap_reflect_packet.o", - BPF_PROG_TYPE_XDP_TEST, - "encap_reflect_packet", - execution_type, - &ifindex, - sizeof(ifindex), - hook); + file_name, BPF_PROG_TYPE_XDP_TEST, "encap_reflect_packet", execution_type, &ifindex, sizeof(ifindex), hook); // Dummy UDP datagram with fake IP and MAC addresses. udp_packet_t packet(address_family); @@ -1753,6 +1756,18 @@ _xdp_encap_reflect_packet_test(ebpf_execution_type_t execution_type, ADDRESS_FAM } } +static void +_xdp_encap_reflect_packet_test_v4(ebpf_execution_type_t execution_type) +{ + _xdp_encap_reflect_packet_test(execution_type, AF_INET); +} + +static void +_xdp_encap_reflect_packet_test_v6(ebpf_execution_type_t execution_type) +{ + _xdp_encap_reflect_packet_test(execution_type, AF_INET6); +} + #if !defined(CONFIG_BPF_INTERPRETER_DISABLED) TEST_CASE("printk", "[end_to_end]") { @@ -1811,20 +1826,25 @@ TEST_CASE("printk", "[end_to_end]") } #endif -TEST_CASE("xdp-reflect-v4-jit", "[xdp_tests]") { _xdp_reflect_packet_test(EBPF_EXECUTION_JIT, AF_INET); } -TEST_CASE("xdp-reflect-v6-jit", "[xdp_tests]") { _xdp_reflect_packet_test(EBPF_EXECUTION_JIT, AF_INET6); } -TEST_CASE("xdp-reflect-v4-interpret", "[xdp_tests]") { _xdp_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET); } -TEST_CASE("xdp-reflect-v6-interpret", "[xdp_tests]") { _xdp_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET6); } -TEST_CASE("xdp-encap-reflect-v4-jit", "[xdp_tests]") { _xdp_encap_reflect_packet_test(EBPF_EXECUTION_JIT, AF_INET); } -TEST_CASE("xdp-encap-reflect-v6-jit", "[xdp_tests]") { _xdp_encap_reflect_packet_test(EBPF_EXECUTION_JIT, AF_INET6); } -TEST_CASE("xdp-encap-reflect-v4-interpret", "[xdp_tests]") -{ - _xdp_encap_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET); -} -TEST_CASE("xdp-encap-reflect-v6-interpret", "[xdp_tests]") -{ - _xdp_encap_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET6); -} +DECLARE_ALL_TEST_CASES("xdp-reflect-v4", "[xdp_tests]", _xdp_reflect_packet_test_v4); +DECLARE_ALL_TEST_CASES("xdp-reflect-v6", "[xdp_tests]", _xdp_reflect_packet_test_v6); +DECLARE_ALL_TEST_CASES("xdp-encap-reflect-v4", "[xdp_tests]", _xdp_encap_reflect_packet_test_v4); +DECLARE_ALL_TEST_CASES("xdp-encap-reflect-v6", "[xdp_tests]", _xdp_encap_reflect_packet_test_v6); + +// TEST_CASE("xdp-reflect-v4-jit", "[xdp_tests]") { _xdp_reflect_packet_test_v4(EBPF_EXECUTION_JIT); } +// TEST_CASE("xdp-reflect-v6-jit", "[xdp_tests]") { _xdp_reflect_packet_test_v6(EBPF_EXECUTION_JIT); } +// TEST_CASE("xdp-reflect-v4-interpret", "[xdp_tests]") { _xdp_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET); } +// TEST_CASE("xdp-reflect-v6-interpret", "[xdp_tests]") { _xdp_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET6); +// } TEST_CASE("xdp-encap-reflect-v4-jit", "[xdp_tests]") { _xdp_encap_reflect_packet_test(EBPF_EXECUTION_JIT, AF_INET); +// } TEST_CASE("xdp-encap-reflect-v6-jit", "[xdp_tests]") { _xdp_encap_reflect_packet_test(EBPF_EXECUTION_JIT, +// AF_INET6); } TEST_CASE("xdp-encap-reflect-v4-interpret", "[xdp_tests]") +// { +// _xdp_encap_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET); +// } +// TEST_CASE("xdp-encap-reflect-v6-interpret", "[xdp_tests]") +// { +// _xdp_encap_reflect_packet_test(EBPF_EXECUTION_INTERPRET, AF_INET6); +// } #if !defined(CONFIG_BPF_INTERPRETER_DISABLED) || !defined(CONFIG_BPF_JIT_DISABLED) static void diff --git a/tests/end_to_end/netsh_test.cpp b/tests/end_to_end/netsh_test.cpp index 369c1ac381..ffa22e545e 100644 --- a/tests/end_to_end/netsh_test.cpp +++ b/tests/end_to_end/netsh_test.cpp @@ -415,6 +415,7 @@ verify_no_programs_exist() "====== ==== ===== ========= ============= ====================\n"); } +#if !defined(CONFIG_BPF_JIT_DISABLED) || !defined(CONFIG_BPF_INTERPRETER_DISABLED) TEST_CASE("pin first program", "[netsh][programs]") { _test_helper_netsh test_helper; @@ -897,6 +898,7 @@ TEST_CASE("cgroup_sock_addr compartment parameter", "[netsh][programs]") ebpf_epoch_synchronize(); } +#endif // !defined(CONFIG_BPF_JIT_DISABLED) || !defined(CONFIG_BPF_INTERPRETER_DISABLED) TEST_CASE("show processes", "[netsh][processes]") {