How to Run Libopus Test Suite After Compilation
This article provides a direct, step-by-step guide on how to execute
the comprehensive built-in test suite for the libopus audio
codec immediately after compilation. It covers the specific commands
required for both the traditional Autotools build system and the modern
CMake build system to verify that your compiled binary is stable and
functioning correctly.
The libopus source code includes a built-in testing
suite that validates the encoder, decoder, API integrity, and math
operations. Depending on how you configured and compiled the library,
you will use either Autotools or CMake to run these tests.
Method 1: Running Tests with Autotools
If you compiled libopus using the standard Autotools
pipeline (./configure and make), you can run
the test suite using the check target.
Configure and build the library:
./configure makeExecute the test suite: Immediately after the build completes, run:
make check
This command compiles the test binaries (such as
test_opus_api, test_opus_decode, and
test_opus_encode) and runs them. The terminal will display
the progress and output a summary of passed and failed tests.
Method 2: Running Tests with CMake
If you compiled libopus using CMake, you must ensure
that testing is enabled during the configuration step, and then use
ctest to execute the suite.
Configure the build directory (ensuring tests are enabled):
cmake -B build -DOPUS_BUILD_TESTING=ONCompile the library and the test binaries:
cmake --build buildExecute the test suite: Navigate into the build directory and run
ctest, or target the test runner directly:cd build ctest --output-on-failure(The
--output-on-failureflag is optional but recommended, as it displays detailed logs if any specific test fails.)