Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release
, bukan aosp-main
, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Menulis pengujian shell di Trade Federation
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara menulis pengujian shell. Jika pengujian dapat dilakukan dengan
skrip shell, Anda dapat menjalankannya dengan ExecutableHostTest
. ExecutableHostTest
mendukung pemfilteran pengujian dan
sharding pengujian.
Menulis pengujian shell
Skrip shell utama Anda berjalan di host. Skrip atau biner lain yang akan dijalankan di
perangkat dan file data yang diperlukan harus di-push ke perangkat terlebih dahulu.
Hal ini dapat dilakukan sebagai bagian dari skrip utama atau menggunakan PushFilePreparer
.
Jika pengujian memiliki modul biner perangkat yang harus diinstal bersama
pengujian, tentukan modul tersebut dengan properti
data_device_bins
.
sh_test {
name: "module-name",
...
data_device_bins: ["target-name"],
}
Pengujian shell ziptool-tests
adalah contohnya.
Hasil pengujian untuk setiap pengujian didasarkan pada status keluar skrip utama Anda.
Pengujian dapat habis waktunya jika per-binary-timeout
telah ditentukan.
Mengonfigurasi pengujian shell
Dalam konfigurasi XML Tradefed, pengujian shell dijalankan melalui
runner 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>
Tetapkan skrip utama untuk pengujian sebagai nilai opsi binary
. Lihat
opsi ExecutableHostTest
lainnya.
Jika skrip memerlukan hak istimewa root, tambahkan RootTargetPreparer
ke konfigurasi.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 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."]]