本頁描述如何寫 shell 測試。如果可以使用 shell 腳本完成測試,則可以使用ExecutableHostTest
來執行它。 ExecutableHostTest
支援測試過濾和測試分片。
編寫 shell 測試
您的主 shell 腳本在主機上執行。要在裝置上執行的其他腳本或二進位檔案以及所需的資料檔案必須先推送到裝置。這可以作為主腳本的一部分或使用PushFilePreparer
來完成。
如果測試具有應與測試一起安裝的裝置二進位模組,請使用data_device_bins
屬性指定它們。
sh_test {
name: "module-name",
...
data_device_bins: ["target-name"],
}
Shell 測試ziptool-tests
就是這樣一個例子。
每個測試的測試結果是基於主腳本的退出狀態。如果指定了per-binary-timeout
測試可能會逾時。
配置 shell 測試
在 Tradefed XML 配置中,shell 測試透過ExecutableHostTest
運行程式運行。
<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" />
</test>
將測試的主腳本設定為binary
期權的值。查看其他ExecutableHostTest
選項。
如果腳本需要 root 權限,請將RootTargetPreparer
新增至設定。