Skip to content

tests: run the wolfCrypt self-test once per make check and ctest - #12280

Open
yosuke-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/unit-test
Open

yosuke-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/unit-test

Conversation

@yosuke-wolfssl

Copy link
Copy Markdown
Contributor

Problem

make check runs the full wolfCrypt self-test twice: in testsuite.test and again in unit.test. ctest does the same with wolfcrypttest and unit_test.

The cost is largest in the PQ small-mode configs, where XMSS dominates the self-test. all-pq-small-noasm is the slowest config in its "Quantum Resistant Tests" shard. That shard hit the 45-minute timeout in 19 of about 100 recent PR runs, and passed at 44-45 minutes in another 12.

Fix (testsuite/testsuite.c)

  • testsuite_test() runs the self-test in every build, then the TLS tests where the build has them (HAVE_TESTSUITE_TLS_TESTS_DEPENDENCIES).
  • unit.test gets --no-wc wherever a dedicated program owns the self-test:
Build Self-test runs in unit.test
autotools, testsuite.test built testsuite.test --no-wc
autotools, --enable-leantls unit.test unchanged
CMake, WOLFSSL_CRYPT_TESTS wolfcrypttest --no-wc

Running ./tests/unit.test by hand still includes the self-test.

Verification

  • all-pq-small-noasm, make check on 4 CPUs (Linux aarch64): 582 s → 392 s, same results (18 pass, 7 skip; 2783 of 3311 API tests pass, the rest skip).
  • One self-test run, make check passing, in: default, NO_WOLFSSL_CLIENT, no-tls-cryptocb-aesgcm-setkey-free, --enable-leantls, cryptocb-only ECC (swdev + TLS), --enable-stacksize (stack use still reported).
  • CMake default build: ctest runs unit.test --no-wc and testwolfcrypt; both pass.
  • GCC 13.3 with -Werror -pedantic -Wdeclaration-after-statement: clean.

- testsuite_test() runs wolfcrypt_test() in every build, with its own
  func_args, before the TLS tests.
- configure.ac sets UNIT_TEST_WC_ARG to --no-wc when testsuite.test is
  built (examples enabled, leantls disabled), and scripts/unit.test
  passes it to tests/unit.test.
- CMake passes --no-wc to the unit_test ctest entry when
  WOLFSSL_CRYPT_TESTS registers wolfcrypttest.
@yosuke-wolfssl yosuke-wolfssl self-assigned this Nov 26, 2026
Copilot AI balanced review requested due to automatic review settings November 26, 2026 06:31
@yosuke-wolfssl

Copy link
Copy Markdown
Contributor Author

@claude review

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,864 B (+4.9%, 296,444 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the changes that avoid duplicate wolfCrypt self-test runs.

No open issues 🎉

What changed in this PR

This PR avoids duplicate wolfCrypt self-test runs during make check and ctest, reducing test time, especially for costly post-quantum configurations. Direct invocation of tests/unit.test still includes the self-test.

Changes:

  • Separates wolfCrypt self-test execution from TLS test prerequisites in testsuite_test().
  • Passes --no-wc to automated unit tests when a dedicated program owns the self-test.
  • Preserves unit-test self-test execution when no dedicated runner is available.
File Description
testsuite/​testsuite.c Runs the self-test independently of TLS tests, with wolfCrypt initialization and cleanup.
scripts/​unit.test.in Forwards the configured self-test skip argument through every launcher path.
configure.ac Sets --no-wc when the testsuite program is built.
CMakeLists.txt Adds --no-wc to CTest unit tests when crypto tests are enabled.

Review effort: Balanced

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This is a small test-harness change, and the conditions for passing --no-wc line up with where the wolfCrypt self-test still runs.

What was reviewed:

  • configure.ac: UNIT_TEST_WC_ARG uses the same test as BUILD_EXAMPLE_SERVERS, which is what gates building testsuite.test. testsuite_test() now runs the self-test even without the TLS dependencies, so builds such as NO_WOLFSSL_CLIENT still run it once.
  • CMake: --no-wc is passed only under WOLFSSL_CRYPT_TESTS, the same option that registers the wolfcrypttest ctest. tests/unit.c already accepts --no-wc. make check runs unit.test through scripts/unit.test, which now gets the flag.
  • testsuite.c: declarations stay at the top of the block (C90). argc/argv are still used through wc_args when the macro is undefined. NO_CRYPT_TEST skips the self-test in both testsuite.test and unit.test. Init and cleanup are balanced, and wolfSSL_Cleanup now runs before wc_SwDev_Cleanup.
  • I did not rebuild under the other feature-macro configurations AGENTS.md lists. This review covered the C code and the build conditions by reading only.
Extended reasoning...

The change touches testsuite/testsuite.c, configure.ac, scripts/unit.test.in and CMakeLists.txt. Together they stop make check and ctest from running the wolfCrypt self-test twice. It changes test and build plumbing only, not library code, and touches no security-sensitive runtime path. I checked the autotools condition against the testsuite.test build gate and the CMake condition against the wolfcrypttest registration, and both match. The --no-wc flag already exists in tests/unit.c. The repository has no CODEOWNERS file, and the timeline shows no outstanding reviewer objections.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #12280

Scan targets checked: wolfssl-bugs
Not reviewed (no scan target covers them): CMakeLists.txt, configure.ac, scripts/unit.test.in
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

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.

4 participants