Skip to content

Commit

Permalink
Rename test & change its location
Browse files Browse the repository at this point in the history
  • Loading branch information
nebraszka committed Mar 12, 2024
1 parent 3c91c01 commit f322f8d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 10 additions & 10 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,36 +122,36 @@ 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})
add_executable(RobotecGPULidar_taped_test ${RGL_INTEGRATION_TEST_FILES})

target_link_libraries(RobotecGPULidar_integration_test PRIVATE
target_link_libraries(RobotecGPULidar_taped_test PRIVATE
gtest_main
gmock_main
RobotecGPULidar
)

target_include_directories(RobotecGPULidar_integration_test PRIVATE
target_include_directories(RobotecGPULidar_taped_test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../src
)

gtest_discover_tests(RobotecGPULidar_integration_test)
gtest_discover_tests(RobotecGPULidar_taped_test)

endif ()
32 changes: 32 additions & 0 deletions test/src/TapedTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <helpers/commonHelpers.hpp>
#include <rgl/api/extensions/tape.h>
#include <Logger.hpp>

#include <filesystem>
#include <fstream>

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<char> expectedOutput((std::istreambuf_iterator<char>(expectedOutputFile)), std::istreambuf_iterator<char>());
std::vector<char> output((std::istreambuf_iterator<char>(outputFile)), std::istreambuf_iterator<char>());

EXPECT_EQ(expectedOutput, output);
#else
GTEST_SKIP();
RGL_WARN("RGL compiled without PCL extension. Integration test skipped.");
#endif
}

0 comments on commit f322f8d

Please sign in to comment.