Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: client/site_tests/storage_SsdDetection/storage_SsdDetection.py

Issue 549083: Add a test to detect if the main disk is a SSD. (Closed)
Patch Set: Setup deps and include this test into pre-compilation Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/site_tests/storage_SsdDetection/control ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/site_tests/storage_SsdDetection/storage_SsdDetection.py
diff --git a/client/site_tests/storage_SsdDetection/storage_SsdDetection.py b/client/site_tests/storage_SsdDetection/storage_SsdDetection.py
new file mode 100644
index 0000000000000000000000000000000000000000..dd00c2400b6665ee8a53193fb12f2eeb9c223846
--- /dev/null
+++ b/client/site_tests/storage_SsdDetection/storage_SsdDetection.py
@@ -0,0 +1,49 @@
+# Copyright (c) 2010 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.
+
+import os
+import re
+
+from autotest_lib.client.bin import test, utils
+from autotest_lib.client.common_lib import error
+
+class storage_SsdDetection(test.test):
+ version = 1
+
+ def setup(self):
+ self.job.setup_dep(['hdparm'])
+ # create a empty srcdir to prevent the error that checks .version file
+ utils.system('mkdir %s' % self.srcdir)
+
+
+ def run_once(self):
+ # TODO(ericli): need to find a general solution to install dep packages
+ # when tests are pre-compiled, so setup() is not called from client any
+ # more.
+ dep = 'hdparm'
+ dep_dir = os.path.join(self.autodir, 'deps', dep)
+ self.job.install_pkg(dep, 'dep', dep_dir)
+
+ cmdline = file('/proc/cmdline').read()
+ match = re.search(r'root=([^ ]+)', cmdline)
+ if not match:
+ raise error.TestError('Unable to find the root partition')
+ device = match.group(1)[:-1]
+
+ path = self.autodir + '/deps/hdparm/sbin/'
+ hdparm = utils.run(path + 'hdparm -I %s' % device)
+
+ for line in hdparm.stdout:
+ match = re.search(r'Nominal Media Rotation Rate: (.+)',
+ line.strip())
+ if match and match.group(1):
+ if match.group(1) == 'Solid State Device':
+ break;
+ else:
+ raise error.TestFail('The main disk is not a SSD, '
+ 'Rotation Rate: %s' % match.group(1))
+ else:
+ raise error.TestNAError(
+ 'Rotation Rate not reported from the device, '
+ 'unable to ensure it is a SSD')
« no previous file with comments | « client/site_tests/storage_SsdDetection/control ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698