Skip to content

Add a host-native unit test harness - #1266

Open
meeloo wants to merge 1 commit into
Duet3D:3.7-devfrom
meeloo:upstream/host-unit-tests
Open

Add a host-native unit test harness#1266
meeloo wants to merge 1 commit into
Duet3D:3.7-devfrom
meeloo:upstream/host-unit-tests

Conversation

@meeloo

@meeloo meeloo commented Aug 22, 2026

Copy link
Copy Markdown

Adds a host-native test harness under tests/: a small runner, shims for the firmware headers that pull in hardware, and unit tests for a few self-contained pieces (bitmap operations, deviation, FOPDT, integer square root).

The point is to be able to exercise pure logic on a development machine without flashing a board. It builds with the system compiler via tests/Makefile and does not touch the firmware build.

One portability fix was needed in RRFLibraries for this to compile on a 64-bit host - SimpleMath.h had a static_assert assuming 32-bit unsigned long. That lives in meeloo/RRFLibraries, branch feature/host-test-portability and would need a matching PR there.

Offered rather than proposed: where tests live and how they are run is a maintainer's call, and I have no visibility into whether this duplicates something you already have. Happy to restructure or drop it

Takes tests/ from the 3.7-unit-tests branch and fixes the three things that
stopped it building here:

 - RRFLibraries/src/General was on the include path. It holds String.h, which on
   a case-insensitive filesystem is what libc++'s <cstring> finds when it asks
   for <string.h>, so every translation unit that reached <cstring> failed.
   Sources get those headers through the General/ prefix instead.
 - CXX was assigned unconditionally, so CXX=clang++ on the command line was
   ignored. Now ?= .
 - test_fopdt.cpp targets the pre-3.7.0-beta.3 FopDt API and no longer compiles.
   Excluded with a note rather than guessed at; it needs whoever owns the heater
   model.

Needs the matching RRFLibraries commit that drops the 32-bit unsigned long
assertion in SimpleMath.h.

make test-host now runs 10 tests green. Note that this reaches leaf utilities
only - see tests/README.md for why the motion system is out of reach.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0132JC621uq1434yhpzBNNgJ
@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@meeloo

meeloo commented Aug 22, 2026

Copy link
Copy Markdown
Author

I have read the Duet3D CLA v2.0 and I hereby sign it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant