A native test for the platform typically accesses lower-level HALs or performs raw IPC against various system services. Therefore, the testing approach is usually tightly coupled with the service under test.
Build native tests using the gtest framework. This is a prerequisite for integration with continuous testing infrastructure.
Examples
Here are some examples of native tests in the platform source:
Summary of steps
- See sample native test module setup at: frameworks/base/libs/hwui/tests/unit/
- Test module configuation should use the
BUILD_NATIVE_TEST
build rule so gtest dependencies are included automatically - Write a test configuration. See the simple and complex options.
Build the test module with
mmm
ormma
(depends on if it's an incremental or full build), e.g.:make hwui_unit_tests -j
Use Atest to run the test locally:
atest hwui_unit_tests
Run the test with the Trade Federation test harness:
make tradefed-all -j tradefed.sh run template/local_min --template:map test=hwui_unit_tests
Manually install and run:
Push the generated test binary onto device:
adb push ${OUT}/data/nativetest/hwui_unit_tests/hwui_unit_tests \ /data/nativetest/hwui_unit_tests/hwui_unit_tests
Execute the test by invoking test binary on device:
adb shell /data/nativetest/hwui_unit_tests/hwui_unit_tests
This launches the native test. You can also add the
--help
parameter to your test binary to find out more about the different ways to customize test execution. Finally, see the gtest advanced guide for more parameters and their use.