Skip to content

Commit 7c19d46

Browse files
committed
PR feedback
Signed-off-by: Alan Jowett <alanjo@microsoft.com>
1 parent 9042f82 commit 7c19d46

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

tests/api_test/api_test.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,7 @@ TEST_CASE("ebpf_type_conversion_apis", "[ebpf_api]")
16431643
// Verify the lookup worked by converting back to name.
16441644
const char* retrieved_name = ebpf_get_program_type_name(&program_type);
16451645
REQUIRE(retrieved_name != nullptr);
1646+
REQUIRE(std::string(retrieved_name) == "bind");
16461647
REQUIRE(strlen(retrieved_name) > 0);
16471648
}
16481649

@@ -1679,6 +1680,17 @@ TEST_CASE("ebpf_enumerate_programs", "[ebpf_api]")
16791680
// Verify we got some program info.
16801681
REQUIRE(program_infos->section_name != nullptr);
16811682
REQUIRE(strlen(program_infos->section_name) > 0);
1683+
if (std::string(file) == "test_sample_ebpf.o") {
1684+
REQUIRE(std::string(program_infos->section_name) == "sample_ext");
1685+
REQUIRE(std::string(program_infos->program_name) == "test_program_entry");
1686+
REQUIRE(program_infos->program_type == EBPF_PROGRAM_TYPE_SAMPLE);
1687+
REQUIRE(program_infos->expected_attach_type == EBPF_ATTACH_TYPE_SAMPLE);
1688+
} else if (std::string(file) == "bindmonitor.o") {
1689+
REQUIRE(std::string(program_infos->section_name) == "bind");
1690+
REQUIRE(std::string(program_infos->program_name) == "BindMonitor");
1691+
REQUIRE(program_infos->program_type == EBPF_PROGRAM_TYPE_BIND);
1692+
REQUIRE(program_infos->expected_attach_type == EBPF_ATTACH_TYPE_BIND);
1693+
}
16821694

16831695
// Clean up.
16841696
ebpf_free_programs(program_infos);
@@ -1781,8 +1793,14 @@ TEST_CASE("ebpf_object_apis", "[ebpf_api]")
17811793
ebpf_map_info_t* map_info = nullptr;
17821794
ebpf_result_t result = ebpf_api_get_pinned_map_info(&map_count, &map_info);
17831795
REQUIRE(result == EBPF_SUCCESS);
1784-
REQUIRE(map_count > 0);
1796+
REQUIRE(map_count == 1);
17851797
REQUIRE(map_info != nullptr);
1798+
REQUIRE(map_info[0].definition.type == BPF_MAP_TYPE_ARRAY);
1799+
REQUIRE(std::string(map_info[0].pin_path) == "BPF:\\test_map_pin");
1800+
REQUIRE(map_info[0].definition.key_size == sizeof(uint32_t));
1801+
REQUIRE(map_info[0].definition.value_size == sizeof(uint32_t));
1802+
REQUIRE(map_info[0].definition.max_entries == 1);
1803+
REQUIRE(map_info[0].definition.inner_map_id == 0);
17861804

17871805
// Clean up pinned map info returned by the API.
17881806
ebpf_api_map_info_free(map_count, map_info);
@@ -1795,6 +1813,12 @@ TEST_CASE("ebpf_object_apis", "[ebpf_api]")
17951813
result = ebpf_object_unpin(pin_path);
17961814
REQUIRE(result != EBPF_SUCCESS);
17971815

1816+
// Verify that the map can no longer be found via ebpf_api_get_pinned_map_info.
1817+
result = ebpf_api_get_pinned_map_info(&map_count, &map_info);
1818+
REQUIRE(result == EBPF_SUCCESS);
1819+
REQUIRE(map_count == 0);
1820+
REQUIRE(map_info == nullptr);
1821+
17981822
// Close the map fd.
17991823
_close(map_fd);
18001824
}
@@ -1849,9 +1873,7 @@ TEST_CASE("ebpf_object_execution_type_apis", "[ebpf_api]")
18491873
if (object != nullptr) {
18501874
// Test getting the default execution type.
18511875
ebpf_execution_type_t exec_type = ebpf_object_get_execution_type(object);
1852-
REQUIRE(
1853-
(exec_type == EBPF_EXECUTION_ANY || exec_type == EBPF_EXECUTION_JIT ||
1854-
exec_type == EBPF_EXECUTION_INTERPRET || exec_type == EBPF_EXECUTION_NATIVE));
1876+
REQUIRE(exec_type == EBPF_EXECUTION_ANY);
18551877

18561878
// Test setting execution type.
18571879
ebpf_result_t result = ebpf_object_set_execution_type(object, EBPF_EXECUTION_INTERPRET);

0 commit comments

Comments
 (0)