diff options
author | Daniel Manrique <roadmr@ubuntu.com> | 2014-07-23 17:16:16 +0000 |
---|---|---|
committer | Daniel Manrique <> | 2014-07-23 17:16:16 +0000 |
commit | f72d5892a9fd624800a86c25c7a8acddcca2387e (patch) | |
tree | 4ab1a2ef0ba412a98192938b441e0c2f2cd81cf2 | |
parent | 1dfe551d7f685b01c038fe2bc2499d4bcccb6781 (diff) | |
parent | 03a45306d439a280d6914575e519240f1c216f25 (diff) |
"providers:checkbox: Add the missing hdd_parking script from checkbox-legacy. [r=zkrynicki][bug=1347761][author=roadmr]"
-rwxr-xr-x | bin/hdd_parking | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/bin/hdd_parking b/bin/hdd_parking new file mode 100755 index 0000000..ead27c0 --- /dev/null +++ b/bin/hdd_parking @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- +# +# hdd_parking +# +# This file is part of Checkbox. +# +# Copyright 2014 Canonical Ltd. +# +# Authors: Brendan Donegan <brendan.donegan@canonical.com> +# +# Checkbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, +# as published by the Free Software Foundation. + +# +# Checkbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. + +""" +This script verifies that a systems HDD protection capabilities +are triggered when appropriate. There are many implementations +of HDD protection from different OEMs, each implemented in a +different way, so this script can only support implementations +which are known to work and are testable. Currently the list +of supported implementations is: + +- HDAPS (Lenovo) +""" + + +import sys +import time + +from argparse import ArgumentParser +from subprocess import Popen, PIPE + +TIMEOUT = 15.0 + +def hdaps_test(run_time): + hdapsd = Popen(['/usr/sbin/hdapsd'], stdout=PIPE, stderr=PIPE, + universal_newlines=True) + time.sleep(float(run_time)) + hdapsd.terminate() + # Look for parking message in hdapsd output. + stdout = hdapsd.communicate()[0] + print(stdout) + for line in stdout.split('\n'): + if line.endswith('parking'): + return 0 + return 1 + +def main(): + # First establish the driver used + parser = ArgumentParser("Tests a systems HDD protection capabilities. " + "Requires the system to be moved by the tester.") + parser.add_argument('-t', '--timeout', + default=TIMEOUT, + help='The time allowed before the test fails.') + print('Starting HDD protection test - move the system around on ' + 'all axis. No particular force should be required.') + return hdaps_test(parser.parse_args().timeout) + +if __name__ == "__main__": + sys.exit(main()) |