1 # Copyright (c) 2009 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 __author__ = 'kobic (at] codeaurora.org (Kobi Cohen-Arazi)' 6 7 import os 8 import datetime 9 import logging 10 import re 11 import utils 12 from autotest_lib.client.bin import test 13 from autotest_lib.client.common_lib import error 14 15 class platform_Rootdev(test.test): 16 version = 1 17 18 def test_no_partition(self, inputDev, cpuType): 19 20 # arm should be /dev/mmcblk0, /dev/mmcblk1 etc 21 # x86 should be /dev/sda, /dev/sdb 22 23 if (cpuType == "arm"): 24 m = re.match("/dev/mmcblk[0-9]$", inputDev) 25 if not m: 26 raise error.TestFail( 27 "Rootdev test_no_partition arm failed != /dev/mmcblk[0-9]") 28 29 else: 30 m = re.match("/dev/sd[a-z]$", inputDev) 31 if not m: 32 raise error.TestFail( 33 "Rootdev test_no_partition x86 failed != /dev/sd[a-z]") 34 35 36 def run_once(self): 37 38 cpuType = utils.get_cpu_arch() 39 logging.debug("cpu type is %s" % cpuType) 40 41 # test return values 42 result = utils.system("rootdev -s") 43 logging.debug("Rootdev test res: %d", result) 44 if (result != 0): 45 raise error.TestFail("Rootdev failed") 46 result = utils.system("rootdev -s -d") 47 logging.debug("Rootdev test -d switch res: %d", result) 48 if (result != 0): 49 raise error.TestFail("Rootdev failed -s -d") 50 51 # test with -d Results should be without the partition device number 52 text = utils.system_output("rootdev -s -d 2>&1") 53 text = text.strip() 54 logging.debug("Rootdev -s -d txt is *%s*", text) 55 self.test_no_partition(text, cpuType) 56 57 58