# Test Case: Build Undefined-Symbol Tool Failure

**Test ID**: TC161-build-nm-failure
**Category**: Build Qualification
**Priority**: Critical
**Regression**: `nm -u | awk` could pass when `nm` itself failed

## Objective

Verify that `build.sh` treats `nm` failure as fatal independently of the awk
`bcmp` check, safely removes its temporary output, preserves prior module output,
and still builds both supported configurations normally.

## Procedure

1. On FreeBSD 15, run normal exact-source builds with `WITH_ZSTDIO=0` and 1.
   Require both SUCCESS lines and save each module hash.
2. Create a private executable `nm` shim containing:

   ```sh
   #!/bin/sh
   exit 73
   ```

3. Put only that shim directory before the normal system paths and run
   `WITH_ZSTDIO=0 ./build.sh`, capturing stdout/stderr and exit status.
4. Require nonzero status, `ERROR: nm failed while checking erofs.ko`, no SUCCESS
   line, unchanged hash for the previously published `build/erofs.ko`, and no
   `build/obj/nm-undef.*` file.
5. Run one final normal build to prove the trap and shim did not contaminate the
   environment.

## Expected Results

- The shimmed build fails after module linkage and before publication.
- Awk cannot convert an `nm` execution failure into PASS.
- Temporary output is removed on failure and normal dual-configuration builds
  remain successful.
