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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « client/site_tests/storage_SsdDetection/control ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2010 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
5 import os
6 import re
7
8 from autotest_lib.client.bin import test, utils
9 from autotest_lib.client.common_lib import error
10
11 class storage_SsdDetection(test.test):
12 version = 1
13
14 def setup(self):
15 self.job.setup_dep(['hdparm'])
16 # create a empty srcdir to prevent the error that checks .version file
17 utils.system('mkdir %s' % self.srcdir)
18
19
20 def run_once(self):
21 # TODO(ericli): need to find a general solution to install dep packages
22 # when tests are pre-compiled, so setup() is not called from client any
23 # more.
24 dep = 'hdparm'
25 dep_dir = os.path.join(self.autodir, 'deps', dep)
26 self.job.install_pkg(dep, 'dep', dep_dir)
27
28 cmdline = file('/proc/cmdline').read()
29 match = re.search(r'root=([^ ]+)', cmdline)
30 if not match:
31 raise error.TestError('Unable to find the root partition')
32 device = match.group(1)[:-1]
33
34 path = self.autodir + '/deps/hdparm/sbin/'
35 hdparm = utils.run(path + 'hdparm -I %s' % device)
36
37 for line in hdparm.stdout:
38 match = re.search(r'Nominal Media Rotation Rate: (.+)',
39 line.strip())
40 if match and match.group(1):
41 if match.group(1) == 'Solid State Device':
42 break;
43 else:
44 raise error.TestFail('The main disk is not a SSD, '
45 'Rotation Rate: %s' % match.group(1))
46 else:
47 raise error.TestNAError(
48 'Rotation Rate not reported from the device, '
49 'unable to ensure it is a SSD')
OLDNEW
« 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