aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElie Kheirallah <khei@google.com>2024-04-16 17:59:58 +0000
committerElie Kheirallah <khei@google.com>2024-04-16 21:12:47 +0000
commitff0c4114cf24d6235c2f7a9130c651fec1b31509 (patch)
tree181a7ed91bf0f5361948dc61dc7ee3cb1dec4998
parenta5785dcb15b2d65edc6ccd59a0e449fbedcdd243 (diff)
downloadcuttlefish-ff0c4114cf24d6235c2f7a9130c651fec1b31509.tar.gz
Add powerwash/snapshot test combinations
Add tests that will snapshot/powerwash to try out combinations of restoring a device. Bug: N/A Test: run in abtd Change-Id: I8ce4da3fcedea767fd2817681a5357096d5c68e2
-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");
+ }
}