自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
自动收集有关失败的日志
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
调试测试时,始终需要一组日志,以便大致了解失败和被测设备的情况。日志来源包括:Logcat、Tradefed 主机日志、屏幕截图等。
为了让这些日志通用并让所有测试编写人员都可以轻松获取,Tradefed 内置了一种机制来帮助收集。
配置
要自动收集有关失败的部分日志,您可以将以下选项添加到 Tradefed 命令行中:
--auto-collect LOGCAT_ON_FAILURE
or
--auto-collect SCREENSHOT_ON_FAILURE
要查看可能值的完整列表,请参阅 AutoLogCollector
为方便起见,logcat 和屏幕截图各有一个直观的标记:
--logcat-on-failure
and
--screenshot-on-failure
有关套件模块的说明 (AndroidTest.xml)
模块不能在 AndroidTest.xml
中直接指定此选项,但它们可以改为使用模块控制器。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Automated log on failure collection\n\nWhen debugging tests, a set of logs is always needed to get a basic picture of\nthe failure and the device under test.\nSources include: Logcat, Tradefed host log, screenshot, etc.\n\nIn order to make it generic and painless for any test writer to get those logs,\nTradefed has a built-in mechanism to help collecting them.\n\nConfiguration\n-------------\n\nTo automatically collect some logs on failure, you can add the following option\nto your Tradefed command line: \n\n --auto-collect LOGCAT_ON_FAILURE\n or\n --auto-collect SCREENSHOT_ON_FAILURE\n\nTo see the full list of possible values, checkout\n[AutoLogCollector](https://android.googlesource.com/platform/tools/tradefederation/+/android16-release/src/com/android/tradefed/device/metric/AutoLogCollector.java)\n\nFor convenience, logcat and screenshot each have a direct flag: \n\n --logcat-on-failure\n and\n --screenshot-on-failure\n\nNote on suite modules (AndroidTest.xml)\n---------------------------------------\n\nModules cannot direcly specify this option in the `AndroidTest.xml`, but they\ncan use a [module controller](/docs/core/tests/tradefed/testing/through-suite/module-controller)\ninstead."]]