diff options
| author | 2020-02-04 10:22:29 +0000 | |
|---|---|---|
| committer | 2020-02-04 10:22:29 +0000 | |
| commit | e5981fae41bd88ac4f350820e3afc24c24e2c44d (patch) | |
| tree | 213e682332e9d8df2409c84ebfe7f1b5fc6228cd | |
| parent | b3584b2cdc0ba408b1e5a6661d46e765c2b2f973 (diff) | |
| parent | b9525aa0f78405dcaba8dbf0338055e5a722b34f (diff) | |
Merge "Add test for DE (user) snapshot and restore."
| -rw-r--r-- | tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java b/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java index ce2f7c50e581..82a524be5c1e 100644 --- a/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +++ b/tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java @@ -329,6 +329,46 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { } /** + * Tests that data in DE (user) apex data directory is restored when apex is rolled back. + */ + @Test + public void testRollbackApexDataDirectories_DeUser() throws Exception { + pushTestApex(); + + // Push files to apex data directory + String oldFilePath1 = apexDataDirDeUser( + APK_IN_APEX_TESTAPEX_NAME, 0) + "/" + TEST_FILENAME_1; + String oldFilePath2 = + apexDataDirDeUser(APK_IN_APEX_TESTAPEX_NAME, 0) + TEST_SUBDIR + TEST_FILENAME_2; + assertTrue(getDevice().pushString(TEST_STRING_1, oldFilePath1)); + assertTrue(getDevice().pushString(TEST_STRING_2, oldFilePath2)); + + // Install new version of the APEX with rollback enabled + runPhase("testRollbackApexDataDirectories_Phase1"); + getDevice().reboot(); + + // Replace files in data directory + getDevice().deleteFile(oldFilePath1); + getDevice().deleteFile(oldFilePath2); + String newFilePath3 = + apexDataDirDeUser(APK_IN_APEX_TESTAPEX_NAME, 0) + "/" + TEST_FILENAME_3; + String newFilePath4 = + apexDataDirDeUser(APK_IN_APEX_TESTAPEX_NAME, 0) + TEST_SUBDIR + TEST_FILENAME_4; + assertTrue(getDevice().pushString(TEST_STRING_3, newFilePath3)); + assertTrue(getDevice().pushString(TEST_STRING_4, newFilePath4)); + + // Roll back the APEX + runPhase("testRollbackApexDataDirectories_Phase2"); + getDevice().reboot(); + + // Verify that old files have been restored and new files are gone + assertEquals(TEST_STRING_1, getDevice().pullFileContents(oldFilePath1)); + assertEquals(TEST_STRING_2, getDevice().pullFileContents(oldFilePath2)); + assertNull(getDevice().pullFile(newFilePath3)); + assertNull(getDevice().pullFile(newFilePath4)); + } + + /** * Tests that data in CE apex data directory is restored when apex is rolled back. */ @Test @@ -382,6 +422,10 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { return String.format("/data/misc/apexdata/%s", apexName); } + private static String apexDataDirDeUser(String apexName, int userId) { + return String.format("/data/misc_de/%d/apexdata/%s", userId, apexName); + } + private static String apexDataDirCe(String apexName, int userId) { return String.format("/data/misc_ce/%d/apexdata/%s", userId, apexName); } |