Wayland logo

Wayland Unit Test Suite

The Wayland unit test suite is part of the Wayland source tree found under the tests directory. It leverages automake's Serial Test Harness to specify, compile, and execute the tests thru make check.

It is recommended that all Wayland developers create unit tests for their code. All unit tests should pass before submitting patches upstream. The Wayland maintainer(s) have the right to refuse any patches that are not accompanied by a unit test or if the patches break existing unit tests.

Compiling and Running

$ make check

NO_ASSERT_LEAK_CHECK=1 disables the test runner's simple memory checks.

Writing Tests

The test runner (tests/test-runner.h,c) predefines the main function, does simple memory leak checking for each test, and defines various convenience macros to simplify writing unit tests. When running a unit test group, the test runner executes each test case in a separate forked subprocess.

The TEST(<test name>) macro defines a test case that "passes" on a normal exit status of the test (i.e. exitcode 0). An abnormal exit status causes the test to "fail". Tests defined with this macro are auto-registered with the test runner.

The FAIL_TEST(<test name>) macro defines a test case that "passes" on a abnormal exit status of the test. A normal exit status causes the test to "fail". Tests defined with this macro are auto-registered with the test runner.

Weston Unit Test Suite

See the Weston documentation for information about the Weston test suite.