tree: cde1bd3d114cb88b043ac0ce27ef8881654ec8f3 [path history] [tgz]
  1. address-tagging/
  2. bad-segsel/
  3. bad-syscall/
  4. bti/
  5. c11-condvar/
  6. c11-mutex/
  7. c11-thread/
  8. channel/
  9. channel-call-etc/
  10. channel-iovec/
  11. channel-write-etc/
  12. clock/
  13. debuglog/
  14. default-exception-handler/
  15. elf-tls/
  16. event-pair/
  17. exceptions/
  18. fifo/
  19. fpu/
  20. futex/
  21. handle-close/
  22. handle-dup/
  23. handle-info/
  24. handle-transfer/
  25. handle-wait/
  26. interrupt/
  27. job/
  28. kernel-unittests/
  29. memory-mapping/
  30. next-vdso/
  31. object-child/
  32. object-info/
  33. object-wait/
  34. page-size/
  35. pager/
  36. pager-writeback/
  37. port/
  38. process/
  39. profile/
  40. property/
  41. pthread/
  42. pthread-barrier/
  43. pthread-tls/
  44. resource/
  45. socket/
  46. stack/
  47. stream/
  48. sync-completion/
  49. sync-condition/
  50. sync-mutex/
  51. syscall-generation/
  52. system-cpu/
  53. system-event/
  54. threads/
  55. time/
  56. version/
  57. vmar/
  58. vmo/
  59. BUILD.gn
  60. OWNERS
  61. README.md
  62. standalone-init.cc
  63. standalone-io.cc
  64. standalone-options.cc
  65. standalone.h
  66. test-main-with-filter.cc
zircon/system/utest/core/README.md

utest/core

The “core” tests exist for one main purpose: To test basic functionality when things like devmgr aren't working.

There are three different ways in which core tests are built and run: unified, standalone, and as Fuchsia components.

Unified mode

In this mode, all core tests are built into a single executable that is directly invoked by the kernel. That is, the kernel is told to run core-tests instead of devmgr. In this mode the tests will run without any userspace device manager, device drivers, io plumbing, etc.

Example usage

fx set core.x64   # any of {bringup,core}.{x64,arm64} are fine too.
fx build
fx core-tests [--gtest_filter=FILTER] [--gtest_repeat=REPEAT]

The helper fx command runs QEMU (or FEMU) providing the specially-built core-tests.zbi as a -z argument.

Only a subset of tests can be specified by gtest_filter, e.g. --gtest_filter="FutexTest.*"

Tests can be rerun with gtest_repeat, e.g. --gtest_repeat=100 to run all tests 100 times or --gtest_repeat=-1 to run all tests until a test fails.

Standalone mode

In this mode, each test is built into its own binary which can be run “manually” from a serial shell or via runtests. Not all core tests can operate in standalone mode. For example, some tests require the root resource which is only available to tests running in unified mode. See unified_only in BUILD.gn for a list of such tests.

Example usage

fx set bringup.x64 --with-base //bundles/bringup:tests
fx build
fx qemu

Then at the shell prompt,

/boot/test/core-futex --gtest_filter='FutexTest.Wakeup' --gtest_repeat=10

or

runtests /boot/test/core-*

Fuchsia components

In this mode, each test is built into its own binary and wrapped up as a component in a package. Not all core tests can operate in this mode, and some tests require policies that are not granted to regular components. Some tests are not available in this mode and some tests skip specific cases in this mode.

This mode can provide a faster iteration cycle for the tests since the edit-compile-test cycle only needs to rebuild and update the package containing the test and not rebuilding or rebooting the system.

Some tests require the next vDSO, which is not available in the standalone mode on bringup builds. These tests are built as standalone binaries and packaged as Fuchsia components instead of standalone bootfs tests. Note that this is a temporary workaround for the next vDSO not being available in the standalone mode in bringup builds. Refer to fxbug.dev/89597 for more context. See requires_next_vdso in BUILD.gn for a list of such tests.

Example usage

fx set core.x64 --with //zircon/system/utest/core:tests
fx build
fx emu ...

Then on the host,

fx test fuchsia-pkg://fuchsia.com/core-page-size-test-package

Limitations

In this mode the set of job policies applied to the tests is restricted compared to the unified and standalone modes. Some test cases are skipped due to missing these policies:

  • ZX_POL_NEW_PROCESS

    If this policy is not available, the environment variable “NO_NEW_PROCESS=1” is set and tests requiring this are skipped.

  • ZX_POL_AMBIENT_MARK_VMO_EXEC

    If this policy is not available, the environment variable “NO_AMBIENT_MARK_VMO_EXEC=1” is set and tests requiring this are skipped.

Notes

The tests here are for “core” functionality (channels, etc.), but not all “core” functionality can go here. For example, you can‘t start a process in your test with launchpad because core tests are for when that functionality isn’t working. Core tests can't use fdio and launchpad uses fdio.

Since these tests can't use fdio core/libc-and-io-stubs.c stubs out the needed functions from fdio.

An additional kernel debugging option of kernel.pmm.alloc-random-should-wait is enabled for these tests. It has a small performance overhead for the purpose of exercising some of the allocation paths that otherwise are only executed under certain OOM conditions. This path exploration is random and the errors may be realized in any of the core tests, and should not be ignored.