Not able to automate CTS running on multiple devices using Python

137 views Asked by At

I am trying to automate CTS automatically with Python. I can use that on single device but can't run on multiple devices with same python code(subprocess.Popen) .

['android-cts/tools/cts-tradefed', 'run', 'cts', '--shards', '1'] works

['android-cts/tools/cts-tradefed', 'run', 'cts', '--shards', '2']doesn't work

My question is how can I start shards CTS testing with python to automatically test CTS on multiple devices?

1

There are 1 answers

0
deeshank On

When running Android Compatibility Test Suite (CTS) with multiple shards to distribute the testing across multiple devices, you need to manage and coordinate the test execution for each shard separately. This typically involves starting a separate cts-tradefed process for each shard and specifying the shard number for each process.

import subprocess

devices = ["device_serial_1", "device_serial_2"]  # Add device identifiers
shards = len(devices)  # Set the number of shards to match the number of devices

for i, device in enumerate(devices):
    cmd = [
        "android-cts/tools/cts-tradefed",
        "run",
        "cts",
        "--shards",
        f"{shards}",
        "--shard-index",
        f"{i}",  # Shard index corresponds to the device index
        "--serial",
        device,  # Specify the device serial number or identifier
    ]

    subprocess.Popen(cmd)  # Start the cts-tradefed process for each device