自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
Cuttlefish:运行稳定版 CTS
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了如何运行兼容性测试套件 (CTS),以便根据 AOSP 源代码评估虚拟设备。
构建 Cuttlefish
在运行 CTS 之前,请先构建要使用 CTS 测试的虚拟设备。对于 AOSP Cuttlefish,请执行以下操作:
source build/envsetup.sh
lunch aosp_cf_x86_64_phone-userdebug
make -j
构建 CTS
CTS 是独立于设备工件构建的。如需构建 CTS,请按照以下说明操作。
从构建 Cuttlefish 所在树的根目录中,运行以下命令:
source build/envsetup.sh
m -j cts WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=false TARGET_PRODUCT=aosp_x86_64
启动多租户 Cuttlefish 实例
从构建 Cuttlefish 所在树的根目录中,运行以下命令:
source build/envsetup.sh
lunch aosp_cf_x86_64_phone-userdebug
launch_cvd --num_instances=8 --daemon
启动实例时,请验证每台设备是否都可以访问 adb
。
adb devices
输出应类似于以下示例输出:
List of devices attached
127.0.0.1:6520 device
127.0.0.1:6521 device
127.0.0.1:6522 device
127.0.0.1:6523 device
127.0.0.1:6524 device
127.0.0.1:6525 device
127.0.0.1:6526 device
127.0.0.1:6527 device
在 Cuttlefish 实例中启用 Wi-Fi
如果未启用 Wi-Fi,部分 CTS 测试会失败。如需在本地托管的所有 Cuttlefish 设备上启用 Wi-Fi,请按照以下说明操作。
从构建 Cuttlefish 所在树的根目录中,运行以下命令:
for SERIAL in $(adb devices | grep -E '127.+device$' | cut -f1); do
adb -s ${SERIAL} install -r -g tools/tradefederation/core/res/apks/wifiutil/WifiUtil.apk
adb -s ${SERIAL} shell su root svc wifi enable
adb -s ${SERIAL} shell am instrument -e method "connectToNetwork" -e scan_ssid "false" -e ssid "VirtWifi" -w com.android.tradefed.utils.wifi/.WifiUtil
done
运行 CTS 稳定版子集
并非在 Cuttlefish 上进行的所有 CTS 都会通过,因为某些测试更多是针对实体设备量身定制的。如需使用 cts-virtual-device-stable
测试计划(用于跟踪在虚拟平台上运行稳定的最新功能)运行 CTS,请按照以下说明操作。
从构建 Cuttlefish 所在树的根目录中,运行以下命令:
source build/envsetup.sh
lunch aosp_cf_x86_64_phone-userdebug
cts-tradefed run cts-virtual-device-stable --no-enable-parameterized-modules --max-testcase-run-count 2 --retry-strategy RETRY_ANY_FAILURE --reboot-at-last-retry --shard-count 8
预计运行该测试需要 20 到 25 分钟时间,并显示类似如下的总结:
=============== Summary ===============
Total Run time: 22m 8s
184/184 modules completed
Total Tests : 92483
PASSED : 92363
FAILED : 0
IGNORED : 71
ASSUMPTION_FAILURE: 49
Shard 0 used: [127.0.0.1:6522]
Shard 1 used: [127.0.0.1:6525]
Shard 2 used: [127.0.0.1:6524]
Shard 3 used: [127.0.0.1:6521]
Shard 4 used: [127.0.0.1:6520]
Shard 5 used: [127.0.0.1:6527]
Shard 6 used: [127.0.0.1:6526]
Shard 7 used: [127.0.0.1:6523]
============== End of Results ==============
清理
测试完成后,请停止虚拟设备。
从构建 Cuttlefish 所在树的根目录中,运行以下命令:
source build/envsetup.sh
lunch aosp_cf_x86_64_phone-userdebug
stop_cvd
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Cuttlefish: Run stable CTS\n\nThis page describes how to run the [Compatibility Test Suite\n(CTS)](/docs/compatibility/cts) to evaluate your virtual device based on the AOSP\nsource code.\n\nBuild Cuttlefish\n----------------\n\nBefore running CTS, build the virtual device that you want to test with CTS. For\nAOSP Cuttlefish, do the following: \n\n source build/envsetup.sh\n lunch \u003cvar translate=\"no\"\u003eaosp_cf_x86_64_only_phone-userdebug\u003c/var\u003e\n make -j\n\nBuild CTS\n---------\n\nCTS is built separately from your device artifacts. To build CTS, follow these\ninstructions.\n\nFrom the root of the same tree where Cuttlefish was built, run the following\ncommands: \n\n source build/envsetup.sh\n m -j cts WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=false TARGET_PRODUCT=aosp_x86_64\n\nLaunch multi-tenant Cuttlefish instances\n----------------------------------------\n\n| **Note:** For detailed instructions on launching multiple Cuttlefish devices, see [Cuttlefish Multi-Tenancy and Powerwashing](/docs/devices/cuttlefish/multi-tenancy).\n\nFrom the root of the same tree where Cuttlefish was built, run the following\ncommands: \n\n source build/envsetup.sh\n lunch \u003cvar translate=\"no\"\u003eaosp_cf_x86_64_only_phone-userdebug\u003c/var\u003e\n launch_cvd --num_instances=\u003cvar translate=\"no\"\u003e8\u003c/var\u003e --daemon\n\nWhen the instances start, verify each of the devices is `adb` accessible. \n\n adb devices\n\nThe output should look similar to the example output below: \n\n List of devices attached\n 127.0.0.1:6520 device\n 127.0.0.1:6521 device\n 127.0.0.1:6522 device\n 127.0.0.1:6523 device\n 127.0.0.1:6524 device\n 127.0.0.1:6525 device\n 127.0.0.1:6526 device\n 127.0.0.1:6527 device\n\nEnable Wi-Fi on Cuttlefish instances\n------------------------------------\n\nSome of the CTS tests fail if Wi-Fi isn't enabled. To enable Wi-Fi on all\nlocally hosted Cuttlefish devices, follow these instructions.\n\nFrom the root of the same tree where Cuttlefish was built, run the following\ncommands: \n\n for SERIAL in $(adb devices | grep -E '127.+device$' | cut -f1); do\n adb -s ${SERIAL} install -r -g tools/tradefederation/core/res/apks/wifiutil/WifiUtil.apk\n adb -s ${SERIAL} shell su root svc wifi enable\n adb -s ${SERIAL} shell am instrument -e method \"connectToNetwork\" -e scan_ssid \"false\" -e ssid \"VirtWifi\" -w com.android.tradefed.utils.wifi/.WifiUtil\n done\n\nRun CTS stable subset\n---------------------\n\nNot all of the CTS pass on Cuttlefish, as some of the tests are more\ntailored towards physical devices. To run the CTS with the\n`cts-virtual-device-stable` test plan that tracks the latest of what is stable\non the virtual platform, follow these instructions.\n\nFrom the root of the same tree where Cuttlefish was built, run the following\ncommands: \n\n source build/envsetup.sh\n lunch aosp_cf_x86_64_only_phone-userdebug\n cts-tradefed run cts-virtual-device-stable --no-enable-parameterized-modules --max-testcase-run-count 2 --retry-strategy RETRY_ANY_FAILURE --reboot-at-last-retry --shard-count 8\n\nExpect the test to run for 20 to 25 minutes, and print out a summary similar to\nfollowing: \n\n =============== Summary ===============\n Total Run time: 22m 8s\n 184/184 modules completed\n Total Tests : 92483\n PASSED : 92363\n FAILED : 0\n IGNORED : 71\n ASSUMPTION_FAILURE: 49\n Shard 0 used: [127.0.0.1:6522]\n Shard 1 used: [127.0.0.1:6525]\n Shard 2 used: [127.0.0.1:6524]\n Shard 3 used: [127.0.0.1:6521]\n Shard 4 used: [127.0.0.1:6520]\n Shard 5 used: [127.0.0.1:6527]\n Shard 6 used: [127.0.0.1:6526]\n Shard 7 used: [127.0.0.1:6523]\n ============== End of Results ==============\n\nCleanup\n-------\n\nWhen the tests are done, stop the virtual devices.\n\nFrom the root of the same tree where Cuttlefish was built, run the following\ncommands: \n\n source build/envsetup.sh\n lunch aosp_cf_x86_64_only_phone-userdebug\n stop_cvd"]]