ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
เขียนการทดสอบเชลล์ใน Trade Federation
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หน้านี้จะอธิบายวิธีเขียนการทดสอบเชลล์ หากการทดสอบทําได้ด้วยสคริปต์เชลล์ คุณจะเรียกใช้การทดสอบได้ด้วย ExecutableHostTest
ExecutableHostTest
รองรับการกรองการทดสอบและการแยกกลุ่มการทดสอบ
เขียนการทดสอบเชลล์
สคริปต์เชลล์หลักจะทำงานบนโฮสต์ สคริปต์หรือไบนารีอื่นๆ ที่จะทำงานในอุปกรณ์และไฟล์ข้อมูลที่จำเป็นจะต้องพุชไปยังอุปกรณ์ก่อน
ซึ่งทำได้โดยเป็นส่วนหนึ่งของสคริปต์หลักหรือใช้ PushFilePreparer
หากการทดสอบมีโมดูลไบนารีของอุปกรณ์ที่ควรติดตั้งควบคู่ไปกับการทดสอบ ให้ระบุด้วยพร็อพเพอร์ตี้ data_device_bins
sh_test {
name: "module-name",
...
data_device_bins: ["target-name"],
}
การทดสอบเชลล์ ziptool-tests
เป็นตัวอย่างหนึ่ง
ผลการทดสอบสําหรับการทดสอบแต่ละรายการจะอิงตามสถานะการออกของสคริปต์หลัก
การทดสอบอาจหมดเวลาหากมีการระบุ per-binary-timeout
กำหนดค่าการทดสอบเชลล์
ในการกำหนดค่า XML ของ Tradefed การทดสอบเชลล์จะทํางานผ่านโปรแกรมรันไทม์ 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
อื่นๆ
หากสคริปต์ต้องใช้สิทธิ์รูท ให้เพิ่ม RootTargetPreparer
ลงในการกำหนดค่า
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 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-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."]]