Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f7c1aa3 authored by JW Wang's avatar JW Wang
Browse files

Test rollback not triggered when crashing under the threshold (2/n)

Move some code to testBadApkOnly_Phase2 so we also test rollback is not
triggered when we don't crash enough times.

Bug: 143052400
Test: atest StagedRollbackTest
Change-Id: If1e3fbbdc24e7e5e2c25c28a4c6b3b1980ac01fd
parent c6efb184
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.util.concurrent.TimeUnit;

/**
 * Tests for rollback of staged installs.
 * <p>
@@ -123,6 +125,13 @@ public class StagedRollbackTest {
        assertThat(rollback).packagesContainsExactly(
                Rollback.from(TestApp.A2).to(TestApp.A1));
        assertThat(rollback.isStaged()).isTrue();

        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_ROLLBACK,
                PROPERTY_WATCHDOG_TRIGGER_FAILURE_COUNT,
                Integer.toString(5), false);
        RollbackUtils.sendCrashBroadcast(TestApp.A, 4);
        // Sleep for a while to make sure we don't trigger rollback
        Thread.sleep(TimeUnit.SECONDS.toMillis(30));
    }

    /**
@@ -132,11 +141,8 @@ public class StagedRollbackTest {
     */
    @Test
    public void testBadApkOnly_Phase3() throws Exception {
        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_ROLLBACK,
                PROPERTY_WATCHDOG_TRIGGER_FAILURE_COUNT,
                Integer.toString(5), false);

        RollbackUtils.sendCrashBroadcast(TestApp.A, 5);
        // One more crash to trigger rollback
        RollbackUtils.sendCrashBroadcast(TestApp.A, 1);

        // We expect the device to be rebooted automatically. Wait for that to happen.
        Thread.sleep(30 * 1000);