Write a shell test in Trade Federation

This page describes how to write a shell test. If a test can be done with a shell script, you can run it with ExecutableHostTest. ExecutableHostTest supports test filtering and test sharding.

Write a shell test

Your main shell script runs on the host. Other scripts or binaries to run on the device and the data files required must be pushed to the device first. This can be done as part of the main script or using PushFilePreparer.

If the test has device binary modules that should be installed alongside the test, specify them with data_device_bins property.

sh_test {
    name: "module-name",
    data_device_bins: ["target-name"],

Shell test ziptool-tests is such an example.

The test result for each test is based on the exit status of your main script. A test can timeout if per-binary-timeout has been specified.

Configure a shell test

In Tradefed XML configuration, shell tests are run through the ExecutableHostTest runner.

<test class="com.android.tradefed.testtype.binary.ExecutableHostTest" >
    <option name="binary" value="your-test-script.sh" />
    <option name="relative-path-execution" value="true" />
    <option name="per-binary-timeout" value="15m" />

Set the main script for the test as the value of the binary option. Check out other ExecutableHostTest options.

If the script requires root privilege, add RootTargetPreparer to the configuration.