Skip to content

Commit

Permalink
test: Add action dedicated to integration tests
Browse files Browse the repository at this point in the history
This way it's easier to handle the different kind of tests.
  • Loading branch information
LukasWoodtli committed Dec 17, 2024
1 parent e5d7dab commit 1cc7783
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 20 deletions.
36 changes: 16 additions & 20 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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 }}
54 changes: 54 additions & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions examples/bootstrap_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 2 additions & 0 deletions examples/client/raw_block1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ target_sources(
)

target_link_libraries(lwm2mclient_raw_block1 PRIVATE wakaama_static)

enable_testing()
2 changes: 2 additions & 0 deletions examples/client/tinydtls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ target_sources(
)

target_link_libraries(lwm2mclient_tinydtls PRIVATE wakaama_static)

enable_testing()
2 changes: 2 additions & 0 deletions examples/client/udp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ target_sources(
)

target_link_libraries(lwm2mclient PRIVATE wakaama_static)

enable_testing()
2 changes: 2 additions & 0 deletions examples/lightclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 2 additions & 0 deletions examples/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 1cc7783

Please sign in to comment.