Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*.swn
*~
*.DS_Store
*.out
pytest_result.xml

# Python
*.pyc
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
lib_logging change log
======================

UNRELEASED
----------

* CHANGED: Removed unused <print.h> header.
* CHANGED: Replaced ".xc" files with ".c" files.
* CHANGED: Updated tests to use Pytest framework and xsim.

3.4.0
-----

Expand Down
56 changes: 23 additions & 33 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ pipeline {
)
string(
name: 'XMOSDOC_VERSION',
defaultValue: 'v7.4.0',
defaultValue: 'v8.0.1',
description: 'The xmosdoc version'
)
string(
name: 'INFR_APPS_VERSION',
defaultValue: 'v3.1.1',
defaultValue: 'v3.2.1',
description: 'The infr_apps version'
)
}

stages {
stage('🏗️ Build and checks') {
stage('🏗️ Build and test') {
agent {
label 'x86_64 && linux && documentation'
}
Expand Down Expand Up @@ -77,46 +77,36 @@ pipeline {
}
}
}
stage("Archive sandbox") {
steps
{
archiveSandbox(REPO_NAME)
}
}
}
} // stage: Build and checks

stage('xcore.ai Verification') {
agent {
label 'xcore.ai'
}
steps {
dir("${REPO_NAME}") {
checkoutScmShallow()
withTools(params.TOOLS_VERSION) {
dir("tests") {
xcoreBuild(archiveBins: false)

//Run this and diff against expected output. Note we have the lib files here available
sh 'xrun --io --id 0 debug_printf_test/bin/debug_printf_test.xe &> debug_printf_test.txt'
sh 'cat debug_printf_test.txt && diff debug_printf_test.txt test.expect'
stage('Tests') {
steps {

dir("${REPO_NAME}/tests") {
withTools(params.TOOLS_VERSION) {
createVenv(reqFile: "requirements.txt")
withVenv {
xcoreBuild(archiveBins: false)
sh "pytest -n auto --junitxml=pytest_result.xml"
}
}
}

dir("examples") {
unstash 'examples'

dir("${REPO_NAME}/examples") {
//Just run these and error on exception
sh 'xrun --io --id 0 app_debug_unit/bin/app_debug_unit.xe'
sh 'xrun --io --id 0 app_debug_printf/bin/app_debug_printf.xe'
}
}
}
}
post {
cleanup {
xcoreCleanSandbox()

stage("Archive sandbox") {
steps
{
archiveSandbox(REPO_NAME)
}
}
}
} // xcore.ai
} // stage: Build and test

stage('🚀 Release') {
steps {
Expand Down
8 changes: 4 additions & 4 deletions doc/rst/lib_logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Example application output

The example application outputs "Hello world".

.. literalinclude:: ../../examples/app_debug_unit/src/main.xc
.. literalinclude:: ../../examples/app_debug_unit/src/main.c
:language: c
:start-at: main(
:end-at: debug_printf(
Expand Down Expand Up @@ -163,14 +163,14 @@ Debug units by example
Applications can be created with different *units* whose debug output is independently
controlled. The example application also calls a function in another unit:

.. literalinclude:: ../../examples/app_debug_unit/src/main.xc
.. literalinclude:: ../../examples/app_debug_unit/src/main.c
:language: c
:start-at: unit_function(
:end-at: unit_function(

That file has put its debug messages as a separate debug unit by doing:

.. literalinclude:: ../../examples/app_debug_unit/src/unit.xc
.. literalinclude:: ../../examples/app_debug_unit/src/unit.c
:language: c
:start-at: define
:end-at: include
Expand All @@ -183,7 +183,7 @@ will only produce the following output.
$ xrun --xscope bin/app_debug_unit.xe
Hello world

In order to enable the debug_print messages in ``unit.xc`` it is necessary to
In order to enable the debug_print messages in ``unit.c`` it is necessary to
add to the list of compiler flags in the ``CMakeLists.txt`` file.

.. code-block:: cmake
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2025 XMOS LIMITED.
// Copyright 2015-2026 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <debug_print.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2025 XMOS LIMITED.
// Copyright 2014-2026 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

#include "debug_print.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2025 XMOS LIMITED.
// Copyright 2014-2026 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

#define DEBUG_UNIT unit
Expand Down
5 changes: 1 addition & 4 deletions lib_logging/api/debug_print.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2025 XMOS LIMITED.
// Copyright 2014-2026 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#ifndef _debug_printf_h_
#define _debug_printf_h_
Expand Down Expand Up @@ -61,9 +61,6 @@ enabled/disabled per debug unit.
*
* Any alignment or padding characters are simply ignored.
*
* The function uses the functions from ``print.h`` to do the
* underlying printing.
*
* Unlike printf this function has no return value.
*
* Whether the function does any output can be controlled via
Expand Down
9 changes: 3 additions & 6 deletions lib_logging/src/debug_printf.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright 2014-2025 XMOS LIMITED.
// Copyright 2014-2026 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <debug_print.h>
#include <print.h>
#include <stdarg.h>
#include <syscall.h>
#include <limits.h>
#include <print.h>
#include <string.h>
#include <ctype.h>

#include "debug_print.h"

#undef debug_printf

static void reverse_array(char buf[], int size)
Expand Down Expand Up @@ -137,5 +136,3 @@ void debug_printf(char * fmt, ...)

return;
}


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2025 XMOS LIMITED.
// Copyright 2015-2026 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <debug_print.h>

Expand Down
5 changes: 5 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# python_version 3.12.1
# pip_version 25.*

pytest>=8.3.3
pytest-xdist>=3.6.1
20 changes: 20 additions & 0 deletions tests/test_lib_logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2015-2026 XMOS LIMITED.
# This Software is subject to the terms of the XMOS Public Licence: Version 1.

import subprocess
from pathlib import Path

test_path = Path(__file__).parent
bin_path = test_path / "debug_printf_test/bin/debug_printf_test.xe"
expect_path = test_path / "test.expect"
out_path = test_path / "test.out"

assert bin_path.exists(), f"Test binary not found at {bin_path}"
assert expect_path.exists(), f"Expect file not found at {expect_path}"

def test_lib_logging():
cmd_xsim = ["xsim", str(bin_path)]
ret = subprocess.run(cmd_xsim, capture_output=True, text=True)
expected_text = expect_path.read_text()
out_path.write_bytes(ret.stdout.encode())
assert ret.stdout == expected_text