自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
测试命令调度程序
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在 Tradefed 中,每个测试请求都要经过命令调度程序才能运行。因此,命令调度程序是运行测试所需的自动化测试框架的关键组件。
生命周期
将测试请求提交给 Tradefed 时(例如,从控制台输入),该请求会在运行之前依次执行以下事件:
- 解析测试请求 - 测试请求通常由 XML Tradefed 配置引用和后跟的选项组成。
例如:
> run host --class com.android.tradefed.build.BuildInfoTest
- 请求设备管理器查找与测试请求匹配的设备 - 设备管理器将分配与测试请求匹配的设备。例如,如果请求 Pixel 设备,则设备管理器将查找可用的 Pixel 设备。
- 测试请求 + 设备以调用的形式启动 - 开始测试。
- 释放设备 - 调用完成后,分配的设备将被释放,并可分配给其他测试。
Tradefed 调用
Tradefed 中的调用是指当前正在执行测试命令。
调用中包含的设备标记为 allocated
,其他测试无法使用这些设备来运行。
TF 将按此顺序执行以下步骤:
- 构建和测试工件下载
- 目标准备
- 测试执行
- 目标清理
- 结果报告
在“架构”部分中,更详细地介绍了各个步骤。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],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)."]]