【问题标题】:Android 4.3_r2 CTS com.android.cts.aadb.TestDeviceFuncTest#testSyncFiles_normal FAILAndroid 4.3_r2 CTS com.android.cts.aadb.TestDeviceFuncTest#testSyncFiles_normal FAIL
【发布时间】:2014-04-11 08:22:26
【问题描述】:

com.android.cts.aadb.TestDeviceFuncTest#testSyncFiles_normal 失败

junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:48)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertTrue(Assert.java:27)
at com.android.cts.aadb.TestDeviceFuncTest.doTestSyncFiles(TestDeviceFuncTest.java:290)
at com.android.cts.aadb.TestDeviceFuncTest.testSyncFiles_normal(TestDeviceFuncTest.java:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

源代码:

[http://androidxref.com/4.3_r2.1/xref/cts/hostsidetests/aadb/src/com/android/cts/aadb/TestDeviceFuncTest.java][1]

根据我的调试,虽然 syncFiles 的返回值为 true,但 tempFile 的内容并未同步到设备。

http://source.android.com/reference/com/android/tradefed/device/ITestDevice.html#syncFiles(java.io.File, java.lang.String)

任何机构可以给我一些建议? 非常感谢。

【问题讨论】:

    标签: cts


    【解决方案1】:

    是的,这是带有 CTS 4.3 r2、r3 和 4.4 的 active, unresolved defect。这是一个不稳定的测试,它使用10-minute timestamp modification 来触发预期的文件同步(见下文)。如果电话和主机时区设置不同,这将失败。你应该可以通过setting your phone to match your host's GMT time zone绕过。

    /**
     * Test syncing a single file using {@link TestDevice#syncFiles(File, String)}.
     */
    public void doTestSyncFiles(String externalStorePath) throws Exception {
        String expectedDeviceFilePath = null;
    
        // create temp dir with one temp file
        File tmpDir = FileUtil.createTempDir("tmp");
        try {
            File tmpFile = createTempTestFile(tmpDir);
            // set last modified to 10 minutes ago
            tmpFile.setLastModified(System.currentTimeMillis() - 10*60*1000);
            assertNotNull(externalStorePath);
            expectedDeviceFilePath = String.format("%s/%s/%s", externalStorePath,
                    tmpDir.getName(), tmpFile.getName());
    
            assertTrue(mTestDevice.syncFiles(tmpDir, externalStorePath));
            assertTrue(mTestDevice.doesFileExist(expectedDeviceFilePath));
    
            // get 'ls -l' attributes of file which includes timestamp
            String origTmpFileStamp = mTestDevice.executeShellCommand(String.format("ls -l %s",
                    expectedDeviceFilePath));
            // now create another file and verify that is synced
            File tmpFile2 = createTempTestFile(tmpDir);
            tmpFile2.setLastModified(System.currentTimeMillis() - 10*60*1000);
            assertTrue(mTestDevice.syncFiles(tmpDir, externalStorePath));
            String expectedDeviceFilePath2 = String.format("%s/%s/%s", externalStorePath,
                    tmpDir.getName(), tmpFile2.getName());
            assertTrue(mTestDevice.doesFileExist(expectedDeviceFilePath2));
    
            // verify 1st file timestamp did not change
            String unchangedTmpFileStamp = mTestDevice.executeShellCommand(String.format("ls -l %s",
                    expectedDeviceFilePath));
            assertEquals(origTmpFileStamp, unchangedTmpFileStamp);
    
            // now modify 1st file and verify it does change remotely
            String testString = "blah";
            FileOutputStream stream = new FileOutputStream(tmpFile);
            stream.write(testString.getBytes());
            stream.close();
    
            assertTrue(mTestDevice.syncFiles(tmpDir, externalStorePath));
            String tmpFileContents = mTestDevice.executeShellCommand(String.format("cat %s",
                    expectedDeviceFilePath));
            assertTrue(tmpFileContents.contains(testString));
        } finally {
            if (expectedDeviceFilePath != null && externalStorePath != null) {
                // note that expectedDeviceFilePath has externalStorePath prepended at definition
                mTestDevice.executeShellCommand(String.format("rm -r %s", expectedDeviceFilePath));
            }
            FileUtil.recursiveDelete(tmpDir);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-21
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      相关资源
      最近更新 更多