查看 IDT 测试结果和日志 - FreeRTOS
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

查看 IDT 测试结果和日志

本节介绍 IDT 生成控制台日志和测试报告的格式。

控制台消息格式

Amazon IoT Device Tester 在启动测试套件时使用标准格式将消息输出到控制台。以下摘录显示了一个由 IDT 生成的控制台消息示例。

[INFO] [2000-01-02 03:04:05]: Using suite: MyTestSuite_1.0.0 executionId=9a52f362-1227-11eb-86c9-8c8590419f30

大多数控制台消息都包含以下字段:

time

所记录事件的完整 ISO 8601 时间戳。

level

所记录事件的消息级别。通常,记录的消息级别为 infowarnerror。如果遇到导致其提前退出的预期事件,IDT 会发出 fatalpanic 消息。

msg

记录的消息。

executionId

当前 IDT 流程的唯一 ID 字符串。此 ID 用于区分各个 IDT 运行。

测试套件生成的控制台消息提供了有关被测设备以及 IDT 运行的测试套件、测试组和测试用例的更多信息。以下摘录显示了从测试套件生成的控制台消息的示例。

[INFO] [2000-01-02 03:04:05]: Hello world! suiteId=MyTestSuitegroupId=myTestGroup testCaseId=myTestCase deviceId=my-deviceexecutionId=9a52f362-1227-11eb-86c9-8c8590419f30

控制台消息中特定于测试套件的部分包含以下字段:

suiteId

当前正在运行的测试套件的名称。

groupId

当前正在运行的测试组的 ID。

testCaseId

当前正在运行的测试用例的 ID。

deviceId

当前测试用例正在使用的被测设备的 ID。

测试摘要包含有关测试套件、每个已运行组的测试结果以及生成的日志和报告文件位置的信息。以下示例显示了测试摘要消息。

========== Test Summary ========== Execution Time: 5m00s Tests Completed: 4 Tests Passed: 3 Tests Failed: 1 Tests Skipped: 0 ---------------------------------- Test Groups: GroupA: PASSED GroupB: FAILED ---------------------------------- Failed Tests: Group Name: GroupB Test Name: TestB1 Reason: Something bad happened ---------------------------------- Path to Amazon IoT Device Tester Report: /path/to/awsiotdevicetester_report.xml Path to Test Execution Logs: /path/to/logs Path to Aggregated JUnit Report: /path/to/MyTestSuite_Report.xml

Amazon IoT Device Tester 报告架构

awsiotdevicetester_report.xml 是一份包含以下信息的签名报告:

  • IDT 版本。

  • 测试套件版本。

  • 用于对报告进行签名的报告签名和密钥。

  • device.json 文件中指定的设备 SKU 和设备池名称。

  • 经过测试的产品版本和设备功能。

  • 测试结果的摘要汇总。此信息与 suite-name_report.xml 文件中包含的信息相同。

<apnreport> <awsiotdevicetesterversion>idt-version</awsiotdevicetesterversion> <testsuiteversion>test-suite-version</testsuiteversion> <signature>signature</signature> <keyname>keyname</keyname> <session> <testsession>execution-id</testsession> <starttime>start-time</starttime> <endtime>end-time</endtime> </session> <awsproduct> <name>product-name</name> <version>product-version</version> <features> <feature name="<feature-name>" value="supported | not-supported | <feature-value>" type="optional | required"/> </features> </awsproduct> <device> <sku>device-sku</sku> <name>device-name</name> <features> <feature name="<feature-name>" value="<feature-value>"/> </features> <executionMethod>ssh | uart | docker</executionMethod> </device> <devenvironment> <os name="<os-name>"/> </devenvironment> <report> <suite-name-report-contents> </report> </apnreport>

awsiotdevicetester_report.xml 文件包含一个 <awsproduct> 标签,其中包含有关正测试的产品以及在运行测试套件后验证的产品功能的信息。

<awsproduct> 标签中使用的属性

name

所测试的产品的名称。

version

所测试的产品的版本。

features

验证的功能。标记为 required 的功能是测试套件验证设备所必需的。以下代码段演示了此信息在 awsiotdevicetester_report.xml 文件中的显示方式。

<feature name="ssh" value="supported" type="required"></feature>

标记为 optional 的功能不是验证所必需的。以下代码段显示了可选功能。

<feature name="hsi" value="supported" type="optional"></feature> <feature name="mqtt" value="not-supported" type="optional"></feature>

测试套件报告架构

suite-name_Result.xml 报告采用 JUnit XML 格式。您可以将它集成到持续集成和开发平台,例如 JenkinsBamboo 等。报告包含测试结果的摘要汇总。

<testsuites name="<suite-name> results" time="<run-duration>" tests="<number-of-test>" failures="<number-of-tests>" skipped="<number-of-tests>" errors="<number-of-tests>" disabled="0"> <testsuite name="<test-group-id>" package="" tests="<number-of-tests>" failures="<number-of-tests>" skipped="<number-of-tests>" errors="<number-of-tests>" disabled="0"> <!--success--> <testcase classname="<classname>" name="<name>" time="<run-duration>"/> <!--failure--> <testcase classname="<classname>" name="<name>" time="<run-duration>"> <failure type="<failure-type>"> reason </failure> </testcase> <!--skipped--> <testcase classname="<classname>" name="<name>" time="<run-duration>"> <skipped> reason </skipped> </testcase> <!--error--> <testcase classname="<classname>" name="<name>" time="<run-duration>"> <error> reason </error> </testcase> </testsuite> </testsuites>

awsiotdevicetester_report.xmlsuite-name_report.xml 中的报告部分列出了运行的测试以及结果。

第一个 XML 标签 <testsuites> 包含测试执行情况的摘要。例如:

<testsuites name="MyTestSuite results" time="2299" tests="28" failures="0" errors="0" disabled="0">

<testsuites> 标签中使用的属性

name

测试套件的名称。

time

运行测试套件所用的时间(以秒为单位)。

tests

执行的测试数。

failures

已运行但未通过的测试数。

errors

IDT 无法执行的测试数。

disabled

此属性未使用,可以忽略。

如果出现测试失败或错误,则可以通过检查 <testsuites> XML 标签来确定失败的测试。<testsuites> 标签内的 <testsuite> XML 标签显示了测试组的测试结果摘要。例如:

<testsuite name="combination" package="" tests="1" failures="0" time="161" disabled="0" errors="0" skipped="0">

其格式与 <testsuites> 标签类似,但包含一个未使用并可忽略的 skipped 属性。在每个 <testsuite> XML 标签内部,对于一个测试组,所执行的每个测试都有 <testcase> 标签。例如:

<testcase classname="Security Test" name="IP Change Tests" attempts="1"></testcase>

<testcase> 标签中使用的属性

name

测试的名称。

attempts

IDT 执行测试用例的次数。

当测试失败或出现错误时,将会在 <testcase> 标签中添加包含用于故障排除的信息的 <failure><error> 标签。例如:

<testcase classname="mcu.Full_MQTT" name="MQTT_TestCase" attempts="1"> <failure type="Failure">Reason for the test failure</failure> <error>Reason for the test execution error</error> </testcase>