summaryrefslogtreecommitdiffstats
path: root/tests/nvme_dsm_test.py
blob: fe3dc01f6a8dbdc1db756717be747d98011587a7 (plain)
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-only
#
# 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 DSM Testcase:-

    1. Issue DSM command on set of block; shall pass.

"""

from nose.tools import assert_equal
from nvme_test import TestNVMe


class TestNVMeDsm(TestNVMe):

    """
    Represents NVMe Verify testcase.
        - Attributes:
              - start_block :   starting block of to verify operation.
              - range :         Range of blocks for DSM operation.
              - test_log_dir :  directory for logs, temp files.
    """

    def __init__(self):
        """ Pre Section for TestNVMeDsm """
        TestNVMe.__init__(self)
        self.start_block = 0
        self.range = 0
        self.namespace = 1
        self.setup_log_dir(self.__class__.__name__)

    def __del__(self):
        """ Post Section for TestNVMeDsm """
        TestNVMe.__del__(self)

    def dsm(self):
        """ Wrapper for nvme verify
            - Args:
                - None
            - Returns:
                - return code for nvme dsm command.
        """
        dsm_cmd = "nvme dsm " + self.ctrl + \
                  " --namespace-id=" + str(self.namespace) + \
                  " --blocks=" + str(self.range) + \
                  " --slbs=" + str(self.start_block)
        return self.exec_cmd(dsm_cmd)

    def test_dsm(self):
        """ Testcase main """
        assert_equal(self.dsm(), 0)