diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7afc05ee..f48ccb07 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,6 +20,12 @@ target_link_libraries(neotests PRIVATE tomlplusplus::tomlplusplus ) +# # NOTE: Add `-Wno-maybe-uninitialized` for g++ because g++ doesn't work well +# # with Catch2 macros. Consider removing this if later switching to googletest. +# if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +# target_compile_options(neotests PRIVATE -Wno-maybe-uninitialized) +# endif() + # target_link_libraries(main PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main) # add_custom_target(neotests-setcap ALL diff --git a/tests/driver/docker.cpp b/tests/driver/docker.cpp index be374813..89cdc1f6 100644 --- a/tests/driver/docker.cpp +++ b/tests/driver/docker.cpp @@ -79,8 +79,8 @@ TEST_CASE("docker") { mutex mtx; // lock for recv_pkts condition_variable cv; // for reading recv_pkts unique_lock lck(mtx); - Interface *eth0; - Interface *eth1; + Interface *eth0 = nullptr; + Interface *eth1 = nullptr; REQUIRE_NOTHROW(eth0 = node->get_intfs().at("eth0")); REQUIRE_NOTHROW(eth1 = node->get_intfs().at("eth1")); diff --git a/tests/dropmon.cpp b/tests/dropmon.cpp index 7b44ab5e..fb58a259 100644 --- a/tests/dropmon.cpp +++ b/tests/dropmon.cpp @@ -24,11 +24,11 @@ TEST_CASE("dropmon") { const string inputfn = test_data_dir + "/docker-drop.toml"; REQUIRE_NOTHROW(ConfigParser().parse(inputfn, plankton)); const auto &network = plankton.network(); - DockerNode *node; + DockerNode *node = nullptr; REQUIRE_NOTHROW(node = static_cast(network.nodes().at("fw"))); REQUIRE(node); - Interface *eth0; - Interface *eth1; + Interface *eth0 = nullptr; + Interface *eth1 = nullptr; REQUIRE_NOTHROW(eth0 = node->get_intfs().at("eth0")); REQUIRE_NOTHROW(eth1 = node->get_intfs().at("eth1")); REQUIRE(eth0); @@ -85,11 +85,11 @@ TEST_CASE("dropmon") { REQUIRE_NOTHROW(dm.start_listening_for(pkt, &docker)); // Send the ping packet REQUIRE_NOTHROW(docker.unpause()); - size_t nwrite; + size_t nwrite = 0; REQUIRE_NOTHROW(nwrite = docker.inject_packet(pkt)); CHECK(nwrite == 42); // Get the kernel drop timestamp (blocking) - uint64_t drop_ts; + uint64_t drop_ts = 0; REQUIRE_NOTHROW(drop_ts = dm.get_drop_ts(timeout)); CHECK(drop_ts > 0); REQUIRE_NOTHROW(docker.pause()); @@ -186,7 +186,7 @@ TEST_CASE("dropmon") { REQUIRE_NOTHROW(start_dm_thread()); // Send the ping packet REQUIRE_NOTHROW(docker.unpause()); - size_t nwrite; + size_t nwrite = 0; REQUIRE_NOTHROW(nwrite = docker.inject_packet(pkt)); CHECK(nwrite == 42); // Get the kernel drop timestamp (blocking) diff --git a/tests/droptrace.cpp b/tests/droptrace.cpp index 22a09870..f115bab0 100644 --- a/tests/droptrace.cpp +++ b/tests/droptrace.cpp @@ -25,11 +25,11 @@ TEST_CASE("droptrace") { const string inputfn = test_data_dir + "/docker-drop.toml"; REQUIRE_NOTHROW(ConfigParser().parse(inputfn, plankton)); const auto &network = plankton.network(); - DockerNode *node; + DockerNode *node = nullptr; REQUIRE_NOTHROW(node = static_cast(network.nodes().at("fw"))); REQUIRE(node); - Interface *eth0; - Interface *eth1; + Interface *eth0 = nullptr; + Interface *eth1 = nullptr; REQUIRE_NOTHROW(eth0 = node->get_intfs().at("eth0")); REQUIRE_NOTHROW(eth1 = node->get_intfs().at("eth1")); REQUIRE(eth0); @@ -84,8 +84,8 @@ TEST_CASE("droptrace") { REQUIRE_NOTHROW(dt.start()); // Open and load the BPF program Packet pkt; - size_t nwrite; - uint64_t drop_ts; + size_t nwrite = 0; + uint64_t drop_ts = 0; // Ping request packet from node1 to node2 pkt = Packet(eth0, "192.168.1.2", "192.168.2.2", 0, 0, 0, 0, @@ -207,7 +207,7 @@ TEST_CASE("droptrace") { }; Packet pkt; - size_t nwrite; + size_t nwrite = 0; // Ping request packet from node1 to node2 pkt = Packet(eth0, "192.168.1.2", "192.168.2.2", 0, 0, 0, 0,