Skip to content

Commit f6a2e49

Browse files
committed
Add tests for all relevant components in test_package
1 parent 63e6fbc commit f6a2e49

File tree

5 files changed

+66
-10
lines changed

5 files changed

+66
-10
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def requirements(self):
129129
modules = self._enabled_modules
130130
self.output.info("Enabled modules:", modules)
131131
if "imageproc" in modules:
132-
self.requires("libsgm/3.0.0@cupoch")
132+
self.requires("libsgm/3.0.0@cupoch", transitive_headers=True)
133133
if "io" in modules:
134134
self.requires("libjpeg-turbo/3.0.0")
135135
self.requires("libpng/1.6.40")

test_package/CMakeLists.txt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,32 @@ project(PackageTest LANGUAGES CXX CUDA)
33

44
find_package(cupoch REQUIRED)
55

6-
if (TARGET cupoch::registration)
7-
add_executable(test_registration test_registration.cpp)
8-
target_link_libraries(test_registration PRIVATE cupoch::registration)
6+
# Build a separate test executable for each module with external dependencies
7+
# to ensure that everything compiles and links correctly.
8+
9+
# Using cupoch::cupoch as the link_libraries would also work.
10+
11+
if (TARGET cupoch::imageproc)
12+
add_executable(test_imageproc test_imageproc.cpp)
13+
target_link_libraries(test_imageproc PRIVATE cupoch::imageproc cupoch::io)
14+
endif()
15+
16+
if (TARGET cupoch::io)
17+
add_executable(test_io test_io.cpp)
18+
target_link_libraries(test_io PRIVATE cupoch::io)
919
endif()
1020

1121
if (TARGET cupoch::kinematics)
1222
add_executable(test_kinematics test_kinematics.cpp)
1323
target_link_libraries(test_kinematics PRIVATE cupoch::kinematics)
1424
endif()
1525

16-
if (TARGET cupoch::io)
17-
add_executable(test_io test_io.cpp)
18-
target_link_libraries(test_io PRIVATE cupoch::io)
26+
if (TARGET cupoch::registration)
27+
add_executable(test_registration test_registration.cpp)
28+
target_link_libraries(test_registration PRIVATE cupoch::registration)
29+
endif()
30+
31+
if (TARGET cupoch::visualization)
32+
add_executable(test_visualization test_visualization.cpp)
33+
target_link_libraries(test_visualization PRIVATE cupoch::visualization)
1934
endif()

test_package/conanfile.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ def test(self):
2525
if not can_run(self):
2626
return
2727
cupoch_opts = self.dependencies["cupoch"].options
28-
if cupoch_opts.registration:
29-
cmd = os.path.join(self.cpp.build.bindir, "test_registration")
30-
self.run(cmd, env="conanrun")
3128
if cupoch_opts.kinematics:
3229
cmd = os.path.join(self.cpp.build.bindir, "test_kinematics")
3330
self.run(cmd, env="conanrun")
31+
if cupoch_opts.imageproc and cupoch_opts.io:
32+
cmd = os.path.join(self.cpp.build.bindir, "test_imageproc")
33+
self.run(cmd, env="conanrun")
3434
if cupoch_opts.io:
3535
cmd = os.path.join(self.cpp.build.bindir, "test_io")
3636
self.run(cmd, env="conanrun")
37+
if cupoch_opts.registration:
38+
cmd = os.path.join(self.cpp.build.bindir, "test_registration")
39+
self.run(cmd, env="conanrun")
40+
if cupoch_opts.visualization:
41+
cmd = os.path.join(self.cpp.build.bindir, "test_visualization")
42+
self.run(cmd, env="conanrun")

test_package/test_imageproc.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <cupoch/geometry/image.h>
2+
#include <cupoch/imageproc/sgm.h>
3+
#include <cupoch/io/class_io/image_io.h>
4+
5+
using namespace cupoch;
6+
7+
void testSGM() {
8+
auto limg = io::CreateImageFromFile("../../testdata/left.png")->CreateGrayImage();
9+
auto rimg = io::CreateImageFromFile("../../testdata/right.png")->CreateGrayImage();
10+
imageproc::SGMOption params(limg->width_, limg->height_);
11+
imageproc::SemiGlobalMatching sgm(params);
12+
auto disp = sgm.ProcessFrame(*limg, *rimg);
13+
disp->LinearTransform(255.0 / 127.0);
14+
}
15+
16+
int main() {
17+
// Only testing that the code compiles and links.
18+
return 0;
19+
}

test_package/test_visualization.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <cupoch/geometry/pointcloud.h>
2+
#include <cupoch/io/class_io/pointcloud_io.h>
3+
#include <cupoch/visualization/utility/draw_geometry.h>
4+
5+
using namespace cupoch;
6+
7+
void displayPointCloud() {
8+
auto pcd = io::CreatePointCloudFromFile("test.ply");
9+
pcd->EstimateNormals();
10+
visualization::DrawGeometries({pcd});
11+
}
12+
13+
int main() {
14+
// Only testing that the code compiles and links.
15+
return 0;
16+
}

0 commit comments

Comments
 (0)