summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi-Yo Chiang <yochiang@google.com>2022-08-01 21:27:33 +0800
committerYi-Yo Chiang <yochiang@google.com>2022-08-03 15:20:44 +0800
commitff9a13dcbfcd31b8b302ffc62bd82682156a86e0 (patch)
treeca0a0d54b3cb753d4afe5130860b6a34b96aa786
parentd934b081921ff8a8aaa79f536e8cf98a371806b5 (diff)
downloadgsid-ff9a13dcbfcd31b8b302ffc62bd82682156a86e0.tar.gz
DsuGsiIntegrationTest: Verify that storage space are freed after 'wipe'
'gsi_tool wipe' should free up any space used by DSU. We test this by comparing the free space of /data before and after 'wipe'. As there could be other processes writing to the /data partition at the same time this test is running, the test should be fuzzy to account for the dynamic nature of /data. Use 0.9 (allow 10% jitter) as the dampening factor for the test. The number is chosen randomly. Bug: 240389742 Test: DsuGsiIntegrationTest Change-Id: I43580a50e4e897819157b5ec229d6997212aed6f
-rw-r--r--tests/DsuGsiIntegrationTest.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/DsuGsiIntegrationTest.java b/tests/DsuGsiIntegrationTest.java
index b5d2b1e..18bafd3 100644
--- a/tests/DsuGsiIntegrationTest.java
+++ b/tests/DsuGsiIntegrationTest.java
@@ -146,6 +146,7 @@ public class DsuGsiIntegrationTest extends DsuTestBase {
CLog.i("Pushing '%s' -> '%s'", mSystemImageZip, DSU_IMAGE_ZIP_PUSH_PATH);
getDevice().pushFile(mSystemImageZip, DSU_IMAGE_ZIP_PUSH_PATH);
+ final long freeSpaceBeforeInstall = getDevice().getPartitionFreeSpace("/data") << 10;
assertShellCommand(getDsuInstallCommand());
CLog.i("Wait for DSU installation complete and reboot");
assertTrue(
@@ -160,6 +161,16 @@ public class DsuGsiIntegrationTest extends DsuTestBase {
CLog.i("Test 'gsi_tool enable -s' and 'gsi_tool enable'");
getDevice().reboot();
assertDsuNotRunning();
+
+ final long freeSpaceAfterInstall = getDevice().getPartitionFreeSpace("/data") << 10;
+ final long estimatedDsuSize = freeSpaceBeforeInstall - freeSpaceAfterInstall;
+ assertTrue(
+ String.format(
+ "Expected DSU installation to consume some storage space, free space before"
+ + " install: %d, free space after install: %d, delta: %d",
+ freeSpaceBeforeInstall, freeSpaceAfterInstall, estimatedDsuSize),
+ estimatedDsuSize > 0);
+
assertShellCommand("gsi_tool enable");
getDevice().reboot();
assertDsuRunning();
@@ -200,9 +211,22 @@ public class DsuGsiIntegrationTest extends DsuTestBase {
assertDsuRunning();
assertDevicePathNotExist(REMOUNT_TEST_PATH);
- CLog.i("Testing is done, clean up the device");
+ CLog.i("Test 'gsi_tool wipe'");
assertShellCommand("gsi_tool wipe");
getDevice().reboot();
assertDsuNotRunning();
+
+ final double dampeningCoefficient = 0.9;
+ final long freeSpaceAfterWipe = getDevice().getPartitionFreeSpace("/data") << 10;
+ final long freeSpaceReturnedByWipe = freeSpaceAfterWipe - freeSpaceAfterInstall;
+ assertTrue(
+ String.format(
+ "Expected 'gsi_tool wipe' to return roughly %d of storage space, free space"
+ + " before wipe: %d, free space after wipe: %d, delta: %d",
+ estimatedDsuSize,
+ freeSpaceAfterInstall,
+ freeSpaceAfterWipe,
+ freeSpaceReturnedByWipe),
+ freeSpaceReturnedByWipe > (long) (estimatedDsuSize * dampeningCoefficient));
}
}