Automate manual test compromised stateful partition
The test:
1. Remove files from /mnt/stateful_partion directory.
2. Checks for OOBE screen after rebooting the device with
corrupted stateful partition.
3. Checks that sign in is possible after OOBE.
BUG=chromium:433076
TEST=Tested locally
DEPLOY=test_importer
Change-Id: I3c526297f5f5669734a10403cb76c989ee54fdb3
Reviewed-on: https://chromium-review.googlesource.com/229657
Reviewed-by: Kalin Stoyanov <kalin@chromium.org>
Commit-Queue: Sridhar Sonti <sontis@chromium.org>
Tested-by: Sridhar Sonti <sontis@chromium.org>
diff --git a/server/site_tests/platform_CompromisedStatefulPartition/control b/server/site_tests/platform_CompromisedStatefulPartition/control
new file mode 100644
index 0000000..37af86f
--- /dev/null
+++ b/server/site_tests/platform_CompromisedStatefulPartition/control
@@ -0,0 +1,35 @@
+# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from autotest_lib.server import utils
+
+AUTHOR = "sontis"
+NAME = "platform_CompromisedStatefulPartition"
+PURPOSE = "Compromised stateful partition test."
+CRITERIA = "This test will fail if unable to get OOBE with corrupted stateful partition."
+TIME = "SHORT"
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "platform"
+TEST_TYPE = "server"
+SUITE = "bvt-perbuild"
+
+DOC = """
+This test:
+1. Remove files from /mnt/stateful_partion directory.
+2. Checks for OOBE screen after rebooting the device with
+ corrupted stateful partition.
+3. Checks that sign in is possible after OOBE.
+
+The test fails if
+-Did not get OOBE after rebooting the device with corrupted stateful partition.
+Example usage:
+test_that -b <board> <ip> platform_CompromisedStatefulPartition
+"""
+
+def run(machine):
+ host = hosts.create_host(machine)
+ job.run_test("platform_CompromisedStatefulPartition", host=host,
+ disable_sysinfo=True, client_autotest="desktopui_SimpleLogin")
+
+parallel_simple(run, machines)
diff --git a/server/site_tests/platform_CompromisedStatefulPartition/platform_CompromisedStatefulPartition.py b/server/site_tests/platform_CompromisedStatefulPartition/platform_CompromisedStatefulPartition.py
new file mode 100644
index 0000000..8a8eb51
--- /dev/null
+++ b/server/site_tests/platform_CompromisedStatefulPartition/platform_CompromisedStatefulPartition.py
@@ -0,0 +1,49 @@
+# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from autotest_lib.client.common_lib import error
+from autotest_lib.server import autotest, test
+
+class platform_CompromisedStatefulPartition(test.test):
+ """Tests how the system recovers with the corrupted stateful partition.
+ """
+ version = 1
+
+ CMD_CORRUPT = 'rm -fr /mnt/stateful_partition/*.*'
+ OOBE_FILE = '/home/chronos/.oobe_completed'
+ FILES_LIST = [
+ '/mnt/stateful_partition/dev_image',
+ '/mnt/stateful_partition/encrypted.key',
+ '/mnt/stateful_partition/encrypted.block',
+ '/mnt/stateful_partition/unencrypted',
+ ]
+
+
+ def run_once(self, host, client_autotest):
+ """This test verify that user should get OOBE after booting
+ the device with corrupted statefull partition.
+ Test fails if not able to recover the device with corrupted
+ stateful partition.
+ """
+ autotest_client = autotest.Autotest(host)
+ host.reboot()
+ autotest_client.run_test(client_autotest,
+ exit_without_logout=True)
+ if not host.run(self.CMD_CORRUPT,
+ ignore_status=True).exit_status == 0:
+ raise error.TestFail('Unable to corrupt stateful partition')
+ host.reboot()
+ if host.path_exists(self.OOBE_FILE):
+ raise error.TestFail('Did not get OOBE screen after '
+ 'rebooting the device with '
+ 'corrupted statefull partition')
+ for new_file in self.FILES_LIST:
+ if not host.path_exists(new_file):
+ raise error.TestFail('%s is missing after rebooting '
+ 'the device with corrupted '
+ 'statefull partition' % new_file)
+
+ autotest_client.run_test(client_autotest,
+ exit_without_logout=True)
+