aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-04-16 22:38:51 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-16 22:38:51 +0000
commit9e50fa0fb53815024bebf776747e84d3f72ad924 (patch)
tree5b3f9403867ebc3381997a179fdc945ac6101490
parent091d2edd79880b057fc7e9969f99936485f08a68 (diff)
parentff0c4114cf24d6235c2f7a9130c651fec1b31509 (diff)
downloadcuttlefish-9e50fa0fb53815024bebf776747e84d3f72ad924.tar.gz
Merge "Add powerwash/snapshot test combinations" into main
-rw-r--r--tests/snapshot/src/com/android/cuttlefish/tests/SnapshotTest.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/snapshot/src/com/android/cuttlefish/tests/SnapshotTest.java b/tests/snapshot/src/com/android/cuttlefish/tests/SnapshotTest.java
index 06c366b16..19b36ecda 100644
--- a/tests/snapshot/src/com/android/cuttlefish/tests/SnapshotTest.java
+++ b/tests/snapshot/src/com/android/cuttlefish/tests/SnapshotTest.java
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue;
import com.android.tradefed.config.Option;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.internal.DeviceResetHandler;
import com.android.tradefed.device.internal.DeviceSnapshotHandler;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
@@ -118,4 +119,48 @@ public class SnapshotTest extends BaseHostJUnit4Test {
// Verify that the device is back online.
getDevice().executeShellCommand("echo test");
}
+
+ // Test powerwash after restoring
+ @Test
+ public void testSnapshotPowerwash() throws Exception {
+ // Snapshot the device>
+ boolean snapshotRes =
+ new DeviceSnapshotHandler().snapshotDevice(getDevice(), "snapshot_img");
+ assertTrue("failed to snapshot", snapshotRes);
+ // Restore the device.
+ boolean restoreRes =
+ new DeviceSnapshotHandler().restoreSnapshotDevice(getDevice(), "snapshot_img");
+ assertTrue("Restore snapshot for device reset failed before powerwash", restoreRes);
+ CLog.d("Powerwash attempt after restore");
+ long start = System.currentTimeMillis();
+ boolean success = new DeviceResetHandler(getInvocationContext()).resetDevice(getDevice());
+ assertTrue(String.format("Powerwash reset failed during attempt after restore"), success);
+ long duration = System.currentTimeMillis() - start;
+ CLog.d("Powerwash took %dms to finish", duration);
+ // Verify that the device is back online.
+ getDevice().executeShellCommand("echo test");
+ }
+
+ // Test powerwash the device, then snapshot and restore
+ @Test
+ public void testPowerwashSnapshot() throws Exception {
+ CLog.d("Powerwash attempt before restore");
+ long start = System.currentTimeMillis();
+ boolean success = new DeviceResetHandler(getInvocationContext()).resetDevice(getDevice());
+ assertTrue(String.format("Powerwash reset failed during attempt before snapshot"), success);
+ long duration = System.currentTimeMillis() - start;
+ CLog.d("Powerwash took %dms to finish", duration);
+ // Verify that the device is back online.
+ getDevice().executeShellCommand("echo test");
+ // Snapshot the device>
+ boolean snapshotRes =
+ new DeviceSnapshotHandler().snapshotDevice(getDevice(), "snapshot_img");
+ assertTrue("failed to snapshot", snapshotRes);
+ // Restore the device.
+ boolean restoreRes =
+ new DeviceSnapshotHandler().restoreSnapshotDevice(getDevice(), "snapshot_img");
+ assertTrue("Restore snapshot after powerwash for device reset failed", restoreRes);
+ // Verify that the device is back online.
+ getDevice().executeShellCommand("echo test");
+ }
}