Skip to content

Commit

Permalink
Add tests for all relevant components in test_package
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Aug 3, 2023
1 parent 63e6fbc commit f6a2e49
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 10 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def requirements(self):
modules = self._enabled_modules
self.output.info("Enabled modules:", modules)
if "imageproc" in modules:
self.requires("libsgm/3.0.0@cupoch")
self.requires("libsgm/3.0.0@cupoch", transitive_headers=True)
if "io" in modules:
self.requires("libjpeg-turbo/3.0.0")
self.requires("libpng/1.6.40")
Expand Down
27 changes: 21 additions & 6 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@ project(PackageTest LANGUAGES CXX CUDA)

find_package(cupoch REQUIRED)

if (TARGET cupoch::registration)
add_executable(test_registration test_registration.cpp)
target_link_libraries(test_registration PRIVATE cupoch::registration)
# Build a separate test executable for each module with external dependencies
# to ensure that everything compiles and links correctly.

# Using cupoch::cupoch as the link_libraries would also work.

if (TARGET cupoch::imageproc)
add_executable(test_imageproc test_imageproc.cpp)
target_link_libraries(test_imageproc PRIVATE cupoch::imageproc cupoch::io)
endif()

if (TARGET cupoch::io)
add_executable(test_io test_io.cpp)
target_link_libraries(test_io PRIVATE cupoch::io)
endif()

if (TARGET cupoch::kinematics)
add_executable(test_kinematics test_kinematics.cpp)
target_link_libraries(test_kinematics PRIVATE cupoch::kinematics)
endif()

if (TARGET cupoch::io)
add_executable(test_io test_io.cpp)
target_link_libraries(test_io PRIVATE cupoch::io)
if (TARGET cupoch::registration)
add_executable(test_registration test_registration.cpp)
target_link_libraries(test_registration PRIVATE cupoch::registration)
endif()

if (TARGET cupoch::visualization)
add_executable(test_visualization test_visualization.cpp)
target_link_libraries(test_visualization PRIVATE cupoch::visualization)
endif()
12 changes: 9 additions & 3 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ def test(self):
if not can_run(self):
return
cupoch_opts = self.dependencies["cupoch"].options
if cupoch_opts.registration:
cmd = os.path.join(self.cpp.build.bindir, "test_registration")
self.run(cmd, env="conanrun")
if cupoch_opts.kinematics:
cmd = os.path.join(self.cpp.build.bindir, "test_kinematics")
self.run(cmd, env="conanrun")
if cupoch_opts.imageproc and cupoch_opts.io:
cmd = os.path.join(self.cpp.build.bindir, "test_imageproc")
self.run(cmd, env="conanrun")
if cupoch_opts.io:
cmd = os.path.join(self.cpp.build.bindir, "test_io")
self.run(cmd, env="conanrun")
if cupoch_opts.registration:
cmd = os.path.join(self.cpp.build.bindir, "test_registration")
self.run(cmd, env="conanrun")
if cupoch_opts.visualization:
cmd = os.path.join(self.cpp.build.bindir, "test_visualization")
self.run(cmd, env="conanrun")
19 changes: 19 additions & 0 deletions test_package/test_imageproc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <cupoch/geometry/image.h>
#include <cupoch/imageproc/sgm.h>
#include <cupoch/io/class_io/image_io.h>

using namespace cupoch;

void testSGM() {
auto limg = io::CreateImageFromFile("../../testdata/left.png")->CreateGrayImage();
auto rimg = io::CreateImageFromFile("../../testdata/right.png")->CreateGrayImage();
imageproc::SGMOption params(limg->width_, limg->height_);
imageproc::SemiGlobalMatching sgm(params);
auto disp = sgm.ProcessFrame(*limg, *rimg);
disp->LinearTransform(255.0 / 127.0);
}

int main() {
// Only testing that the code compiles and links.
return 0;
}
16 changes: 16 additions & 0 deletions test_package/test_visualization.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <cupoch/geometry/pointcloud.h>
#include <cupoch/io/class_io/pointcloud_io.h>
#include <cupoch/visualization/utility/draw_geometry.h>

using namespace cupoch;

void displayPointCloud() {
auto pcd = io::CreatePointCloudFromFile("test.ply");
pcd->EstimateNormals();
visualization::DrawGeometries({pcd});
}

int main() {
// Only testing that the code compiles and links.
return 0;
}

0 comments on commit f6a2e49

Please sign in to comment.