2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
Trade Federation でシェルテストを作成する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページでは、シェルテストの作成方法について説明します。シェル スクリプトで実行できるテストは、ExecutableHostTest
で実行できます。ExecutableHostTest
は、テストのフィルタリングとシャーディングをサポートします。
シェルテストの作成
メインのシェル スクリプトはホストで実行されます。最初に、デバイス上で実行する他のスクリプトまたはバイナリと、必要なデータファイルをデバイスにプッシュする必要があります。これは、メイン スクリプトの中で行うことも、PushFilePreparer
を使用して行うこともできます。
テストと一緒にインストールする必要があるデバイス バイナリ モジュールがテストに含まれている場合は、data_device_bins
プロパティでそれらのモジュールを指定します。
sh_test {
name: "module-name",
...
data_device_bins: ["target-name"],
}
シェルテストの ziptool-tests
はその一例です。
各テストの結果は、メイン スクリプトの終了ステータスに基づいて生成されます。per-binary-timeout
が指定されている場合は、テストがタイムアウトする可能性があります。
シェルテストを構成する
Tradefed XML 構成では、シェルテストは 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
を追加します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-26 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-26 UTC。"],[],[],null,["# Write a shell test in Trade Federation\n\nThis page describes how to write a shell test. If a test can be done with a\nshell script, you can run it with [`ExecutableHostTest`](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/test_framework/com/android/tradefed/testtype/binary/ExecutableHostTest.java). `ExecutableHostTest` supports test filtering and\ntest sharding.\n\nWrite a shell test\n------------------\n\nYour main shell script runs on the host. Other scripts or binaries to run on\nthe device and the data files required must be pushed to the device first.\nThis can be done as part of the main script or using [`PushFilePreparer`](https://cs.android.com/android/platform/superproject/+/android-latest-release:tools/tradefederation/core/test_framework/com/android/tradefed/targetprep/PushFilePreparer.java?q=PushFilePreparer).\n\nIf the test has device binary modules that should be installed alongside the\ntest, specify them with [`data_device_bins`](https://ci.android.com/builds/submitted/6873301/linux/latest/view/sh.html#sh_test.data_device_bins)\nproperty. \n\n sh_test {\n name: \"module-name\",\n ...\n data_device_bins: [\"target-name\"],\n }\n\nShell test [`ziptool-tests`](https://cs.android.com/android/platform/superproject/+/android-latest-release:system/libziparchive/Android.bp?q=ziptool-tests)\nis such an example.\n\nThe test result for each test is based on the exit status of your main script.\nA test can timeout if `per-binary-timeout` has been specified.\n\nConfigure a shell test\n----------------------\n\nIn Tradefed XML configuration, shell tests are run through the\n`ExecutableHostTest` runner. \n\n \u003ctest class=\"com.android.tradefed.testtype.binary.ExecutableHostTest\" \u003e\n \u003coption name=\"binary\" value=\"your-test-script.sh\" /\u003e\n \u003coption name=\"relative-path-execution\" value=\"true\" /\u003e\n \u003coption name=\"per-binary-timeout\" value=\"15m\" /\u003e\n \u003c/test\u003e\n\nSet the main script for the test as the value of the `binary` option. Check out\nother `ExecutableHostTest` options.\n\nIf the script requires root privilege, add [`RootTargetPreparer`](https://cs.android.com/android/platform/superproject/+/android-latest-release:tools/tradefederation/core/test_framework/com/android/tradefed/targetprep/RootTargetPreparer.java) to the configuration."]]