Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build problems in absence of cmocka #43

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,27 @@ target_link_libraries(hello-world-listener open1722 open1722examples)

enable_testing()

# find_package(cmocka 1.1.0 REQUIRED)

list(APPEND TEST_TARGETS test-aaf)
list(APPEND TEST_TARGETS test-avtp)
list(APPEND TEST_TARGETS test-can)
list(APPEND TEST_TARGETS test-crf)
list(APPEND TEST_TARGETS test-cvf)
list(APPEND TEST_TARGETS test-rvf)
# list(APPEND TEST_TARGETS test-stream)

foreach(TEST_TARGET IN LISTS TEST_TARGETS)
add_executable(${TEST_TARGET} "unit/${TEST_TARGET}.c")
target_include_directories(${TEST_TARGET} PRIVATE "include")
target_link_libraries(${TEST_TARGET} open1722 cmocka m)
add_test(NAME ${TEST_TARGET} COMMAND "${PROJECT_BINARY_DIR}/${TEST_TARGET}")
endforeach()
if (UNIT_TESTING)

find_package(cmocka 1.1.0 REQUIRED)

if (cmocka_FOUND)
list(APPEND TEST_TARGETS test-aaf)
list(APPEND TEST_TARGETS test-avtp)
list(APPEND TEST_TARGETS test-can)
list(APPEND TEST_TARGETS test-crf)
list(APPEND TEST_TARGETS test-cvf)
list(APPEND TEST_TARGETS test-rvf)

foreach(TEST_TARGET IN LISTS TEST_TARGETS)
add_executable(${TEST_TARGET} "unit/${TEST_TARGET}.c")
target_include_directories(${TEST_TARGET} PRIVATE "include")
target_link_libraries(${TEST_TARGET} open1722 cmocka m)
add_test(NAME ${TEST_TARGET} COMMAND "${PROJECT_BINARY_DIR}/${TEST_TARGET}")
endforeach()
endif(cmocka_FOUND)
endif(UNIT_TESTING)


#### Install ##################################################################

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This repository is organized as follows:

Before building Open1722 make sure you have installed the following software :
* CMake >= 3.20
* CMocka >= 1.1.0
* CMocka >= 1.1.0 (For running unit tests. This can be installed on Debian/Ubuntu using ```sudo apt install libcmocka-dev```)

Alternatively, you can use VS Code to run the provided dev container which takes care of the dependencies.

Expand All @@ -61,6 +61,12 @@ $ cmake ..
$ make
```

To execute available unit tests, set the Cmake variable UNIT_TESTING.
```
$ cmake .. -DUNIT_TESTING=on
$ make
```

The build can be cleaned using the following command:
```
$ make clean
Expand Down
10 changes: 6 additions & 4 deletions test_all.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
set -ev
#!/bin/bash
set -ev

./build_all.sh
rm -rf build
mkdir build
cd build
cmake .. -DUNIT_TESTING=on
make -j`nproc`
make test
# ninja coverage-html