Skip to content

Testing

Phillippe Pelzer edited this page Nov 24, 2026 · 3 revisions

Testing

The project has four kinds of test scripts. This page says what each one does and how to run it.

Script What it checks Needs a build?
tests/unit/run.sh The C code in scripts/includes (compiled and run on its own) and the shell tests of the runtime scripts. No
tests/smoke.test.sh The smoke script itself, against stub binaries. No
tests/smoke.sh, tests/smoke.ps1 A built binary starts, reports the version and exits cleanly. Plus the checks listed below. Yes
tests/tests.sh, tests/tests.ps1 The full codec and hardware suite. Yes

Paths are from the repository root. To get a build, see Building Locally.

Unit tests

tests/unit/run.sh

It compiles each tests/unit/test_*.c against scripts/includes with -Wall -Wextra -Werror, runs it, and runs each test_*.sh. It uses $CC if set, else cc. No FFmpeg build is needed.

tests/smoke.test.sh

This runs tests/smoke.sh against stub ffmpeg and ffprobe scripts. It proves that each smoke check fails when it should: a missing codec, a decode error, a flat or truncated alpha result.

Smoke test

tests/smoke.sh <workspace> <expected_version> [platform]
./tests/smoke.ps1 -Workspace <dir> -ExpectedVersion <version> -Platform <platform>

<workspace> is the folder where you unpacked the archive. CI passes the release line, 9.1, as the expected version. The check looks for that text in ffmpeg -version, which says 9.1.

A runner cannot execute a binary built for another CPU or another OS. For those platforms the script does not execute anything. It checks the file header instead (ELF for Linux and FreeBSD, PE for Windows ARM64). That is what the CI smoke job does for linux-aarch64, freebsd-x86_64 and windows-aarch64.

The smoke job also runs these checks on every platform the runner can execute:

  • the ggml CPU variant dispatcher is present, and NOMERCY_GGML_CPU can never stop the binary from starting (see CPU Instruction Sets),
  • JPEG XL, HAP and APV encoders work on a generated clip (see Codecs-and-Libraries),
  • the stemsplit release gates (see Filter-stemsplit),
  • on Linux x86_64: the whisper checks, the lyricsalign checks, and a run on hosts with glibc 2.35, 2.36, 2.39 and 2.43 (tests/lib/glibc-hosts.sh, which needs Docker).

The full suite

tests/tests.sh <workspace> [--platform <name>] [--json <report path>]
./tests/tests.ps1 -Workspace <dir> [-Platform <name>] [-JsonReport <path>]

The workspace holds the unpacked ffmpeg. The script makes small sample files in <workspace>/sample_files, then runs encode and decode tests for the codecs, filters and muxers in the build.

Hardware encoders are tested only when the machine has the hardware. A missing GPU is a skip with a reason in the output. It is never a silent pass and never a failure.

--json writes a report. The release verification uses it. See CI and Releases.

Tests that need assets

Some checks need a model or a test clip. Without them, they skip and print why.

Check Set this Notes
whisper WHISPER_TEST_MODEL, WHISPER_TEST_AUDIO ggml-base.en.bin and whisper.cpp's jfk.wav.
whisper VAD WHISPER_TEST_VAD_MODEL ggml-silero-v5.1.2.bin.
whisper default output WHISPER_TEST_REFERENCE_FFMPEG A build of the previous release, to compare against.
lyricsalign LYRICSALIGN_ASSETS_DIR Fetch it with tests/lib/lyricsalign-assets.sh <dir>.
lyricsalign on a GPU LYRICSALIGN_TEST_GPU=1 Adds the use_gpu=1 check.

tests/lib/lyricsalign-assets.sh downloads the model by SHA-256 and prints the line to export:

eval "$(tests/lib/lyricsalign-assets.sh ~/nm-assets)"

The stemsplit gates use their own assets. The project's CI fetches them. Without them those checks skip.

Making a skip fail

CI must not pass because a check skipped. These variables turn a skip into a failure.

Variable Applies to
WHISPER_TEST_REQUIRED=1 whisper checks
STEMSPLIT_TEST_REQUIRED=1 stemsplit gates
LYRICSALIGN_TEST_REQUIRED=1 lyricsalign checks (except the GPU check)

Set them when you want a missing asset to be an error, for example before you ask a maintainer to review.

Adding a test

  • A new filter, muxer or codec gets a check in tests/tests.sh and tests/tests.ps1. Keep both in step.
  • Logic you can test without FFmpeg gets a tests/unit/test_*.c or test_*.sh.
  • A new check that can skip must say why it skipped.
  • A check must be able to fail. Test it against a binary that lacks the feature.

Verify a release candidate

tests/verify-rc.sh and tests/verify-rc.ps1 check one archive from a release candidate. The project's workflow calls them. They check the archive's SHA-256 against manifest.json, unpack it, run the full suite, and write a verdict file. See CI and Releases.

Clone this wiki locally