Do cleanup before/after running the test

Somehow rollbacks related to testappA are not cleaned before running the
test and cause test failures. See b/150653097#comment2 for more details.

Let's clean rollbacks manually to have a clean start.

Bug: 150653097
Test: atest MultiUserRollbackTest
Change-Id: I4eb126e193f76c821d26fc62115263b86066a215
This commit is contained in:
JW Wang
2020-03-03 16:17:57 +08:00
parent 78afcedf9f
commit 757a3bad2c
2 changed files with 6 additions and 4 deletions

View File

@@ -15,9 +15,6 @@
-->
<configuration description="Runs rollback tests for multiple users">
<option name="test-suite-tag" value="MultiUserRollbackTest" />
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
<option name="run-command" value="pm uninstall com.android.cts.install.lib.testapp.A" />
</target_preparer>
<test class="com.android.tradefed.testtype.HostTest" >
<option name="class" value="com.android.tests.rollback.host.MultiUserRollbackTest" />
</test>

View File

@@ -40,15 +40,20 @@ public class MultiUserRollbackTest extends BaseHostJUnit4Test {
private static final long SWITCH_USER_COMPLETED_NUMBER_OF_POLLS = 60;
private static final long SWITCH_USER_COMPLETED_POLL_INTERVAL_IN_MILLIS = 1000;
private void cleanUp() throws Exception {
getDevice().executeShellCommand("pm rollback-app com.android.cts.install.lib.testapp.A");
getDevice().executeShellCommand("pm uninstall com.android.cts.install.lib.testapp.A");
}
@After
public void tearDown() throws Exception {
getDevice().executeShellCommand("pm uninstall com.android.cts.install.lib.testapp.A");
cleanUp();
removeSecondaryUserIfNecessary();
}
@Before
public void setup() throws Exception {
cleanUp();
mOriginalUserId = getDevice().getCurrentUser();
createAndStartSecondaryUser();
// TODO(b/149733368): Remove the '-g' workaround when the bug is fixed.