File tree Expand file tree Collapse file tree 8 files changed +76
-25
lines changed
Expand file tree Collapse file tree 8 files changed +76
-25
lines changed Original file line number Diff line number Diff line change 1+ name : Build and Test example module
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ - jira/*
8+
9+ jobs :
10+ build-and-test :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout repo
14+ uses : actions/checkout@v4
15+
16+ - name : Install dependencies
17+ run : |
18+ sudo apt-get update && sudo apt-get install -y git wget cmake ninja-build mono-complete g++ libgmock-dev
19+ wget -v https://docs.opendaq.com/download/SDK/opendaq-3.20.4-ubuntu22.04-x86_64.deb -O /tmp/opendaq.deb
20+ sudo dpkg -i /tmp/opendaq.deb || sudo apt-get install -f -y
21+
22+ - name : Configure CMake
23+ run : cmake -B build/output -S . -G Ninja -DOPENDAQ_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release
24+
25+ - name : Build
26+ run : cmake --build build/output --target all
27+
28+ - name : Run tests with GTest report
29+ run : |
30+ mkdir -p build/reports
31+ export GTEST_OUTPUT=xml:$(pwd)/build/reports/gtest-report.xml
32+ ctest --test-dir build/output --output-on-failure -V
33+
34+ - name : Upload test report artifact
35+ if : always()
36+ uses : actions/upload-artifact@v4
37+ with :
38+ name : gtest-report
39+ path : build/reports/gtest-report.xml
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ if(OPENDAQ_DEVICE_EXAMPLE_ENABLE_SERVER_APP)
3030 set (OPENDAQ_ENABLE_NATIVE_STREAMING ON CACHE BOOL "" FORCE)
3131endif ()
3232
33+ if (OPENDAQ_ENABLE_TESTS)
34+ message (STATUS "Unit tests are ENABLED" )
35+ enable_testing ()
36+ endif ()
37+
3338add_subdirectory (external)
3439add_subdirectory (example_module)
3540
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ if (MSVC)
3737 target_compile_options (${LIB_NAME} PRIVATE /bigobj)
3838endif ()
3939
40+ find_package (openDAQ 3.20.4 REQUIRED)
4041target_link_libraries (${LIB_NAME} PUBLIC daq::opendaq
4142)
4243
Original file line number Diff line number Diff line change @@ -8,10 +8,37 @@ set(TEST_SOURCES test_example_module.cpp
88add_executable (${TEST_APP} ${TEST_SOURCES}
99)
1010
11- target_link_libraries (${TEST_APP} PRIVATE daq::test_utils
11+ find_package (openDAQ 3.20.4 REQUIRED)
12+ target_link_libraries (${TEST_APP} PRIVATE daq::opendaq
1213 ${SDK_TARGET_NAMESPACE} ::${MODULE_NAME}
1314)
1415
16+ find_package (GTest QUIET )
17+ if (NOT GTest_FOUND)
18+ message (STATUS "GTest not found, fetching googletest with gmock..." )
19+
20+ include (FetchContent)
21+ FetchContent_Declare(
22+ googletest
23+ URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
24+ )
25+ set (INSTALL_GTEST OFF CACHE BOOL "" FORCE)
26+ FetchContent_MakeAvailable(googletest)
27+ else ()
28+ message (STATUS "GTest found, setting up googletest with gtest, gmock..." )
29+ endif ()
30+
31+ # Link module + gtest/gmock
32+ target_link_libraries (${TEST_APP}
33+ PRIVATE
34+ GTest::gtest
35+ GTest::gtest_main
36+ GTest::gmock
37+ GTest::gmock_main
38+ )
39+ include (GoogleTest)
40+ gtest_discover_tests(${TEST_APP} )
41+
1542add_test (NAME ${TEST_APP}
1643 COMMAND $<TARGET_FILE_NAME:${TEST_APP} >
1744 WORKING_DIRECTORY bin
Original file line number Diff line number Diff line change 1- #include < testutils/testutils.h>
2- #include < testutils/bb_memcheck_listener.h>
1+ #include < gtest/gtest.h>
32#include < coreobjects/util.h>
4- #include < opendaq/module_manager_init.h>
5- #include < coretypes/stringobject_factory.h>
6-
73
84int main (int argc, char ** args)
95{
10- daq::daqInitializeCoreObjectsTesting ();
11- daqInitModuleManagerLibrary ();
12-
136 testing::InitGoogleTest (&argc, args);
147
15- testing::TestEventListeners& listeners = testing::UnitTest::GetInstance ()->listeners ();
16- listeners.Append (new DaqMemCheckListener ());
17-
188 auto res = RUN_ALL_TESTS ();
199
2010 return res;
Original file line number Diff line number Diff line change 55#include < example_module/version.h>
66#include < gmock/gmock.h>
77#include < opendaq/opendaq.h>
8- #include < testutils/testutils.h>
8+ // #include <testutils/testutils.h>
99
1010#include < chrono>
1111#include < thread>
Original file line number Diff line number Diff line change @@ -5,6 +5,4 @@ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
55 message (FATAL_ERROR "In-source build is not supported!" )
66endif ()
77
8- include (FetchContent)
9-
108add_subdirectory (openDAQ)
Original file line number Diff line number Diff line change 11set (OPENDAQ_ENABLE_TESTS false )
22
3- FetchContent_Declare(
4- openDAQ
5- GIT_REPOSITORY https://github.com/openDAQ/openDAQ.git
6- GIT_TAG v3.20.1
7- GIT_PROGRESS ON
8- SYSTEM
9- FIND_PACKAGE_ARGS 3.20.1 GLOBAL
10- )
11-
12- FetchContent_MakeAvailable(openDAQ)
3+ find_package (openDAQ 3.20.4 REQUIRED)
You can’t perform that action at this time.
0 commit comments