To build Zircon and run unit tests, run one of the following commands:
# Build and run x64. fx set bringup.x64 --with-base //garnet/packages/tests:zircon fx build fx qemu # Build and run arm64. fx set bringup.arm64 --with-base //garnet/packages/tests:zircon fx build fx qemu
Once the scripts finish running, you should see the Zircon shell. To run userspace tests, use the Zircon shell to run:
To run in-kernel tests, use the Zircon shell to run:
k ut all
Fuchsia's Get Started page has more details about how to use the Zircon shell and how to automatically build all supported architectures.
The test harness, runtests, picks up and runs all of the executables from the
/system/test directories. If you provide a command-line
argument, such as
runtests -S -m widget_test, runtests will only run the
single test requested -- in this case,
"runtests" takes command-line arguments to toggle classes of tests to execute.
These classes are the following:
- Small: Isolated tests for functions and classes. These must be totally synchronous and single-threaded. These tests should be parallelizable; there shouldn't be any shared resources between them.
- Medium: Single-process integration tests. Ideally these are also synchronous and single-threaded but they might run through a large chunk of code in each test case, or they might use disk, making them a bit slower.
- Large: Slow, multi-process, or particularly incomprehensible single-process integration tests. These tests are often too slow / flaky to run in a CQ, and we should try to limit how many we have.
- Performance: Tests which are expected to pass, but which are measured using other metrics (thresholds, statistical techniques) to identify regressions.
Since runtests doesn't really know what "class" is executing when it launches a
test, it encodes this information in the environment variable
RUNTESTS_TEST_CLASS, which is detailed in the unittest
header , and lets the executable itself decide what to run /
not run. This environment variable is a bitmask indicating which tests to run.
For example, if a a test executable is run with "small" and "medium" tests,
it will be executed ONCE with
RUNTESTS_TEST_CLASS set to 00000003 (the
hex bitwise OR of "TEST_SMALL" and "TEST_MEDIUM" -- though this information
should be parsed using the unittest header, as it may be
updated in the future).
Zircon Tests (ulib/test, and/or using ulib/unittest)
The following macros can be used to filter tests into these categories:
RUN_TEST_SMALL(widget_tiny_test) RUN_TEST_MEDIUM(widget_test) RUN_TEST_LARGE(widget_big_test) RUN_TEST_PERFORMANCE(widget_benchmark)
RUN_TEST(widget_test) is aliased to mean the same thing as
Fuchsia Tests (not using ulib/unittest)
The environment variable
RUNTESTS_TEST_CLASS will still be available to all
executables launched by runtests. The unittest header can be
used to parse different categories of tests which the runtests harness attempted
By default, runtests will run both small and medium tests.
To determine how to run a custom set of test categories, run
which includes usage information.
The kernel contains unit tests and diagnostics, which can be run using the
command. The output of the
k command will only be shown on the
console. Depending on your configuration, this might be the serial console, or
debuglog virtual terminal.
Many parts of the kernel have unit tests, which report success/failure
automatically. These unit tests are built using the primitives provided by the
kernel unit-test library. You can find these statically
by searching for
These tests can be run from the shell with
k ut all will run all tests
or you can use
k ut $TEST_NAME to run a specific test.
Many parts of the kernel provide diagnostics, whose output requires manual
inspection. Some of these diagnostics are used to verify correctness
timer_diag), while others simply
stress test a part of the system
To run a diagnostic, simply pass its name to the
k command. For example, to
run the kernel's builtin benchmarks, run
bench. To find the full set of kernel diagnostics statically, search for
STATIC_COMMAND. To enumerate them dynamically, run
Diagnostic tests are intended to be run via serial console, or with physical access to the system. Some diagnostics may be destructive, and leave the system in a broken state.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.