Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saxena-anurag committed Feb 29, 2024
1 parent 671241b commit c665c2f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 28 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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.
Expand Down
76 changes: 48 additions & 28 deletions tests/end_to_end/end_to_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -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]")
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/end_to_end/netsh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,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;
Expand Down Expand Up @@ -949,6 +950,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]")
{
Expand Down

0 comments on commit c665c2f

Please sign in to comment.