Skip to content

Commit

Permalink
tests: Add CTest base harness testing
Browse files Browse the repository at this point in the history
Add a testcase to validate the added CTest twister harness.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt authored and kartben committed Jan 10, 2025
1 parent 0b67255 commit 4895b1f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/ctest/base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2024 Basalte bv
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(ctest_base)

target_sources(app PRIVATE ${ZEPHYR_BASE}/misc/empty_file.c)

enable_testing()
include(CTest)

add_test(NAME exe_help COMMAND ${CMAKE_BINARY_DIR}/zephyr/zephyr.exe --help)
add_test(NAME exe_run COMMAND ${CMAKE_BINARY_DIR}/zephyr/zephyr.exe -stop_at=3 -no-rt)
set_property(
TEST exe_run
PROPERTY PASS_REGULAR_EXPRESSION "Stopped at [0-9.]+s"
)

# A test that always succeeds
add_test(NAME success COMMAND ${CMAKE_COMMAND} -E true)

# A test that is expected to fail
add_test(NAME failure COMMAND ${CMAKE_COMMAND} -E false)
set_property(TEST failure PROPERTY WILL_FAIL true)
1 change: 1 addition & 0 deletions tests/ctest/base/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Intentionally empty
10 changes: 10 additions & 0 deletions tests/ctest/base/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
common:
tags:
- test_framework
platform_allow:
- native_sim
integration_platforms:
- native_sim
harness: ctest
tests:
testing.ctest.base: {}

0 comments on commit 4895b1f

Please sign in to comment.