• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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@codeaurora.org (Kobi Cohen-Arazi)'
6
7import logging
8import re
9import utils
10
11from autotest_lib.client.bin import test
12from autotest_lib.client.common_lib import error
13
14class platform_Rootdev(test.test):
15    version = 1
16
17    def test_no_partition(self, inputDev):
18        """Tests the device is having partition
19
20        @inputDev: rootdev -s -d output.
21        """
22        m = re.match(r'/dev/(sd[a-z]|mmcblk[0-9]+|nvme[0-9]n[0-9]+)$', inputDev)
23        if not m:
24            raise error.TestFail(
25                    "Rootdev test_no_partition failed != "
26                    "/dev/(sd[a-z]|mmcblk[0-9]+|nvme[0-9]n[0-9]+)$")
27
28
29    def run_once(self):
30        # test return values
31        result = utils.system("rootdev -s")
32        logging.debug("Rootdev test res: %d", result)
33        if (result != 0):
34            raise error.TestFail("Rootdev failed")
35        result = utils.system("rootdev -s -d")
36        logging.debug("Rootdev test -d switch res: %d", result)
37        if (result != 0):
38            raise error.TestFail("Rootdev failed -s -d")
39
40        # test with -d Results should be without the partition device number
41        text = utils.system_output("rootdev -s -d 2>&1")
42        text = text.strip()
43        logging.debug("Rootdev -s -d txt is *%s*", text)
44        self.test_no_partition(text)
45
46
47