Skip to content

Commit

Permalink
test(aeva): fix wrongly compiledand thus skipped unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Max SCHMELLER <[email protected]>
  • Loading branch information
mojomex committed Dec 16, 2024
1 parent a75e32f commit b248dee
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 87 deletions.
17 changes: 2 additions & 15 deletions nebula_tests/aeva/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
)
47 changes: 0 additions & 47 deletions nebula_tests/aeva/aeva_hw_interface_test.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions nebula_tests/aeva/aeva_hw_interface_test.hpp

This file was deleted.

55 changes: 43 additions & 12 deletions nebula_tests/aeva/aeva_test_main.cpp
Original file line number Diff line number Diff line change
@@ -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 <nebula_common/aeva/config_types.hpp>
#include <nebula_hw_interfaces/nebula_hw_interfaces_aeva/connections/aeva_api.hpp>

#include <gtest/gtest.h>

#include <atomic>
#include <memory>
#include <thread>

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<nebula::test::MockByteStream>(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);
Expand Down

0 comments on commit b248dee

Please sign in to comment.