From de11948cc1e47abf368f19d13bcd328626d3ff49 Mon Sep 17 00:00:00 2001 From: nebraszka Date: Mon, 11 Mar 2024 16:01:11 +0100 Subject: [PATCH] Rename test & change its location --- CMakeLists.txt | 4 ++-- test/CMakeLists.txt | 12 ++++++------ test/src/TapedTest.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 test/src/TapedTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bd34c66c..447688b65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,8 @@ set(RGL_AUTO_TAPE_PATH "" CACHE STRING # STRING prevents from expanding relativ # Test configuration set(RGL_BUILD_TESTS ON CACHE BOOL "Enables building test. GTest will be automatically downloaded") -set(RGL_BUILD_INTEGRATION_TEST OFF CACHE BOOL - "Enables building integration test using Tape. Benchmark data will be automatically downloaded from RGL-blobs repository") +set(RGL_BUILD_TAPED_TEST OFF CACHE BOOL + "Enables building taped test. Benchmark data will be automatically downloaded from RGL-blobs repository") # Tools configuration set(RGL_BUILD_TOOLS ON CACHE BOOL "Enables building RGL executable tools") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0913dafa2..c5c91a6a0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -122,21 +122,21 @@ include(FetchContent) if (RGL_BUILD_INTEGRATION_TEST) FetchContent_Declare( - rgltest + tapedtest GIT_REPOSITORY git@github.com:RobotecAI/RGL-blobs.git GIT_TAG test/integration-using-tape ) - FetchContent_GetProperties(rgltest) - if (NOT rgltest_POPULATED) - FetchContent_Populate(rgltest) + FetchContent_GetProperties(tapedtest) + if (NOT tapedtest_POPULATED) + FetchContent_Populate(tapedtest) endif() set(RGL_INTEGRATION_TEST_FILES - ${rgltest_SOURCE_DIR}/test/IntegrationTest.cpp + src/TapedTest.cpp ) - file(COPY ${rgltest_SOURCE_DIR}/tapes DESTINATION ${CMAKE_BINARY_DIR}/data) + file(COPY ${tapedtest_SOURCE_DIR}/tapes DESTINATION ${CMAKE_BINARY_DIR}/data) add_executable(RobotecGPULidar_integration_test ${RGL_INTEGRATION_TEST_FILES}) diff --git a/test/src/TapedTest.cpp b/test/src/TapedTest.cpp new file mode 100644 index 000000000..6652f75e2 --- /dev/null +++ b/test/src/TapedTest.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +#include +#include + +class TapedTest : public RGLTest +{}; + +TEST_F(TapedTest, compare_pcd_files) +{ +#if RGL_BUILD_PCL_EXTENSION + std::string testTapePath{std::filesystem::current_path().parent_path().string() + "/data/tapes/minimal"}; + std::string expectedOutputPath{std::filesystem::current_path().parent_path().string() + + "/data/tapes/expected-output/minimal.pcd"}; + std::string outputPath{std::filesystem::current_path().string() + "/minimal.pcd"}; + + ASSERT_RGL_SUCCESS(rgl_tape_play(testTapePath.c_str())); + + std::ifstream expectedOutputFile(expectedOutputPath, std::ios::binary); + std::ifstream outputFile(outputPath, std::ios::binary); + + std::vector expectedOutput((std::istreambuf_iterator(expectedOutputFile)), std::istreambuf_iterator()); + std::vector output((std::istreambuf_iterator(outputFile)), std::istreambuf_iterator()); + + EXPECT_EQ(expectedOutput, output); +#else + GTEST_SKIP(); + RGL_WARN("RGL compiled without PCL extension. Integration test skipped."); +#endif +}