Skip to content

fix(tests): include assert.h in test_net.c, which master no longer builds - #112

Closed
Kartikey1306 wants to merge 1 commit into
embeddedos-org:masterfrom
Kartikey1306:fix/test-net-missing-assert-header
Closed

Kartikey1306 wants to merge 1 commit into
embeddedos-org:masterfrom
Kartikey1306:fix/test-net-missing-assert-header

Conversation

@Kartikey1306

@Kartikey1306 Kartikey1306 commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

master does not compile

tests/test_net.c:212:5: error: call to undeclared function 'assert';
  ISO C99 and later do not support implicit function declarations
tests/test_net.c:232:5: error: ...
tests/test_net.c:249:5: error: ...

test_net.c makes ten assert() calls and includes stdio.h, stdlib.h and string.h — but never assert.h.

It built while every test target was compiled with NDEBUG. #104 removed that from test targets so the assertions in these suites are real again, and that is what turned the missing include into a hard error. The omission was always there; #104 made the compiler care.

Fix

Add the include. Nothing else changes.

I swept the rest of tests/*.c — this is the only file that calls assert() without including the header:

$ for f in $(grep -rl "assert(" tests/*.c); do
    grep -q "include <assert.h>" $f || echo "MISSING: $f"; done
MISSING: tests/test_net.c

Verified

$ cmake --build build -j8      # was: 3 errors
BUILD OK
$ ctest
100% tests passed, 34 of 34

and the assertions are genuinely live rather than compiled away — the binary still carries its test_net.c assertion strings, which is the guarantee #104 exists to provide.

…ilds

master does not compile:

    tests/test_net.c:212:5: error: call to undeclared function 'assert';
      ISO C99 and later do not support implicit function declarations

test_net.c makes ten assert() calls and includes stdio, stdlib and string
but never assert.h. It built while every test target was compiled with
NDEBUG, and embeddedos-org#104 removed that from test targets so the assertions in
these suites are real again -- which is what turned the missing include
into an error.

The include is what the file always needed; nothing else changes. Swept
the rest of tests/*.c and this is the only file that calls assert()
without including the header.

Restores the build: 34/34, and the assertions are live in the binary
rather than compiled away.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Kartikey1306

Copy link
Copy Markdown
Contributor Author

Merge-order note: this fixes the test build, but CI — eos stays red on its own — the default non-test build fails separately in net/src/net_posix.c. #113 fixes that and is green. Merging both, or just #113 (it contains this commit), returns master to green.

@Kartikey1306

Copy link
Copy Markdown
Contributor Author

Closing in favour of #113, which contains this commit (9d2f7ea) verbatim as the first of its two, and is green on all five jobs.

This PR cannot go green on its own: it fixes Build & Test (Linux x86_64), but the same workflow's Default configuration (no tests, no product) job fails separately in net/src/net_posix.c, which is what the second commit in #113 fixes. Merging #113 lands both and returns master to green in one step.

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