自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
測試指令排程器
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在 Tradefed 中,每項測試要求都會透過 指令排程器執行。因此,指令排程器是執行測試所需的束縛程式碼中的重要元件。
生命週期
當測試要求提交至 Tradefed (例如從控制台輸入) 時,會先經過下列事件,然後才執行:
- 剖析測試要求:測試要求通常由 XML Tradefed 設定參照和後續選項組成。例如:
> run host --class com.android.tradefed.build.BuildInfoTest
- 向裝置管理員要求與測試要求相符的裝置 - 裝置管理員會分配與測試要求相符的裝置。舉例來說,如果要求 Pixel 裝置,裝置管理工具就會尋找可用的 Pixel 裝置。
- 測試要求 + 裝置以叫用方式啟動 - 測試開始。
- 裝置釋出:叫用作業完成後,系統會釋出已指派的裝置,並可為其他測試指派裝置。
Tradefed 叫用
Tradefed 中的叫用作業是指目前執行測試指令時。叫用中包含的裝置會標示為 allocated
,其他測試無法使用這些裝置執行。
TF 會按照以下順序執行下列步驟:
- 下載建構和測試構件
- 目標準備
- 測試執行
- 目標清理
- 結果報表
架構一節會詳細說明每個步驟。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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 (世界標準時間)。"],[],[],null,["# Test Command Scheduler\n\nIn Tradefed, every single test request goes through the\n[Command Scheduler](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/command/CommandScheduler.java)\nto be run. So the Command Scheduler is a key component of the harness needed to\nrun tests.\n\nLifecycle\n---------\n\nWhen a test request is presented to Tradefed (for example, input from the\nconsole), it will go through the following events before being run:\n\n1. *Test request is parsed* - A test request is usually composed of an XML Tradefed configuration reference followed by options. For example: `\u003e run host --class com.android.tradefed.build.BuildInfoTest`\n2. *Device Manager is requested for device(s) matching the test request* - Device Manager [allocates a device](/docs/core/tests/tradefed/architecture/device-manager/device-allocation) that matches the test requests. For example, if a Pixel device is requested then Device Manager will look for an available Pixel device.\n3. *Test request + device(s) starts as an invocation* - Testing is starting.\n4. *Device release* - Once the invocation is finished, the device allocated will be released and can be allocated for other tests.\n\nTradefed invocation\n-------------------\n\nAn invocation in Tradefed refers to when a test command is currently executing.\nDevices included in the invocation are marked as `allocated` and cannot be used\nby other tests to run.\n\nTF will execute the following steps in this order:\n\n1. [Build and test artifacts download](/docs/core/tests/tradefed/architecture/build-provider)\n2. [Target preparation](/docs/core/tests/tradefed/architecture/target-preparer)\n3. [Test execution](/docs/core/tests/tradefed/architecture/advanced/test-runner)\n4. [Target clean up](/docs/core/tests/tradefed/architecture/target-preparer)\n5. [Result reporting](/docs/core/tests/tradefed/architecture/result-reporter)\n\nEach step is described in more detail within the\n[Architecture section](/docs/core/tests/tradefed/architecture)."]]