summaryrefslogtreecommitdiff
path: root/bin
diff options
authorDaniel Manrique <roadmr@ubuntu.com>2014-07-23 12:06:16 -0400
committerDaniel Manrique <roadmr@ubuntu.com>2014-07-23 12:06:16 -0400
commit03a45306d439a280d6914575e519240f1c216f25 (patch)
treeae6c33c71201886a96a79b0632470fbd3ad68b74 /bin
parent46f70aa4038c6e0f38f13ceb87345b95a9a331e9 (diff)
providers:checkbox: Added hdd_parking script (LP: #1347761)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/hdd_parking70
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())