blob: 1bd7581039d2bf488d68332b28ec9f81e0b5657f [file] [log] [blame] [view]
Roland Levillain450b27a2019-07-24 14:06:56 +01001# ART Chroot-Based On-Device Testing
2
3This file documents the use of a chroot environment in on-device testing of the
4Android Runtime (ART). Using a chroot allows tests to run a standalone ART from
5a locally built source tree on a device running (almost any) system image and
6does not interfere with the Runtime installed in the device's system partition.
7
8## Introduction
9
10The Android Runtime (ART) supports testing in a chroot-based environment, by
11setting up a chroot directory in a `ART_TEST_CHROOT` directory located under
12`/data/local` (e.g. `ART_TEST_CHROOT=/data/local/art-test-chroot`) on a device,
13installing ART and all other required artifacts there, and having tests use `adb
14shell chroot $ART_TEST_CHROOT <command>` to execute commands on the device
15within this environment.
16
17This way to run tests using a "standalone ART" ("guest system") only affects
18files in the data partition (the system partition and other partitions are left
19untouched) and is as independent as possible from the Android system ("host
20system") running on the device. This has some benefits:
21
22* no need to build and flash a whole device to do ART testing (or "overwriting"
23 and existing ART by syncing the system partition);
24* the possibility to use a smaller AOSP Android manifest (`master-art`) to build
25 ART and the required dependencies for testing;
26* no instability due to updating/replacing ART on the system partition (a
27 functional Android Runtime is necessary to properly boot a device);
28* the possibility to have several standalone ART instances (one per directory,
29 e.g. `/data/local/art-test-chroot1`, `/data/local/art-test-chroot2`, etc.).
30
31Note that using this chroot-based approach requires root access to the device
32(i.e. be able to run `adb root` successfully).
33
34## Quick User Guide
35
360. Unset variables which are not used with the chroot-based approach (if they
37 were set previously):
38 ```bash
39 unset ART_TEST_ANDROID_ROOT
40 unset CUSTOM_TARGET_LINKER
41 unset ART_TEST_ANDROID_RUNTIME_ROOT
42 unset ART_TEST_ANDROID_TZDATA_ROOT
43 ```
441. Set the chroot directory in `ART_TEST_CHROOT`:
45 ```bash
46 export ART_TEST_CHROOT=/data/local/art-test-chroot
47 ```
482. Set lunch target and ADB:
49 * With a minimal `aosp/master-art` tree:
50 ```bash
51 export SOONG_ALLOW_MISSING_DEPENDENCIES=true
52 . ./build/envsetup.sh
53 lunch armv8-eng # or arm_krait-eng for 32-bit ARM
54 export PATH="$(pwd)/prebuilts/runtime:$PATH"
55 export ADB="$ANDROID_BUILD_TOP/prebuilts/runtime/adb"
56 ```
57 * With a full Android (AOSP) `aosp/master` tree:
58 ```bash
59 . ./build/envsetup.sh
60 lunch aosp_arm64-eng # or aosp_arm-eng for 32-bit ARM
Roland Levillaine47933a2019-08-09 14:06:02 +010061 m adb
Roland Levillain450b27a2019-07-24 14:06:56 +010062 ```
633. Build ART and required dependencies:
64 ```bash
65 art/tools/buildbot-build.sh --target -j40
66 ```
674. Clean up the device:
68 ```bash
69 art/tools/cleanup-buildbot-device.sh
70 ```
715. Setup the device (including setting up mount points and files in the chroot directory):
72 ```bash
73 art/tools/setup-buildbot-device.sh
74 ```
756. Populate the chroot tree on the device (including "activating" APEX packages
76 in the chroot environment):
77 ```bash
78 art/tools/buildbot-sync.sh
79 ```
807. Run ART gtests:
81 ```bash
82 art/tools/run-gtests.sh -j4
83 ```
84 * Note: This currently fails on test
85 `test-art-target-gtest-image_space_test{32,64}` when using the full AOSP
86 tree (b/119815008).
Roland Levillaine47933a2019-08-09 14:06:02 +010087 * Workaround: Run `m clean-oat-host` before the build step
Roland Levillain450b27a2019-07-24 14:06:56 +010088 (`art/tools/buildbot-build.sh --target -j40`) above.
89 * Note: The `-j` option is not honored yet (b/129930445).
Martin Stjernholm05b00862019-08-14 17:47:23 +010090 * Specific tests to run can be passed on the command line, specified by
91 their absolute paths beginning with "/apex/".
Roland Levillain450b27a2019-07-24 14:06:56 +0100928. Run ART run-tests:
93 * On a 64-bit target:
94 ```bash
95 art/test/testrunner/testrunner.py --target --64
96 ```
97 * On a 32-bit target:
98 ```bash
99 art/test/testrunner/testrunner.py --target --32
100 ```
1019. Run Libcore tests:
102 * On a 64-bit target:
103 ```bash
104 art/tools/run-libcore-tests.sh --mode=device --variant=X64
105 ```
106 * On a 32-bit target:
107 ```bash
108 art/tools/run-libcore-tests.sh --mode=device --variant=X32
109 ```
11010. Run JDWP tests:
111 * On a 64-bit target:
112 ```bash
113 art/tools/run-jdwp-tests.sh --mode=device --variant=X64
114 ```
115 * On a 32-bit target:
116 ```bash
117 art/tools/run-jdwp-tests.sh --mode=device --variant=X32
118 ```
11911. Tear down device setup:
120 ```bash
121 art/tools/teardown-buildbot-device.sh
122 ```
12312. Clean up the device:
124 ```bash
125 art/tools/cleanup-buildbot-device.sh
126 ```