File: nvme_lba_status_log_test.py

package info (click to toggle)
nvme-cli 2.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,664 kB
  • sloc: ansic: 80,727; sh: 2,257; python: 975; makefile: 70; ruby: 25
file content (57 lines) | stat: -rw-r--r-- 1,545 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# SPDX-License-Identifier: GPL-2.0-or-later
#
# This file is part of nvme-cli
#
# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
#
# Author: Arunpandian J <apj.arun@samsung.com>

"""
NVMe LBA Status Log Testcase :-

    1. Execute lba-status-log on a device.
"""

import subprocess

from nvme_test import TestNVMe


class TestNVMeLbaStatLogCmd(TestNVMe):

    """
    Represents LBA Status Log test.
    """

    def setUp(self):
        """ Pre Section for TestNVMeLbaStatLogCmd. """
        super().setUp()
        if not self.get_lba_status_supported():
            self.skipTest("because: Optional Admin Command 'Get LBA Status' (OACS->GLSS) not supported")
        self.setup_log_dir(self.__class__.__name__)

    def tearDown(self):
        """
        Post Section for TestNVMeLbaStatLogCmd.

            - Call super class's destructor.
        """
        super().tearDown()

    def get_lba_stat_log(self):
        """ Wrapper for executing nvme lba-status-log.
            - Args:
                - None
            - Returns:
                - 0 on success, error code on failure.
        """
        lba_stat_log_cmd = f"{self.nvme_bin} lba-status-log {self.ctrl}"
        proc = subprocess.Popen(lba_stat_log_cmd,
                                shell=True,
                                stdout=subprocess.PIPE,
                                encoding='utf-8')
        return proc.wait()

    def test_lba_stat_log(self):
        """ Testcase main """
        self.assertEqual(self.get_lba_stat_log(), 0)