diff options
author | Oli Lan <olilan@google.com> | 2020-01-24 10:24:28 +0000 |
---|---|---|
committer | Oli Lan <olilan@google.com> | 2020-01-30 11:25:15 +0000 |
commit | b9525aa0f78405dcaba8dbf0338055e5a722b34f (patch) | |
tree | 9acb3c05013a406b613110e279b94a03f38dab56 /tests | |
parent | 3ce294d8bf77dc4c626ae5c67261984d837c1de1 (diff) |
Add test for DE (user) snapshot and restore.
This adds a test for rolling back device encrypted (user) apex data,
similar to the tests previously added for DE_sys and CE data.
Bug: 141148175
Test: atest StagedRollbackTest#testRollbackApexDataDirectories_DeUser
Change-Id: I632957449e4aa4f93df2e8bf0ae541937472d9fe
Diffstat (limited to 'tests')
-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); } |