• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import logging, os
6from shutil import copyfile
7from autotest_lib.client.bin import test
8from autotest_lib.client.common_lib import error
9
10UMOUNT_FAIL_BASENAME = 'shutdown_stateful_umount_failure'
11SHUTDOWN_STATEFUL_UMOUNT_FAIL = ('/mnt/stateful_partition/' +
12                                 UMOUNT_FAIL_BASENAME)
13
14class platform_CleanShutdown(test.test):
15    """Checks for the presence of an unclean shutdown file."""
16    version = 1
17
18    def run_once(self):
19        if os.path.exists(SHUTDOWN_STATEFUL_UMOUNT_FAIL):
20            with open(SHUTDOWN_STATEFUL_UMOUNT_FAIL) as f:
21                logging.debug('Stateful unmount failure log:\n%s', f.read())
22
23            copyfile(SHUTDOWN_STATEFUL_UMOUNT_FAIL,
24                     os.path.join(self.resultsdir, UMOUNT_FAIL_BASENAME))
25
26            # Delete the file between each test run to see if the last reboot
27            # failed.
28            os.remove(SHUTDOWN_STATEFUL_UMOUNT_FAIL)
29            raise error.TestFail(
30                '{} exists!'.format(SHUTDOWN_STATEFUL_UMOUNT_FAIL))
31