Loading tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +5 −13 Original line number Diff line number Diff line Loading @@ -124,22 +124,12 @@ public class StagedRollbackTest { Thread.sleep(TimeUnit.SECONDS.toMillis(30)); } /** * Test rollbacks of staged installs involving only apks with bad update. * Trigger rollback phase. */ @Test public void testBadApkOnly_Phase3_Crash() throws Exception { // One more crash to trigger rollback RollbackUtils.sendCrashBroadcast(TestApp.A, 1); } /** * Test rollbacks of staged installs involving only apks. * Confirm rollback phase. */ @Test public void testBadApkOnly_Phase4_VerifyRollback() throws Exception { public void testBadApkOnly_Phase3_VerifyRollback() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); InstallUtils.processUserData(TestApp.A); Loading Loading @@ -447,8 +437,10 @@ public class StagedRollbackTest { Rollback.from(TEST_APEX_WITH_APK_V2).to(TEST_APEX_WITH_APK_V1), Rollback.from(TestApp.A, 0).to(TestApp.A1)); // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT times to trigger rollback RollbackUtils.sendCrashBroadcast(TestApp.A, 5); // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT-1 times RollbackUtils.sendCrashBroadcast(TestApp.A, 4); // Sleep for a while to make sure we don't trigger rollback Thread.sleep(TimeUnit.SECONDS.toMillis(30)); } @Test Loading tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -153,13 +153,14 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { getDevice().reboot(); runPhase("testBadApkOnly_Phase2_VerifyInstall"); // Trigger rollback and wait for reboot to happen runPhase("testBadApkOnly_Phase3_Crash"); // Launch the app to crash to trigger rollback startActivity(TESTAPP_A); // Wait for reboot to happen waitForDeviceNotAvailable(2, TimeUnit.MINUTES); getDevice().waitForDeviceAvailable(); runPhase("testBadApkOnly_Phase4_VerifyRollback"); runPhase("testBadApkOnly_Phase3_VerifyRollback"); assertThat(mLogger).eventOccurred(ROLLBACK_INITIATE, null, REASON_APP_CRASH, TESTAPP_A); assertThat(mLogger).eventOccurred(ROLLBACK_BOOT_TRIGGERED, null, null, null); Loading Loading @@ -304,8 +305,10 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { getDevice().reboot(); // Verify apex was installed and then crash the apk runPhase("testRollbackApexWithApkCrashing_Phase2_Crash"); // Wait for crash to trigger rollback waitForDeviceNotAvailable(5, TimeUnit.MINUTES); // Launch the app to crash to trigger rollback startActivity(TESTAPP_A); // Wait for reboot to happen waitForDeviceNotAvailable(2, TimeUnit.MINUTES); getDevice().waitForDeviceAvailable(); // Verify rollback occurred due to crash of apk-in-apex runPhase("testRollbackApexWithApkCrashing_Phase3_VerifyRollback"); Loading Loading @@ -631,6 +634,12 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { } } private void startActivity(String packageName) throws Exception { String cmd = "am start -S -a android.intent.action.MAIN " + "-c android.intent.category.LAUNCHER " + packageName; getDevice().executeShellCommand(cmd); } private void crashProcess(String processName, int numberOfCrashes) throws Exception { String pid = ""; String lastPid = "invalid"; Loading Loading
tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +5 −13 Original line number Diff line number Diff line Loading @@ -124,22 +124,12 @@ public class StagedRollbackTest { Thread.sleep(TimeUnit.SECONDS.toMillis(30)); } /** * Test rollbacks of staged installs involving only apks with bad update. * Trigger rollback phase. */ @Test public void testBadApkOnly_Phase3_Crash() throws Exception { // One more crash to trigger rollback RollbackUtils.sendCrashBroadcast(TestApp.A, 1); } /** * Test rollbacks of staged installs involving only apks. * Confirm rollback phase. */ @Test public void testBadApkOnly_Phase4_VerifyRollback() throws Exception { public void testBadApkOnly_Phase3_VerifyRollback() throws Exception { assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1); InstallUtils.processUserData(TestApp.A); Loading Loading @@ -447,8 +437,10 @@ public class StagedRollbackTest { Rollback.from(TEST_APEX_WITH_APK_V2).to(TEST_APEX_WITH_APK_V1), Rollback.from(TestApp.A, 0).to(TestApp.A1)); // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT times to trigger rollback RollbackUtils.sendCrashBroadcast(TestApp.A, 5); // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT-1 times RollbackUtils.sendCrashBroadcast(TestApp.A, 4); // Sleep for a while to make sure we don't trigger rollback Thread.sleep(TimeUnit.SECONDS.toMillis(30)); } @Test Loading
tests/RollbackTest/StagedRollbackTest/src/com/android/tests/rollback/host/StagedRollbackTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -153,13 +153,14 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { getDevice().reboot(); runPhase("testBadApkOnly_Phase2_VerifyInstall"); // Trigger rollback and wait for reboot to happen runPhase("testBadApkOnly_Phase3_Crash"); // Launch the app to crash to trigger rollback startActivity(TESTAPP_A); // Wait for reboot to happen waitForDeviceNotAvailable(2, TimeUnit.MINUTES); getDevice().waitForDeviceAvailable(); runPhase("testBadApkOnly_Phase4_VerifyRollback"); runPhase("testBadApkOnly_Phase3_VerifyRollback"); assertThat(mLogger).eventOccurred(ROLLBACK_INITIATE, null, REASON_APP_CRASH, TESTAPP_A); assertThat(mLogger).eventOccurred(ROLLBACK_BOOT_TRIGGERED, null, null, null); Loading Loading @@ -304,8 +305,10 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { getDevice().reboot(); // Verify apex was installed and then crash the apk runPhase("testRollbackApexWithApkCrashing_Phase2_Crash"); // Wait for crash to trigger rollback waitForDeviceNotAvailable(5, TimeUnit.MINUTES); // Launch the app to crash to trigger rollback startActivity(TESTAPP_A); // Wait for reboot to happen waitForDeviceNotAvailable(2, TimeUnit.MINUTES); getDevice().waitForDeviceAvailable(); // Verify rollback occurred due to crash of apk-in-apex runPhase("testRollbackApexWithApkCrashing_Phase3_VerifyRollback"); Loading Loading @@ -631,6 +634,12 @@ public class StagedRollbackTest extends BaseHostJUnit4Test { } } private void startActivity(String packageName) throws Exception { String cmd = "am start -S -a android.intent.action.MAIN " + "-c android.intent.category.LAUNCHER " + packageName; getDevice().executeShellCommand(cmd); } private void crashProcess(String processName, int numberOfCrashes) throws Exception { String pid = ""; String lastPid = "invalid"; Loading