【问题结论】
[Common]SN配置项的问题,只可以‘数字与大小写字母’ 将配置SN改为字母数字组合,测试全部pass 【问题描述】 CTS三条失败项run cts -m CtsTelephonyTestCases -t android.telephony.cts.TelephonyManagerTest#testGetDeviceIdrun cts -m CtsTelephonyTestCases -t android.telephony.cts.TelephonyManagerTest#testGetDeviceIdForSlotrun cts -m CtsUsbTests -t com.android.cts.usb.TestUsbTest#testUsbSerialReadOnDeviceMatches
问题日志:
06-10 15:29:58 I/ConsoleReporter: [1/1 armeabi-v7a CtsUsbTests xxx_xxx_111_00000111] com.android.cts.usb.TestUsbTest#testUsbSerialReadOnDeviceMatches fail: junit.framework.ComparisonFailure: usb serial != adb serial expected:<[]> but was:<[xxx_xxx_111_00000111]> at junit.framework.Assert.assertEquals(Assert.java:100) at junit.framework.TestCase.assertEquals(TestCase.java:261) at com.android.cts.usb.TestUsbTest.testUsbSerialReadOnDeviceMatches(TestUsbTest.java:162)
【问题分析】
- 源码追溯
cts / master / . / hostsidetests / usb / src / com / android / cts / usb / TestUsbTest.java/** * Check if adb serial number, USB serial number, ro.serialno, and android.os.Build.SERIAL * all matches and meets the format requirement [a-zA-Z0-9]{6,20} */public void testInstantAppsCannotReadSerial() throws Exception {...... CommandResult result = RunUtil.getDefault().runTimedCmd(5000, "lsusb", "-v");//这一句是在linux测试机执行shell命令"lsusb -v"...... String lsusbOutput = result.getStdout(); Pattern pattern = Pattern.compile("^\\s+iSerial\\s+\\d+\\s+([a-zA-Z0-9]{6,20})",Pattern.MULTILINE);//在上句命令的返回值中匹配,看serilnumber是不是合法即“只能由字母数字组成,且6≤lenth≤20” Matcher matcher = pattern.matcher(lsusbOutput); String usbSerial = ""; while (matcher.find()) { String currentSerial = matcher.group(1).toLowerCase(); if (adbSerial.compareTo(currentSerial) == 0) { usbSerial = currentSerial; break; } } assertEquals("usb serial != adb serial" , usbSerial, adbSerial);//由于我们的serialno是带下划线了,所以匹配为空,就抛异常了
- 实验 在理清源码测试逻辑后,我们将SN配置项修改为“无下划线”的字母数字组合 实验结果:三条均pass