ART Testing has early support for execution in the Trade Federation ("TradeFed") test harness, in particular via the Atest command line tool.
Atest conveniently takes care of building tests and their dependencies (using Soong, the Android build system) and executing them using Trade Federation.
See also README.md for a general introduction to ART run-tests and gtests.
ART run-tests are defined in sub-directories of test/
starting with a number (e.g. test/001-HelloWorld
). Each ART run-test is identified in the build system by a Soong module name following the art-run-test-
<test-directory>
format (e.g. art-run-test-001-HelloWorld
).
You can run a specific ART run-test on device by passing its Soong module name to Atest:
atest art-run-test-001-HelloWorld
To run all ART run-tests in a single command, the currently recommended way is to use test mapping (see below).
Because of current build- and link-related limitations, ART gtests can only run as part of the Testing ART APEX (com.android.art.testing.apex
) on device, i.e. they have to be part of the ART APEX package itself to be able to build and run properly. This means that it is not possible to test the ART APEX presently residing on a device (either the original one, located in the "system" partition, or an updated package, present in the "data" partition).
There are two ways to run ART gtests on device:
chroot
environment on the device, and "activating" the Testing ART APEX in that environment.You can run ART gtests on device with the ART APEX installation strategy by using the following atest
command:
atest ArtGtestsTargetInstallApex
This command:
adb install
;You can run the tests of a single ART gtest C++ class using the ArtGtestsTargetInstallApex:
<art-gtest-c++-class>
syntax, e.g.:
atest ArtGtestsTargetInstallApex:JniInternalTest
This syntax also supports the use of wildcards, e.g.:
atest ArtGtestsTargetInstallApex:*Test*
You can also use Trade Federation options to run a subset of ART gtests, e.g.:
atest ArtGtestsTargetInstallApex -- \ --module ArtGtestsTargetInstallApex --test '*JniInternalTest*'
You can also pass option --gtest_filter
to the gtest binary to achieve a similar effect:
atest ArtGtestsTargetInstallApex -- \ --test-arg com.android.tradefed.testtype.GTest:native-test-flag:"--gtest_filter=*JniInternalTest*"
chroot
environmentYou can run ART gtests on device with the chroot-based strategy by using the following atest
command:
atest ArtGtestsTargetChroot
This command:
chroot
environment;chroot
environment on the device;chroot
environment;chroot
environment; andchroot
environment).ART Testing supports the execution of tests via Test Mapping. The tests declared in ART's TEST_MAPPING file are executed during pre-submit testing (when an ART changelist in Gerrit is verified by Treehugger) and/or post-submit testing (when a given change is merged in the Android code base), depending on the "test group" where a test is declared.
It is possible to run tests via test mapping locally using Atest.
To run all the tests declared in ART's TEST_MAPPING
file, use the following command from the Android source tree top-level directory:
atest --test-mapping art:all
In the previous command, art
is the (relative) path to the directory containing the TEST_MAPPING
file listing the tests to run, while all
means that tests declared in all test groups shall be run.
To only run tests executed during pre-submit testing, use:
atest --test-mapping art:presubmit
To only run tests executed during post-submit testing, use:
atest --test-mapping art:postsubmit