diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ef497cb1..e12e1fce 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -7,7 +7,7 @@ on: pull_request: branches: [trunk] -permissions: # added using https://github.com/step-security/secure-repo +permissions: # added using https://github.com/step-security/secure-repo contents: read jobs: @@ -15,13 +15,18 @@ jobs: runs-on: "ubuntu-latest" steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: atsdk Unit CTest + - name: build atSDK run: | - cmake -S . -B build -DATSDK_BUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + cmake -S . -B build -DATSDK_BUILD_TESTS="unit" cmake --build build --target all - ctest --test-dir build/packages/atchops/tests --output-on-failure --timeout 2 - ctest --test-dir build/packages/atclient/tests --output-on-failure --timeout 2 + + - name: atchops Unit CTest + working-directory: build/packages/atchops/tests + run: ctest --test-dir . --output-on-failure --timeout 2 + + - name: atclient Unit CTest + working-directory: build/packages/atclient/tests + run: ctest --test-dir . --output-on-failure --timeout 2 functional-tests: runs-on: "ubuntu-latest" @@ -44,8 +49,8 @@ jobs: working-directory: tests/functional_tests run: | cmake -S . -B build - cmake --build build - ctest --test-dir build -VV --timeout 60 + sudo cmake --build build + ctest --test-dir . -VV --timeout 90 build-examples: runs-on: "ubuntu-latest" @@ -73,19 +78,19 @@ jobs: cmake -S . -B build -DTARGET_SRC=put_publickey.c && cmake --build build cmake -S . -B build -DTARGET_SRC=put_selfkey.c && cmake --build build cmake -S . -B build -DTARGET_SRC=put_sharedkey.c && cmake --build build - + - name: Build events working-directory: examples/desktop/events run: | cmake -S . -B build cmake --build build - + - name: Build pkam_authenticate working-directory: examples/desktop/pkam_authenticate run: | cmake -S . -B build cmake --build build - + - name: Build REPL working-directory: examples/desktop/repl run: | @@ -102,4 +107,4 @@ jobs: working-directory: examples/desktop/sample_cmake_project run: | cmake -S . -B build -Datsdk="/usr/local/bin/cmake/atsdk" - cmake --build build \ No newline at end of file + cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index 92f59d9e..38a35196 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,26 @@ # Configurable options set(TARGET_ESPIDF FALSE CACHE BOOL "Build for the espidf platform") -option(ATSDK_BUILD_TESTS "Build tests for atsdk" OFF) + +option(ATSDK_BUILD_TESTS "Build tests for atsdk ON | \"unit\" | \"func\" " OFF) + +# to avoid caching issues +if(ATSDK_BUILD_TESTS STREQUAL "func") + message("FUNCTIONAL TESTING ENABLED") + set(ATSDK_BUILD_UNIT_TESTS OFF) + set(ATSDK_BUILD_FUNCTIONAL_TESTS ON) +elseif(ATSDK_BUILD_TESTS STREQUAL "unit") + message("UNIT TESTING ENABLED") + set(ATSDK_BUILD_UNIT_TESTS ON) + set(ATSDK_BUILD_FUNCTIONAL_TESTS OFF) +elseif(ATSDK_BUILD_TESTS) + message("ALL TESTING ENABLED") + set(ATSDK_BUILD_FUNCTIONAL_TESTS ON) + set(ATSDK_BUILD_UNIT_TESTS ON) +else() + message("TESTING DISABLED") + set(ATSDK_BUILD_UNIT_TESTS OFF) + set(ATSDK_BUILD_FUNCTIONAL_TESTS OFF) +endif() # Basic project setup cmake_minimum_required(VERSION 3.24) @@ -30,20 +50,23 @@ message(STATUS "Building atlogger") add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atlogger) message(STATUS "Building atchops") -set(ATCHOPS_BUILD_TESTS ${ATSDK_BUILD_TESTS}) +set(ATCHOPS_BUILD_TESTS ${ATSDK_BUILD_UNIT_TESTS}) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atchops) message(STATUS "Building atclient") -set(ATCLIENT_BUILD_TESTS ${ATSDK_BUILD_TESTS}) +set(ATCLIENT_BUILD_TESTS ${ATSDK_BUILD_UNIT_TESTS}) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atclient) message(STATUS "Building atauth") -set(ATAUTH_BUILD_TESTS ${ATSDK_BUILD_TESTS}) +set(ATAUTH_BUILD_TESTS ${ATSDK_BUILD_UNIT_TESTS}) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atauth) -if(${ATSDK_BUILD_TESTS}) +if(ATSDK_BUILD_FUNCTIONAL_TESTS) message(STATUS "Building functional tests") add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests/functional_tests) +endif() + +if(ATSDK_BUILD_UNIT_TESTS OR ATSDK_BUILD_FUNCTIONAL_TESTS) enable_testing() endif()