From 1cc77834c6373f6e8030efac188a5530216ac4eb Mon Sep 17 00:00:00 2001 From: Lukas Woodtli Date: Wed, 4 Dec 2024 21:39:44 +0100 Subject: [PATCH] test: Add action dedicated to integration tests This way it's easier to handle the different kind of tests. --- .github/workflows/build_and_test.yaml | 36 +++++++-------- .github/workflows/integration_test.yaml | 54 +++++++++++++++++++++++ examples/bootstrap_server/CMakeLists.txt | 2 + examples/client/raw_block1/CMakeLists.txt | 2 + examples/client/tinydtls/CMakeLists.txt | 2 + examples/client/udp/CMakeLists.txt | 2 + examples/lightclient/CMakeLists.txt | 2 + examples/server/CMakeLists.txt | 2 + 8 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/integration_test.yaml diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index 3471df78..26532c07 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -18,6 +18,7 @@ jobs: matrix: sanitizer: ["address", "leak", "thread", "undefined"] compiler: ["clang-18", "gcc-13"] + example: ["bootstrap_server", "client/udp", "client/tinydtls", "client/raw_block1", "lightclient", "server"] steps: - name: Checkout code including full history and submodules @@ -29,7 +30,7 @@ jobs: - name: Install dependencies from APT repository run: | sudo apt-get update - sudo apt-get install cmake libcunit1-dev ninja-build unzip wget + sudo apt-get install cmake libcunit1-dev ninja-build - name: Build all binaries run: | @@ -43,27 +44,22 @@ jobs: env: CC: ${{ matrix.compiler }} - - name: Build examples for integration tests + - name: Build examples run: | - for example in "server" "bootstrap_server" "client/udp" - do - echo "Building example ${example}" - tools/ci/run_ci.sh \ - --run-clean \ - --run-build \ - --sanitizer ${{ matrix.sanitizer }} \ - --source-directory examples/${example} \ - --build-directory build-wakaama-${example} - done + tools/ci/run_ci.sh \ + --run-clean \ + --run-build \ + --sanitizer ${{ matrix.sanitizer }} \ + --source-directory examples/${{ matrix.example }} \ + --build-directory wakaama-build-${{ matrix.example }} env: CC: ${{ matrix.compiler }} - - name: Install dependencies + - name: Unit test examples run: | - pip install --require-hashes -r tests/integration/requirements.txt - - - name: Execute integration tests - run: | - python -c "import sys; print(sys.version)" - pytest -v tests/integration - + tools/ci/run_ci.sh \ + --run-tests \ + --source-directory examples/${{ matrix.example }} \ + --build-directory wakaama-build-${{ matrix.example }} + env: + CC: ${{ matrix.compiler }} diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml new file mode 100644 index 00000000..0caf9517 --- /dev/null +++ b/.github/workflows/integration_test.yaml @@ -0,0 +1,54 @@ +name: Integration Tests + +on: + push: + branches: '**' + pull_request: + branches: '**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_and_test: + runs-on: ubuntu-24.04 + + strategy: + matrix: + sanitizer: ["address", "leak", "thread", "undefined"] + + steps: + - name: Checkout code including full history and submodules + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: true + fetch-depth: 0 + + - name: Install dependencies from APT repository + run: | + sudo apt-get update + sudo apt-get install cmake libcunit1-dev ninja-build + + - name: Build examples for integration tests + run: | + for example in "server" "bootstrap_server" "client/udp" + do + echo "Building example ${example}" + tools/ci/run_ci.sh \ + --run-clean \ + --run-build \ + --sanitizer ${{ matrix.sanitizer }} \ + --run-tests \ + --source-directory examples/${example} \ + --build-directory build-wakaama-${example} + done + + - name: Install Python test dependencies + run: | + pip install --require-hashes -r tests/integration/requirements.txt + + - name: Execute integration tests + run: | + python -c "import sys; print(sys.version)" + pytest -v tests/integration diff --git a/examples/bootstrap_server/CMakeLists.txt b/examples/bootstrap_server/CMakeLists.txt index 1de8f184..05edf9d2 100644 --- a/examples/bootstrap_server/CMakeLists.txt +++ b/examples/bootstrap_server/CMakeLists.txt @@ -13,3 +13,5 @@ add_subdirectory(../../ wakaama_lib) add_executable(bootstrap_server) target_sources(bootstrap_server PRIVATE bootstrap_info.c bootstrap_server.c bootstrap_info.h bootstrap_server.ini) target_link_libraries(bootstrap_server PRIVATE wakaama_static) + +enable_testing() diff --git a/examples/client/raw_block1/CMakeLists.txt b/examples/client/raw_block1/CMakeLists.txt index 810bdc37..1eebb4d6 100644 --- a/examples/client/raw_block1/CMakeLists.txt +++ b/examples/client/raw_block1/CMakeLists.txt @@ -33,3 +33,5 @@ target_sources( ) target_link_libraries(lwm2mclient_raw_block1 PRIVATE wakaama_static) + +enable_testing() diff --git a/examples/client/tinydtls/CMakeLists.txt b/examples/client/tinydtls/CMakeLists.txt index 8c1b05de..70fb2522 100644 --- a/examples/client/tinydtls/CMakeLists.txt +++ b/examples/client/tinydtls/CMakeLists.txt @@ -32,3 +32,5 @@ target_sources( ) target_link_libraries(lwm2mclient_tinydtls PRIVATE wakaama_static) + +enable_testing() diff --git a/examples/client/udp/CMakeLists.txt b/examples/client/udp/CMakeLists.txt index 8d492db0..87531aaf 100644 --- a/examples/client/udp/CMakeLists.txt +++ b/examples/client/udp/CMakeLists.txt @@ -32,3 +32,5 @@ target_sources( ) target_link_libraries(lwm2mclient PRIVATE wakaama_static) + +enable_testing() diff --git a/examples/lightclient/CMakeLists.txt b/examples/lightclient/CMakeLists.txt index 6bb52687..62f035b2 100644 --- a/examples/lightclient/CMakeLists.txt +++ b/examples/lightclient/CMakeLists.txt @@ -14,3 +14,5 @@ add_subdirectory(../../ wakaama_lib) add_executable(lightclient) target_sources(lightclient PRIVATE lightclient.c object_device.c object_security.c object_server.c object_test.c) target_link_libraries(lightclient PRIVATE wakaama_static) + +enable_testing() diff --git a/examples/server/CMakeLists.txt b/examples/server/CMakeLists.txt index 2b0bb36e..2991a941 100644 --- a/examples/server/CMakeLists.txt +++ b/examples/server/CMakeLists.txt @@ -13,3 +13,5 @@ add_subdirectory(../../ wakaama_lib) add_executable(lwm2mserver) target_sources(lwm2mserver PRIVATE lwm2mserver.c) target_link_libraries(lwm2mserver PRIVATE wakaama_static) + +enable_testing()