我正在尝试通过以下命令执行 android CTS:
./cts-tradefed run cts --shards ${no_of_devices}
当我从终端执行一个普通的 shell 命令时,它会检测所有连接的设备并使用所有连接的设备并行执行测试套件来执行测试。当我尝试从 Java 代码(本地)或 CI 服务器调用这个 shell 命令时;它检测所有设备,但在 (no_of_devices -1) 上执行测试。被忽略的设备始终是列表中的第一个设备。确认设备本身没有问题,因为如果同一设备不是设备列表中的第一个,则该设备将用于执行测试。
我的 shell 脚本如下所示:
!#/bin/bash
./cts-tradefed run cts --shards 2 #say if I have two devices connected
我用来执行 shell 脚本的 java 代码是这样的:
public class Main {
public static void main(String[] args) {
ProcessBuilder pb = new ProcessBuilder("temp/run-cts-with-sharding.sh");
try {
Process p = pb.start();
Thread.sleep(2000);
BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch(Exception e) {
System.out.println("Exception on pb.start(): " + e);
}
}
}