wolfBoot/tools/unit-tests
David Garske 9ca1d435b9 Peer review fixes (copilot)
src/fdt.c, include/fdt.h
  - Propagate fdt_fixup_initrd error in fit_load_ramdisk so a /chosen
    patch failure no longer silently boots a kernel with no initrd.
  - Add fit_load_image_to(): decompress (or memcpy) directly to a
    caller-supplied destination buffer instead of going through the
    FIT-declared `load` address. fit_load_ramdisk now uses this when
    WOLFBOOT_LOAD_RAMDISK_ADDRESS is set, so the override is a real
    safety bound for compressed ramdisks (previously the gzip stream
    was still inflated to the FIT `load` and only memcpy'd afterward).
  - Refactor fit_load_image_ex into a shared inner helper.
  - Reword the WOLFBOOT_FIT_MAX_DECOMP comment: the cap is a sanity
    ceiling, not a per-destination memory-safety bound. Authenticity
    is provided by the outer wolfBoot signature; tighter bounds need
    fit_load_image_ex / _to with an explicit out_max / dst_max.
  - Add WOLFBOOT_FIT_MAX_RAMDISK (defaults to WOLFBOOT_FIT_MAX_DECOMP)
    so targets can pin a tighter ramdisk decompression bound.

src/update_ram.c, src/update_disk.c
  - Panic when fit_load_image() returns NULL for the kernel subimage
    instead of letting load_address=NULL propagate into do_boot().

tools/unit-tests/unit-gzip.c
  - Add deterministic stored / fixed-Huffman / dynamic-Huffman gzip
    fixtures so the inflater's BTYPE 00/01/10 paths are exercised
    independent of host gzip(1) heuristics.
  - Add FEXTRA / FNAME / FCOMMENT / FHCRC and combined-flag fixtures
    plus a truncated-FEXTRA negative case to cover the optional gzip
    header parser.

tools/unit-tests/unit-fit-gzip.c (new), tools/unit-tests/Makefile
  - New libcheck binary covering the FIT loader's compression
    branches: gzip success, gzip stream corruption, unknown
    compression, compression="none" baseline, and the no-load
    fail-closed path. Built twice from the same source - once with
    WOLFBOOT_GZIP for the success / runtime-failure paths, and once
    without it so the compile-time fail-closed branch is also tested.
2026-05-05 10:16:16 +02:00
..
Makefile Peer review fixes (copilot) 2026-05-05 10:16:16 +02:00
README.md
gpt-sfdisk-test.h
target.h Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
txt_filler.h
unit-boot-x86_fsp.c
unit-common.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-delta.c Cap backward delta match length 2026-04-29 11:34:23 +02:00
unit-disk.c Add GPT single-sector partition test 2026-04-29 12:24:41 +02:00
unit-enc-nvm.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-extflash.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-fdt.c Rebased, addressed comments 2026-03-30 16:30:27 +02:00
unit-fit-gzip.c Peer review fixes (copilot) 2026-05-05 10:16:16 +02:00
unit-fwtpm-stub.c Proper interface renaming + documentation 2026-04-22 14:14:28 +02:00
unit-gzip.c Peer review fixes (copilot) 2026-05-05 10:16:16 +02:00
unit-image.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-keygen-xmss-params.c Fix XMSS keygen param fallback 2026-04-29 12:30:23 +02:00
unit-keystore.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-loader-tpm-init.c loader: panic on TPM init failure 2026-04-14 07:48:59 +02:00
unit-max-space.c Fix WOLFBOOT_MAX_SPACE precedence and test 2026-04-14 14:28:44 +02:00
unit-mock-flash.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-mock-state.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-multiboot.c Fix multiboot debug header length guard 2026-04-29 11:27:58 +02:00
unit-nvm.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-parser.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-pci.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-pkcs11_store.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-policy-create.c Fix policy_create PCR digest validation 2026-04-08 19:51:17 +02:00
unit-policy-sign.c
unit-psa_store.c Fix store header search bounds 2026-03-30 16:23:16 +02:00
unit-qspi-flash.c Abort QSPI writes after WE failure 2026-04-29 12:13:40 +02:00
unit-rot-auth.c Rebased, addressed comments 2026-03-30 16:30:27 +02:00
unit-sdhci-disk-unaligned.c Clamp unaligned SDHCI disk I/O spans 2026-04-14 07:38:41 +02:00
unit-sdhci-response-bits.c Fix SDHCI response bit span check 2026-03-30 16:23:16 +02:00
unit-sectorflags.c Add sector flag unit coverage 2026-04-29 12:26:55 +02:00
unit-sign-encrypted-output.c Reject oversized signature TLV lengths 2026-04-14 14:25:10 +02:00
unit-sign-encrypted-output.mkfrag Fix sign encrypted output open failure 2026-04-08 19:53:50 +02:00
unit-spi-flash.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-store-sbrk.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-string.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-tpm-api-names.c Bound TPM name fallback copies 2026-04-29 12:16:03 +02:00
unit-tpm-blob.c Fix TPM unseal handle cleanup 2026-04-14 07:46:13 +02:00
unit-tpm-check-rot-auth.c Rebased, addressed comments 2026-03-30 16:30:27 +02:00
unit-tpm-rsa-exp.c
unit-uart-flash.c Addressed copilot's comments 2026-04-29 13:15:52 +02:00
unit-update-disk.c Add single-partition disk boot tests 2026-04-29 11:32:24 +02:00
unit-update-flash.c Add inverse delta version gate tests 2026-04-29 12:23:03 +02:00
unit-update-ram-nofixed.c Fixed regression in update_ram tests 2026-04-15 23:22:00 +02:00
unit-update-ram.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00

README.md

Unit Test Tools

This uses the "check" unit test framework for C.

You may need to run "apt install check", "yum install check" or "brew install check".

Building

Use make to build.

Expected output

$ ./unit-parser
Running suite(s): wolfBoot
Explicit end of options reached
This field is too large (bigger than the space available in the current header)
This field is too large and would overflow the image header
Illegal address (too high)
Illegal address (too high)
100%: Checks: 2, Failures: 0, Errors: 0