From e2a2320de4168495208a3c25c3da38eb867e631d Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Wed, 5 Aug 2026 15:06:07 +0100 Subject: [PATCH] Add XS and VX build and test support --- CHANGELOG.rst | 7 ++ Jenkinsfile | 79 +++++++++++++++---- README.rst | 7 +- doc/exclude_patterns.inc | 4 + examples/app_assert/CMakeLists.txt | 4 +- examples/app_fail/CMakeLists.txt | 4 +- examples/app_timed_block/CMakeLists.txt | 4 +- examples/app_timed_loop/CMakeLists.txt | 4 +- examples/app_timed_loop/src/fn_no_assert.c | 2 +- .../app_timing_loop_exception/CMakeLists.txt | 4 +- examples/app_unreachable/CMakeLists.txt | 4 +- lib_xassert/api/xassert.h | 29 +++---- lib_xassert/lib_build_info.cmake | 2 +- tests/CMakeLists.txt | 23 ++++-- tests/assert_c_test.expect | 2 + tests/assert_c_test/CMakeLists.txt | 11 +++ tests/assert_c_test/src/main.c | 11 +++ tests/assert_test/CMakeLists.txt | 4 +- tests/assert_test_unit/CMakeLists.txt | 4 +- tests/assert_unit_c_test.expect | 2 + tests/assert_unit_c_test/CMakeLists.txt | 11 +++ tests/assert_unit_c_test/src/main.c | 12 +++ tests/fail_c_test.expect | 2 + tests/fail_c_test/CMakeLists.txt | 11 +++ tests/fail_c_test/src/main.c | 11 +++ tests/fail_test/CMakeLists.txt | 4 +- tests/timing_block_c_test/CMakeLists.txt | 4 +- tests/timing_block_c_test/src/main.c | 6 +- tests/timing_block_test/CMakeLists.txt | 4 +- tests/timing_debug_c_test/CMakeLists.txt | 4 +- tests/timing_debug_c_test/src/main.c | 6 +- tests/timing_debug_test/CMakeLists.txt | 4 +- tests/timing_loop_c_test/CMakeLists.txt | 4 +- tests/timing_loop_c_test/src/main.c | 6 +- tests/timing_loop_test/CMakeLists.txt | 4 +- tests/unreachable_c_test.expect | 2 + tests/unreachable_c_test/CMakeLists.txt | 11 +++ tests/unreachable_c_test/src/main.c | 11 +++ tests/unreachable_test/CMakeLists.txt | 4 +- 39 files changed, 256 insertions(+), 76 deletions(-) create mode 100644 tests/assert_c_test.expect create mode 100644 tests/assert_c_test/CMakeLists.txt create mode 100644 tests/assert_c_test/src/main.c create mode 100644 tests/assert_unit_c_test.expect create mode 100644 tests/assert_unit_c_test/CMakeLists.txt create mode 100644 tests/assert_unit_c_test/src/main.c create mode 100644 tests/fail_c_test.expect create mode 100644 tests/fail_c_test/CMakeLists.txt create mode 100644 tests/fail_c_test/src/main.c create mode 100644 tests/unreachable_c_test.expect create mode 100644 tests/unreachable_c_test/CMakeLists.txt create mode 100644 tests/unreachable_c_test/src/main.c diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 22de569..c9d6b2c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ lib_xassert change log ====================== +UNRELEASED +---------- + + * ADDED: Support for building and testing on XS and VX architectures. + * ADDED: C assertion tests while retaining XC compatibility tests on XS. + * CHANGED: Use lib_basix for portable trap, printing and timer support. + 5.0.0 ----- diff --git a/Jenkinsfile b/Jenkinsfile index f6ed210..a8a4f9b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ // This file relates to internal XMOS infrastructure and should be ignored by external users -@Library('xmos_jenkins_shared_library@v0.51.1') _ +@Library('xmos_jenkins_shared_library@v0.52.0') _ getApproval() pipeline { @@ -9,9 +9,14 @@ pipeline { parameters { string( - name: 'TOOLS_VERSION', + name: 'TOOLS_VERSION_XS', defaultValue: '15.3.1', - description: 'XTC tools version' + description: 'XS XTC tools version' + ) + string( + name: 'TOOLS_VERSION_VX', + defaultValue: '-j --repo arch_vx_slipgate -b master -a XTC 131', + description: 'VX XTC tools version' ) string( name: 'XMOSDOC_VERSION', @@ -54,44 +59,85 @@ pipeline { } } - stage('Examples build') { + stage('Build XS') { steps { dir("${REPO_NAME}/examples") { - xcoreBuild() + xcoreBuild( + toolsVersion: params.TOOLS_VERSION_XS, + buildDir: 'build-xs', + cmakeOpts: '-DAPP_HW_TARGET=XK-EVK-XU316' + ) } } } - stage('Repo checks') { + stage('Test XS') { steps { - warnError("Repo checks failed") { - runRepoChecks("${WORKSPACE}/${REPO_NAME}") + dir("${REPO_NAME}/tests") { + xcoreBuild( + toolsVersion: params.TOOLS_VERSION_XS, + buildDir: 'build-xs', + cmakeOpts: '-DAPP_HW_TARGET=XK-EVK-XU316 -DXASSERT_BUILD_XC_TESTS=ON', + archiveBins: false + ) + withTools(params.TOOLS_VERSION_XS) { + createVenv(reqFile: 'requirements.txt') + withVenv { + runPytest() + } + } } } } - stage('Doc build') { + stage('Build VX') { steps { - dir(REPO_NAME) { - buildDocs() + dir("${REPO_NAME}/examples") { + xcoreBuild( + toolsVersion: params.TOOLS_VERSION_VX, + buildDir: 'build-vx', + cmakeOpts: '-DAPP_HW_TARGET=XK-EVK-XU416' + ) } } } - stage('Tests') { + stage('Test VX') { steps { dir("${REPO_NAME}/tests") { - withTools(params.TOOLS_VERSION) { - createVenv(reqFile: "requirements.txt") + sh "find . -name '*.xe' -delete" + xcoreBuild( + toolsVersion: params.TOOLS_VERSION_VX, + buildDir: 'build-vx', + cmakeOpts: '-DAPP_HW_TARGET=XK-EVK-XU416 -DXASSERT_BUILD_XC_TESTS=OFF', + archiveBins: false + ) + withTools(params.TOOLS_VERSION_VX) { + createVenv(reqFile: 'requirements.txt') withVenv { - xcoreBuild(archiveBins: false) - sh "pytest -n auto --junitxml=pytest_result.xml" + runPytest() } } } } } + stage('Repo checks') { + steps { + warnError("Repo checks failed") { + runRepoChecks("${WORKSPACE}/${REPO_NAME}") + } + } + } + + stage('Doc build') { + steps { + dir(REPO_NAME) { + buildDocs() + } + } + } + stage("Archive sandbox") { steps { archiveSandbox(REPO_NAME) @@ -116,4 +162,3 @@ pipeline { } } // stages } // pipeline - diff --git a/README.rst b/README.rst index fc29881..4ed8e41 100644 --- a/README.rst +++ b/README.rst @@ -18,7 +18,7 @@ Summary This library provides a lightweight and flexible replacement for the standard C header ``assert.h``. -The assertions in this library can be be enabled/disabled and configured as to how much information +The assertions in this library can be enabled or disabled and configured to control how much information they show. This configuration can be per `xassert unit` (i.e. for sets of files). ******** @@ -28,6 +28,8 @@ Features * Low memory usage * Ability to enable or disable various features via compile time defines * Timing assertion system to check that code executes within a specified time limit +* Support for XS and VX architectures +* C and C++ support, with XC compatibility on XS ************ Known issues @@ -53,7 +55,7 @@ Required tools Required libraries (dependencies) ********************************* -* None +* `lib_basix `_ (https://www.github.com/xmos/lib_basix) ************************* Related application notes @@ -67,4 +69,3 @@ Support This package is supported by XMOS Ltd. Issues can be raised against the software at `www.xmos.com/support `_ or using GitHub `issues `_. - diff --git a/doc/exclude_patterns.inc b/doc/exclude_patterns.inc index 3dfea5e..aece52d 100644 --- a/doc/exclude_patterns.inc +++ b/doc/exclude_patterns.inc @@ -1,3 +1,7 @@ # The following patterns are to be excluded from the documentation build + +examples +tests +.pytest_cache **CHANGELOG.rst **LICENSE.rst diff --git a/examples/app_assert/CMakeLists.txt b/examples/app_assert/CMakeLists.txt index d72f66c..ff6aeaf 100644 --- a/examples/app_assert/CMakeLists.txt +++ b/examples/app_assert/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(app_assert) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) diff --git a/examples/app_fail/CMakeLists.txt b/examples/app_fail/CMakeLists.txt index bc25ad1..dcc5b19 100644 --- a/examples/app_fail/CMakeLists.txt +++ b/examples/app_fail/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(app_fail) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) diff --git a/examples/app_timed_block/CMakeLists.txt b/examples/app_timed_block/CMakeLists.txt index c7dcf39..874529f 100644 --- a/examples/app_timed_block/CMakeLists.txt +++ b/examples/app_timed_block/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(app_timed_block) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) diff --git a/examples/app_timed_loop/CMakeLists.txt b/examples/app_timed_loop/CMakeLists.txt index 4a067b0..d6afe8d 100644 --- a/examples/app_timed_loop/CMakeLists.txt +++ b/examples/app_timed_loop/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(app_timed_loop) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) diff --git a/examples/app_timed_loop/src/fn_no_assert.c b/examples/app_timed_loop/src/fn_no_assert.c index 4abe55b..21dd72b 100644 --- a/examples/app_timed_loop/src/fn_no_assert.c +++ b/examples/app_timed_loop/src/fn_no_assert.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include void fn_no_assert() diff --git a/examples/app_timing_loop_exception/CMakeLists.txt b/examples/app_timing_loop_exception/CMakeLists.txt index 71b6d44..ec1dfca 100644 --- a/examples/app_timing_loop_exception/CMakeLists.txt +++ b/examples/app_timing_loop_exception/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(app_timing_loop_exception) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) diff --git a/examples/app_unreachable/CMakeLists.txt b/examples/app_unreachable/CMakeLists.txt index 9bb2e33..9d4c606 100644 --- a/examples/app_unreachable/CMakeLists.txt +++ b/examples/app_unreachable/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(app_upreachable) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) diff --git a/lib_xassert/api/xassert.h b/lib_xassert/api/xassert.h index bbb48d0..87fb835 100644 --- a/lib_xassert/api/xassert.h +++ b/lib_xassert/api/xassert.h @@ -31,6 +31,8 @@ #define XASSERT_ENABLE_LINE_NUMBERS 0 #endif +#include + #define XASSERT_JOIN0(x,y) x ## y #define XASSERT_JOIN(x,y) XASSERT_JOIN0(x,y) @@ -71,7 +73,7 @@ #endif #if XASSERT_ENABLE_DEBUG0 -#include "print.h" +#include #if XASSERT_ENABLE_TIMING_ASSERTIONS0 #include #endif @@ -98,10 +100,10 @@ # if XASSERT_ENABLE_DEBUG0 # define xassert(e) do { if (!(e)) {\ printstr(#e); xassert_print_line; \ - __builtin_trap();} \ + basix_trap();} \ } while(0) # else -# define xassert(e) do { if (!(e)) __builtin_trap();} while(0) +# define xassert(e) do { if (!(e)) basix_trap();} while(0) # endif #else # define xassert(e) // disabled @@ -109,26 +111,26 @@ #if XASSERT_ENABLE_ASSERTIONS0 # if XASSERT_ENABLE_DEBUG0 -# define unreachable(msg) do { printstr(msg); xassert_print_line; __builtin_trap();} while(0) +# define unreachable(msg) do { printstr(msg); xassert_print_line; basix_trap();} while(0) # else -# define unreachable(msg) do { __builtin_trap();} while(0) +# define unreachable(msg) do { basix_trap();} while(0) # endif #else # define unreachable(msg) do { __builtin_unreachable();} while(0) #endif #if XASSERT_ENABLE_DEBUG0 -# define fail(msg) do { printstr(msg); xassert_print_line; __builtin_trap();} while(0) +# define fail(msg) do { printstr(msg); xassert_print_line; basix_trap();} while(0) # define fail_timing(tag, actual, limit, file, line) do { printstr("Timing failed for: "); \ printf("%s", (const char *) tag); \ fflush(stdout); \ printstr("\nΔt = "); printint(actual); printstr(" ticks ("); printint((actual) * 10); printstr(" ns), "); \ printstr("limit = "); printint(limit); printstr(" ticks ("); printint((limit) * 10); printstr(" ns) "); \ - xassert_timing_print_line(file, line); __builtin_trap();\ + xassert_timing_print_line(file, line); basix_trap();\ } while(0) #else -# define fail(msg) do { __builtin_trap();} while(0) -# define fail_timing(tag, actual, limit, file, line) do { __builtin_trap();} while(0) +# define fail(msg) do { basix_trap();} while(0) +# define fail_timing(tag, actual, limit, file, line) do { basix_trap();} while(0) #endif /* UNUSED() works for variables and references */ @@ -173,8 +175,6 @@ extern "C" { #if XASSERT_ENABLE_TIMING_ASSERTIONS0 -#include - #ifdef __XC__ # define UNSAFE unsafe #else @@ -207,9 +207,7 @@ typedef struct { static inline unsigned get_time(void) { - unsigned time; - asm volatile("gettime %0" : "=r"(time)); - return time; + return basix_time_now(); } static timing_block_t timing_blocks[XASSERT_MAX_TIMING_BLOCKS]; @@ -310,8 +308,7 @@ static inline void timing_loop_impl(const char *tag, unsigned min_freq_hz, const return; } - //unsigned interval = XS1_TIMER_HZ / min_freq_hz; - unsigned interval = (XS1_TIMER_HZ + min_freq_hz - 1) / min_freq_hz; // rounds up + unsigned interval = (BASIX_TIMER_HZ + min_freq_hz - 1) / min_freq_hz; // rounds up for (int i = head; i != tail; i = CIRCULAR_INC(i)) { diff --git a/lib_xassert/lib_build_info.cmake b/lib_xassert/lib_build_info.cmake index 12cf8af..9ed04b2 100644 --- a/lib_xassert/lib_build_info.cmake +++ b/lib_xassert/lib_build_info.cmake @@ -1,7 +1,7 @@ set(LIB_NAME lib_xassert) set(LIB_VERSION 5.0.0) set(LIB_INCLUDES api) -set(LIB_DEPENDENT_MODULES "") +set(LIB_DEPENDENT_MODULES "lib_basix(0.1.0)") set(LIB_OPTIONAL_HEADERS debug_conf.h xassert_conf.h) set(LIB_COMPILER_FLAGS -Wall diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f50fcab..3f62a65 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,13 +2,22 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(lib_xassert_tests) -add_subdirectory(assert_test) -add_subdirectory(assert_test_unit) -add_subdirectory(fail_test) +option(XASSERT_BUILD_XC_TESTS "Build XC compatibility tests" ON) + +add_subdirectory(assert_c_test) +add_subdirectory(assert_unit_c_test) +add_subdirectory(fail_c_test) +add_subdirectory(unreachable_c_test) add_subdirectory(timing_block_c_test) -add_subdirectory(timing_block_test) add_subdirectory(timing_debug_c_test) -add_subdirectory(timing_debug_test) add_subdirectory(timing_loop_c_test) -add_subdirectory(timing_loop_test) -add_subdirectory(unreachable_test) + +if(XASSERT_BUILD_XC_TESTS) + add_subdirectory(assert_test) + add_subdirectory(assert_test_unit) + add_subdirectory(fail_test) + add_subdirectory(timing_block_test) + add_subdirectory(timing_debug_test) + add_subdirectory(timing_loop_test) + add_subdirectory(unreachable_test) +endif() diff --git a/tests/assert_c_test.expect b/tests/assert_c_test.expect new file mode 100644 index 0000000..7180284 --- /dev/null +++ b/tests/assert_c_test.expect @@ -0,0 +1,2 @@ +0 +Unhandled exception: ECALL, data: 0x00000000 diff --git a/tests/assert_c_test/CMakeLists.txt b/tests/assert_c_test/CMakeLists.txt new file mode 100644 index 0000000..bd18bdd --- /dev/null +++ b/tests/assert_c_test/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.21) +include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) +project(assert_c_test) + +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) +XMOS_REGISTER_APP() diff --git a/tests/assert_c_test/src/main.c b/tests/assert_c_test/src/main.c new file mode 100644 index 0000000..16c6d16 --- /dev/null +++ b/tests/assert_c_test/src/main.c @@ -0,0 +1,11 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#define XASSERT_ENABLE_DEBUG 1 +#include + +int main(void) +{ + xassert(0); + return 0; +} diff --git a/tests/assert_test/CMakeLists.txt b/tests/assert_test/CMakeLists.txt index e469693..53e91c9 100644 --- a/tests/assert_test/CMakeLists.txt +++ b/tests/assert_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(assert_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/assert_test_unit/CMakeLists.txt b/tests/assert_test_unit/CMakeLists.txt index e24c3e3..0021102 100644 --- a/tests/assert_test_unit/CMakeLists.txt +++ b/tests/assert_test_unit/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(assert_test_unit) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/assert_unit_c_test.expect b/tests/assert_unit_c_test.expect new file mode 100644 index 0000000..7180284 --- /dev/null +++ b/tests/assert_unit_c_test.expect @@ -0,0 +1,2 @@ +0 +Unhandled exception: ECALL, data: 0x00000000 diff --git a/tests/assert_unit_c_test/CMakeLists.txt b/tests/assert_unit_c_test/CMakeLists.txt new file mode 100644 index 0000000..ea7d7ee --- /dev/null +++ b/tests/assert_unit_c_test/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.21) +include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) +project(assert_unit_c_test) + +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) +XMOS_REGISTER_APP() diff --git a/tests/assert_unit_c_test/src/main.c b/tests/assert_unit_c_test/src/main.c new file mode 100644 index 0000000..7d46dd3 --- /dev/null +++ b/tests/assert_unit_c_test/src/main.c @@ -0,0 +1,12 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#define XASSERT_UNIT TESTER +#define XASSERT_ENABLE_DEBUG_TESTER 1 +#include + +int main(void) +{ + xassert(0); + return 0; +} diff --git a/tests/fail_c_test.expect b/tests/fail_c_test.expect new file mode 100644 index 0000000..1fb77e1 --- /dev/null +++ b/tests/fail_c_test.expect @@ -0,0 +1,2 @@ +epic fail +Unhandled exception: ECALL, data: 0x00000000 diff --git a/tests/fail_c_test/CMakeLists.txt b/tests/fail_c_test/CMakeLists.txt new file mode 100644 index 0000000..9dd4531 --- /dev/null +++ b/tests/fail_c_test/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.21) +include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) +project(fail_c_test) + +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) +XMOS_REGISTER_APP() diff --git a/tests/fail_c_test/src/main.c b/tests/fail_c_test/src/main.c new file mode 100644 index 0000000..2fe646e --- /dev/null +++ b/tests/fail_c_test/src/main.c @@ -0,0 +1,11 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#define XASSERT_ENABLE_DEBUG 1 +#include + +int main(void) +{ + fail("epic fail"); + return 0; +} diff --git a/tests/fail_test/CMakeLists.txt b/tests/fail_test/CMakeLists.txt index f247343..d9fbbfc 100644 --- a/tests/fail_test/CMakeLists.txt +++ b/tests/fail_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(fail_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/timing_block_c_test/CMakeLists.txt b/tests/timing_block_c_test/CMakeLists.txt index 03e9c9b..84a1659 100644 --- a/tests/timing_block_c_test/CMakeLists.txt +++ b/tests/timing_block_c_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(timing_block_c_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/timing_block_c_test/src/main.c b/tests/timing_block_c_test/src/main.c index 5ce42c2..338155e 100644 --- a/tests/timing_block_c_test/src/main.c +++ b/tests/timing_block_c_test/src/main.c @@ -2,16 +2,12 @@ // This Software is subject to the terms of the XMOS Public Licence: Version 1. #include -#include int main(void) { - hwtimer_t t = hwtimer_alloc(); - xassert_timing_start("timed-block", 20); - hwtimer_delay(t, 200); + basix_delay_ticks(200); xassert_timing_end("timed-block"); - hwtimer_free(t); return 0; } diff --git a/tests/timing_block_test/CMakeLists.txt b/tests/timing_block_test/CMakeLists.txt index 723233c..1755e9b 100644 --- a/tests/timing_block_test/CMakeLists.txt +++ b/tests/timing_block_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(timing_block_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/timing_debug_c_test/CMakeLists.txt b/tests/timing_debug_c_test/CMakeLists.txt index a3447cf..6ae9bce 100644 --- a/tests/timing_debug_c_test/CMakeLists.txt +++ b/tests/timing_debug_c_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(timing_debug_c_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/timing_debug_c_test/src/main.c b/tests/timing_debug_c_test/src/main.c index 28b8395..423d925 100644 --- a/tests/timing_debug_c_test/src/main.c +++ b/tests/timing_debug_c_test/src/main.c @@ -5,16 +5,12 @@ #define XASSERT_ENABLE_TIMING_ASSERTIONS 1 #include -#include int main(void) { - hwtimer_t t = hwtimer_alloc(); - xassert_timing_start("timed-block", 1); - hwtimer_delay(t, 20); + basix_delay_ticks(20); xassert_timing_end("timed-block"); - hwtimer_free(t); return 0; } diff --git a/tests/timing_debug_test/CMakeLists.txt b/tests/timing_debug_test/CMakeLists.txt index a0ad773..456d1e7 100644 --- a/tests/timing_debug_test/CMakeLists.txt +++ b/tests/timing_debug_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(timing_debug_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/timing_loop_c_test/CMakeLists.txt b/tests/timing_loop_c_test/CMakeLists.txt index ea10e44..9a94bc6 100644 --- a/tests/timing_loop_c_test/CMakeLists.txt +++ b/tests/timing_loop_c_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(timing_loop_c_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/timing_loop_c_test/src/main.c b/tests/timing_loop_c_test/src/main.c index bebf691..acdfba3 100644 --- a/tests/timing_loop_c_test/src/main.c +++ b/tests/timing_loop_c_test/src/main.c @@ -4,16 +4,12 @@ #define XASSERT_ENABLE_TIMING_ASSERTIONS 1 #include -#include int main(void) { - hwtimer_t t = hwtimer_alloc(); - xassert_loop_freq("timed-loop", 100000000); - hwtimer_delay(t, 100); + basix_delay_ticks(100); xassert_loop_freq("timed-loop", 100000000); - hwtimer_free(t); return 0; } diff --git a/tests/timing_loop_test/CMakeLists.txt b/tests/timing_loop_test/CMakeLists.txt index 05cf9fa..55437c1 100644 --- a/tests/timing_loop_test/CMakeLists.txt +++ b/tests/timing_loop_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(timing_loop_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) diff --git a/tests/unreachable_c_test.expect b/tests/unreachable_c_test.expect new file mode 100644 index 0000000..14405de --- /dev/null +++ b/tests/unreachable_c_test.expect @@ -0,0 +1,2 @@ +unreachable +Unhandled exception: ECALL, data: 0x00000000 diff --git a/tests/unreachable_c_test/CMakeLists.txt b/tests/unreachable_c_test/CMakeLists.txt new file mode 100644 index 0000000..0870907 --- /dev/null +++ b/tests/unreachable_c_test/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.21) +include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) +project(unreachable_c_test) + +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) +XMOS_REGISTER_APP() diff --git a/tests/unreachable_c_test/src/main.c b/tests/unreachable_c_test/src/main.c new file mode 100644 index 0000000..eee721a --- /dev/null +++ b/tests/unreachable_c_test/src/main.c @@ -0,0 +1,11 @@ +// Copyright 2026 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#define XASSERT_ENABLE_DEBUG 1 +#include + +int main(void) +{ + unreachable("unreachable"); + return 0; +} diff --git a/tests/unreachable_test/CMakeLists.txt b/tests/unreachable_test/CMakeLists.txt index 66138b5..eafc5b6 100644 --- a/tests/unreachable_test/CMakeLists.txt +++ b/tests/unreachable_test/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.21) include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(unreachable_test) -set(APP_HW_TARGET XK-EVK-XU316) +if(NOT DEFINED APP_HW_TARGET) + set(APP_HW_TARGET XK-EVK-XU316) +endif() include(${CMAKE_CURRENT_LIST_DIR}/../../examples/deps.cmake)