Virtual devices in Android Test Station

Android Test Station supports Cuttlefish virtual devices that let you run tests without physical Android devices. Cuttlefish is suitable for testing hardware-independent functions. Before starting to use virtual devices, follow the user guide to install Android Test Station.

Install Cuttlefish dependencies

Run the following command to ensure that the necessary kernel modules are loaded:

sudo modprobe -a kvm tun vhost_net vhost_vsock

Start Android Test Station with virtual devices

To enable virtual devices, run:

mtt start --max_local_virtual_devices N

N is the maximum number of virtual devices that ATS can simultaneously allocate. The default number is 0.

If the command fails due to missing device nodes, follow the steps in the error message to load the kernel modules. If it continues to fail, reboot the machine.

You must shut down all Cuttlefish instances before running the command. ATS automatically launches and shuts down the virtual devices during the test cycle. The existing Cuttlefish instances conflict with those managed by ATS.

Run a test with virtual devices

Select devices

On the device list, ATS displays virtual devices as placeholders instead of their actual serial numbers. The placeholders are shown in the format of HOSTNAME:local-virtual-device-ID. The states are either Available or Allocated. A placeholder in the Available state indicates that the virtual device is not running and can be allocated for the test.

Select Virtual Devices

Figure 1. Selecting virtual devices

Add device actions

If you select at least one local virtual device, the associated device action should be added to the list automatically. The action consists of the required TradeFed parameters and test resources to create virtual devices.

Virtual Device Actions

Figure 2. Device actions for virtual devices

Set test resources

Cuttlefish virtual devices require three test resources, the virtual machine tools, the images, and Acloud. In a typical Cuttlefish build (for example, aosp_cf_x86_64_phone on ci.android.com ), the virtual machine tools are packed in cvd-host_package.tar.gz, and the images are in aosp_cf_x86_64_phone-img-*.zip. The Acloud binary is built in ATS and is compatible with all versions of Cuttlefish. The default download URL of the Acloud binary only needs to be changed for debugging purposes.

Virtual Device Test Resources

Figure 3. Test resources for virtual devices

View test runs

The device logs, including kernel.log, host_log.txt, and launcher.log are collected in the output file folder. Click View Output Files to see them.

Test Run Results

Figure 4. Test run results