Running Host Tests
There are two ways to build host tests: from a full build, or from a Lagom-only build. The only difference is the CMake command used to initialize the build directory.Full Build
For a full build, pass-DBUILD_LAGOM=ON to the CMake command.
Lagom-Only Build
For a Lagom-only build, pass the Lagom directory to CMake. TheBUILD_LAGOM CMake option is still required.
Running the Tests
In both cases, the tests can be run via ninja after doing a build.test-js requires the SERENITY_SOURCE_DIR environment variable to be set to the root of the serenity source tree when running on a non-SerenityOS host.Viewing Test Output
To see the stdout/stderr output of failing tests, the recommended way is to set the environment variableCTEST_OUTPUT_ON_FAILURE to 1.
Running with Sanitizers
CI runs host tests with Address Sanitizer and Undefined Sanitizer instrumentation enabled. These tools catch many classes of common C++ errors, including memory leaks, out of bounds access to stack and heap allocations, and signed integer overflow. The sanitizers can be enabled with the-DENABLE_FOO_SANITIZER set of flags. For the Serenity target, only the Undefined Sanitizers is supported.
halt_on_error flag should be set to 1 in the environment variable UBSAN_OPTIONS.
Running Target Tests
Tests built for the SerenityOS target get installed either into/usr/Tests or /bin. /usr/Tests is preferred, but some system tests are installed into /bin for historical reasons.
The easiest way to run all of the known tests in the system is to use the run-tests-and-shutdown.sh script that gets installed into /home/anon/Tests.
When running in CI, the environment variable
$DO_SHUTDOWN_AFTER_TESTS is set, which will run shutdown -n after running all the tests.Basic On-Target Test Run
For completeness, a basic on-target test run will need the SerenityOS image built and run via QEMU.CI Test Mode
CI runs the tests in self-test mode, using the ‘ci’ run options and the TestRunner entry in/etc/SystemServer.ini to run tests automatically on startup.
The system server entry looks as below:
/dev/ttyS0 is used as stdio because that serial port is connected when qemu is run with -display none and -serial stdio, and output to it will show up in the stdout of the qemu window. Separately, the CI run script redirects the serial debug output to ./debug.log so that both stdout of the tests and the dbgln from the kernel/tests can be captured.