自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Cuttlefish:執行穩定版 CTS
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁面說明如何執行相容性測試套件 (CTS),根據 AOSP 原始碼評估虛擬裝置。
建構 Cuttlefish
執行 CTS 之前,請先建構要透過 CTS 測試的虛擬裝置。如果是 AOSP Cuttlefish,請執行下列操作:
source build/envsetup.sh
lunch aosp_cf_x86_64_only_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_only_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 穩定子集
並非所有 CTS 都會在 Cuttlefish 上通過,因為某些測試更適合實體裝置。如要使用 cts-virtual-device-stable
測試計畫執行 CTS,追蹤虛擬平台上最新的穩定版本,請按照下列操作說明操作。
請在 Cuttlefish 建構的相同樹狀結構根層級執行下列指令:
source build/envsetup.sh
lunch aosp_cf_x86_64_only_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_only_phone-userdebug
stop_cvd
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# 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"]]