From 4895b1f47b457437265d57e85dd43625e60f245d Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Sat, 21 Dec 2024 10:10:49 +0100 Subject: [PATCH] tests: Add CTest base harness testing Add a testcase to validate the added CTest twister harness. Signed-off-by: Pieter De Gendt --- tests/ctest/base/CMakeLists.txt | 26 ++++++++++++++++++++++++++ tests/ctest/base/prj.conf | 1 + tests/ctest/base/testcase.yaml | 10 ++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/ctest/base/CMakeLists.txt create mode 100644 tests/ctest/base/prj.conf create mode 100644 tests/ctest/base/testcase.yaml diff --git a/tests/ctest/base/CMakeLists.txt b/tests/ctest/base/CMakeLists.txt new file mode 100644 index 00000000000000..2fb9d23e72dde3 --- /dev/null +++ b/tests/ctest/base/CMakeLists.txt @@ -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) diff --git a/tests/ctest/base/prj.conf b/tests/ctest/base/prj.conf new file mode 100644 index 00000000000000..bb7b160deb3702 --- /dev/null +++ b/tests/ctest/base/prj.conf @@ -0,0 +1 @@ +# Intentionally empty diff --git a/tests/ctest/base/testcase.yaml b/tests/ctest/base/testcase.yaml new file mode 100644 index 00000000000000..f10d3945b7a6de --- /dev/null +++ b/tests/ctest/base/testcase.yaml @@ -0,0 +1,10 @@ +common: + tags: + - test_framework + platform_allow: + - native_sim + integration_platforms: + - native_sim + harness: ctest +tests: + testing.ctest.base: {}