From b248dee7f0d7112468a291e7f80a500a38e087c9 Mon Sep 17 00:00:00 2001 From: Max SCHMELLER Date: Mon, 16 Dec 2024 10:12:39 +0900 Subject: [PATCH] test(aeva): fix wrongly compiledand thus skipped unit test Signed-off-by: Max SCHMELLER --- nebula_tests/aeva/CMakeLists.txt | 17 +----- nebula_tests/aeva/aeva_hw_interface_test.cpp | 47 ----------------- nebula_tests/aeva/aeva_hw_interface_test.hpp | 13 ----- nebula_tests/aeva/aeva_test_main.cpp | 55 +++++++++++++++----- 4 files changed, 45 insertions(+), 87 deletions(-) delete mode 100644 nebula_tests/aeva/aeva_hw_interface_test.cpp delete mode 100644 nebula_tests/aeva/aeva_hw_interface_test.hpp diff --git a/nebula_tests/aeva/CMakeLists.txt b/nebula_tests/aeva/CMakeLists.txt index 26d05fad6..f9e6bf38e 100644 --- a/nebula_tests/aeva/CMakeLists.txt +++ b/nebula_tests/aeva/CMakeLists.txt @@ -1,24 +1,11 @@ -add_library(aeva_hw_interface_test SHARED - aeva_hw_interface_test.cpp) - -target_include_directories(aeva_hw_interface_test PUBLIC - ${NEBULA_TEST_INCLUDE_DIRS} -) - -target_link_libraries(aeva_hw_interface_test - ${AEVA_TEST_LIBRARIES} -) - ament_add_gtest(aeva_test_main aeva_test_main.cpp ) target_include_directories(aeva_test_main PUBLIC - ${PROJECT_SOURCE_DIR}/src/aeva - include ${NEBULA_TEST_INCLUDE_DIRS} ) target_link_libraries(aeva_test_main -aeva_hw_interface_test -) + ${AEVA_TEST_LIBRARIES} +) \ No newline at end of file diff --git a/nebula_tests/aeva/aeva_hw_interface_test.cpp b/nebula_tests/aeva/aeva_hw_interface_test.cpp deleted file mode 100644 index c4d51d0cb..000000000 --- a/nebula_tests/aeva/aeva_hw_interface_test.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2024 TIER IV, Inc. - -#include "aeva_hw_interface_test.hpp" - -#include "../common/mock_byte_stream.hpp" -#include "../data/aeva/tcp_stream.hpp" -#include "nebula_hw_interfaces/nebula_hw_interfaces_aeva/connections/pointcloud.hpp" - -#include -#include - -#include - -#include -#include -#include - -using nebula::drivers::aeva::PointCloudMessage; -using nebula::drivers::connections::aeva::PointcloudParser; - -TEST(TestParsing, Pointcloud) // NOLINT -{ - using std::chrono_literals::operator""ms; - - auto mock_byte_stream = std::make_shared(STREAM); - PointcloudParser parser(mock_byte_stream); - std::atomic_bool done = false; - - PointcloudParser::callback_t callback = [&](const PointCloudMessage & arg) { - if (done) return; - - EXPECT_EQ(arg.header.aeva_marker, 0xAE5Au); - EXPECT_EQ(arg.header.platform, 2); - - EXPECT_GT(arg.points.size(), 0); - EXPECT_TRUE(mock_byte_stream->done()); - EXPECT_EQ(mock_byte_stream->get_read_count(), 2); - done = true; - }; - - parser.register_callback(std::move(callback)); - - mock_byte_stream->run(); - while (!done) { - std::this_thread::yield(); - } -} diff --git a/nebula_tests/aeva/aeva_hw_interface_test.hpp b/nebula_tests/aeva/aeva_hw_interface_test.hpp deleted file mode 100644 index a31160f2e..000000000 --- a/nebula_tests/aeva/aeva_hw_interface_test.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2024 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. diff --git a/nebula_tests/aeva/aeva_test_main.cpp b/nebula_tests/aeva/aeva_test_main.cpp index 2ceaec2d4..1e54fa67f 100644 --- a/nebula_tests/aeva/aeva_test_main.cpp +++ b/nebula_tests/aeva/aeva_test_main.cpp @@ -1,19 +1,50 @@ // Copyright 2024 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. + +#include "../common/mock_byte_stream.hpp" +#include "../data/aeva/tcp_stream.hpp" +#include "nebula_hw_interfaces/nebula_hw_interfaces_aeva/connections/pointcloud.hpp" + +#include +#include #include +#include +#include +#include + +using nebula::drivers::aeva::PointCloudMessage; +using nebula::drivers::connections::aeva::PointcloudParser; + +TEST(TestParsing, Pointcloud) // NOLINT +{ + using std::chrono_literals::operator""ms; + + auto mock_byte_stream = std::make_shared(STREAM); + PointcloudParser parser(mock_byte_stream); + std::atomic_bool done = false; + + PointcloudParser::callback_t callback = [&](const PointCloudMessage & arg) { + if (done) return; + + EXPECT_EQ(arg.header.aeva_marker, 0xAE5Au); + EXPECT_EQ(arg.header.platform, 2); + + EXPECT_GT(arg.points.size(), 0); + EXPECT_TRUE(mock_byte_stream->done()); + EXPECT_EQ(mock_byte_stream->get_read_count(), 2); + done = true; + }; + + parser.register_callback(std::move(callback)); + + mock_byte_stream->run(); + while (!done) { + std::this_thread::yield(); + } +} + + int main(int argc, char * argv[]) { ::testing::InitGoogleTest(&argc, argv);