Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierChanth committed Dec 7, 2024
1 parent 6e4a48e commit bcb49df
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@ 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:
unit-tests:
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"
Expand All @@ -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"
Expand Down Expand Up @@ -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: |
Expand All @@ -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
cmake --build build
33 changes: 28 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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()

Expand Down
11 changes: 10 additions & 1 deletion tests/functional_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ project(
LANGUAGES C
)

find_package(atsdk CONFIG REQUIRED)
if(NOT DEFINED FUNCTIONAL_TESTS_AS_SUBPROJECT)
set(FUNCTIONAL_TESTS_AS_SUBPROJECT ON)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(FUNCTIONAL_TESTS_AS_SUBPROJECT OFF)
endif()
endif()

if(NOT FUNCTIONAL_TESTS_AS_SUBPROJECT)
find_package(atsdk CONFIG REQUIRED)
endif()

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/lib)

Expand Down

0 comments on commit bcb49df

Please sign in to comment.