Merge "Test apexd behaves correctly when not in fs-checkpoint mode" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b713ec62bb
@@ -195,6 +195,47 @@ public class StagedInstallInternalTest {
|
||||
assertSessionFailedWithMessage(sessionId, "has unexpected SHA512 hash");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActiveApexIsRevertedOnCheckpointRollback_Prepare() throws Exception {
|
||||
int sessionId = Install.single(TestApp.Apex2).setStaged().commit();
|
||||
assertSessionReady(sessionId);
|
||||
storeSessionId(sessionId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActiveApexIsRevertedOnCheckpointRollback_Commit() throws Exception {
|
||||
// Verify apex installed during preparation was successful
|
||||
int sessionId = retrieveLastSessionId();
|
||||
assertSessionApplied(sessionId);
|
||||
assertThat(InstallUtils.getInstalledVersion(SHIM_APEX_PACKAGE_NAME)).isEqualTo(2);
|
||||
// Commit a new staged session
|
||||
sessionId = Install.single(TestApp.Apex3).setStaged().commit();
|
||||
assertSessionReady(sessionId);
|
||||
storeSessionId(sessionId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActiveApexIsRevertedOnCheckpointRollback_VerifyPostReboot() throws Exception {
|
||||
int sessionId = retrieveLastSessionId();
|
||||
assertSessionFailed(sessionId);
|
||||
assertThat(InstallUtils.getInstalledVersion(SHIM_APEX_PACKAGE_NAME)).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApexIsNotActivatedIfNotInCheckpointMode_Commit() throws Exception {
|
||||
int sessionId = Install.single(TestApp.Apex2).setStaged().commit();
|
||||
assertSessionReady(sessionId);
|
||||
storeSessionId(sessionId);
|
||||
assertThat(InstallUtils.getInstalledVersion(SHIM_APEX_PACKAGE_NAME)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApexIsNotActivatedIfNotInCheckpointMode_VerifyPostReboot() throws Exception {
|
||||
int sessionId = retrieveLastSessionId();
|
||||
assertSessionFailed(sessionId);
|
||||
assertThat(InstallUtils.getInstalledVersion(SHIM_APEX_PACKAGE_NAME)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRebootlessUpdates() throws Exception {
|
||||
InstallUtils.dropShellPermissionIdentity();
|
||||
@@ -257,6 +298,18 @@ public class StagedInstallInternalTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertSessionApplied(int sessionId) {
|
||||
assertSessionState(sessionId, (session) -> {
|
||||
assertThat(session.isStagedSessionApplied()).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
private static void assertSessionFailed(int sessionId) {
|
||||
assertSessionState(sessionId, (session) -> {
|
||||
assertThat(session.isStagedSessionFailed()).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
private static void assertSessionFailedWithMessage(int sessionId, String msg) {
|
||||
assertSessionState(sessionId, (session) -> {
|
||||
assertThat(session.isStagedSessionFailed()).isTrue();
|
||||
|
||||
@@ -345,6 +345,49 @@ public class StagedInstallInternalTest extends BaseHostJUnit4Test {
|
||||
runPhase("testApexActivationFailureIsCapturedInSession_Verify");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActiveApexIsRevertedOnCheckpointRollback() throws Exception {
|
||||
assumeTrue("Device does not support updating APEX",
|
||||
mHostUtils.isApexUpdateSupported());
|
||||
assumeTrue("Device does not support file-system checkpoint",
|
||||
mHostUtils.isCheckpointSupported());
|
||||
|
||||
// Install something so that /data/apex/active is not empty
|
||||
runPhase("testActiveApexIsRevertedOnCheckpointRollback_Prepare");
|
||||
getDevice().reboot();
|
||||
|
||||
// Stage another session which will be installed during fs-rollback mode
|
||||
runPhase("testActiveApexIsRevertedOnCheckpointRollback_Commit");
|
||||
|
||||
// Set checkpoint to 0 so that we enter fs-rollback mode immediately on reboot
|
||||
getDevice().enableAdbRoot();
|
||||
getDevice().executeShellCommand("vdc checkpoint startCheckpoint 0");
|
||||
getDevice().disableAdbRoot();
|
||||
getDevice().reboot();
|
||||
|
||||
// Verify that session was reverted and we have fallen back to
|
||||
// apex installed during preparation stage.
|
||||
runPhase("testActiveApexIsRevertedOnCheckpointRollback_VerifyPostReboot");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApexIsNotActivatedIfNotInCheckpointMode() throws Exception {
|
||||
assumeTrue("Device does not support updating APEX",
|
||||
mHostUtils.isApexUpdateSupported());
|
||||
assumeTrue("Device does not support file-system checkpoint",
|
||||
mHostUtils.isCheckpointSupported());
|
||||
|
||||
runPhase("testApexIsNotActivatedIfNotInCheckpointMode_Commit");
|
||||
// Delete checkpoint file in /metadata so that device thinks
|
||||
// fs-checkpointing was never activated
|
||||
getDevice().enableAdbRoot();
|
||||
getDevice().executeShellCommand("rm /metadata/vold/checkpoint");
|
||||
getDevice().disableAdbRoot();
|
||||
getDevice().reboot();
|
||||
// Verify that session was not installed when not in fs-checkpoint mode
|
||||
runPhase("testApexIsNotActivatedIfNotInCheckpointMode_VerifyPostReboot");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRebootlessUpdates() throws Exception {
|
||||
pushTestApex("test.rebootless_apex_v1.apex");
|
||||
|
||||
Reference in New Issue
Block a user