Blame tests/nvme_smart_log_test.py

Packit Service b7b338
# Copyright (c) 2015-2016 Western Digital Corporation or its affiliates.
Packit Service b7b338
#
Packit Service b7b338
# This program is free software; you can redistribute it and/or
Packit Service b7b338
# modify it under the terms of the GNU General Public License
Packit Service b7b338
# as published by the Free Software Foundation; either version 2
Packit Service b7b338
# of the License, or (at your option) any later version.
Packit Service b7b338
#
Packit Service b7b338
# This program is distributed in the hope that it will be useful,
Packit Service b7b338
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service b7b338
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service b7b338
# GNU General Public License for more details.
Packit Service b7b338
#
Packit Service b7b338
# You should have received a copy of the GNU General Public License
Packit Service b7b338
# along with this program; if not, write to the Free Software
Packit Service b7b338
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
Packit Service b7b338
# MA  02110-1301, USA.
Packit Service b7b338
#
Packit Service b7b338
#   Author: Chaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
Packit Service b7b338
#
Packit Service b7b338
"""
Packit Service b7b338
NVMe Smart Log Verification Testcase:-
Packit Service b7b338
Packit Service b7b338
    1. Execute smat-log on controller.
Packit Service b7b338
    2. Execute smart-log on each available namespace.
Packit Service b7b338
Packit Service b7b338
"""
Packit Service b7b338
Packit Service b7b338
from nose.tools import assert_equal
Packit Service b7b338
from nvme_test import TestNVMe
Packit Service b7b338
Packit Service b7b338
Packit Service b7b338
class TestNVMeSmartLogCmd(TestNVMe):
Packit Service b7b338
Packit Service b7b338
    """
Packit Service b7b338
    Represents Smart Log testcae.
Packit Service b7b338
Packit Service b7b338
        - Attributes:
Packit Service b7b338
    """
Packit Service b7b338
Packit Service b7b338
    def __init__(self):
Packit Service b7b338
        """ Pre Section for TestNVMeSmartLogCmd """
Packit Service b7b338
        TestNVMe.__init__(self)
Packit Service b7b338
        self.setup_log_dir(self.__class__.__name__)
Packit Service b7b338
Packit Service b7b338
    def __del__(self):
Packit Service b7b338
        """
Packit Service b7b338
        Post Section for TestNVMeSmartLogCmd
Packit Service b7b338
Packit Service b7b338
            - Call super class's destructor.
Packit Service b7b338
        """
Packit Service b7b338
        TestNVMe.__del__(self)
Packit Service b7b338
Packit Service b7b338
    def get_smart_log_ctrl(self):
Packit Service b7b338
        """ Wrapper for executing smart-log on controller.
Packit Service b7b338
            - Args:
Packit Service b7b338
                - None:
Packit Service b7b338
            - Returns:
Packit Service b7b338
                - 0 on success, error code on failure.
Packit Service b7b338
        """
Packit Service b7b338
        return self.get_smart_log("0xFFFFFFFF")
Packit Service b7b338
Packit Service b7b338
    def get_smart_log_ns(self, nsid):
Packit Service b7b338
        """ Wrapper for executing smart-log on a namespace.
Packit Service b7b338
            - Args:
Packit Service b7b338
                - nsid: namespace id to be used in smart-log command.
Packit Service b7b338
            - Returns:
Packit Service b7b338
                - 0 on success, error code on failure.
Packit Service b7b338
        """
Packit Service b7b338
        return self.get_smart_log(nsid)
Packit Service b7b338
Packit Service b7b338
    def get_smart_log_all_ns(self):
Packit Service b7b338
        """ Wrapper for executing smart-log on all the namespaces.
Packit Service b7b338
            - Args:
Packit Service b7b338
                - None:
Packit Service b7b338
            - Returns:
Packit Service b7b338
                - 0 on success, error code on failure.
Packit Service b7b338
        """
Packit Service b7b338
        ns_list = self.get_ns_list()
Packit Service b7b338
        for nsid in range(0, len(ns_list)):
Packit Service b7b338
            self.get_smart_log_ns(ns_list[nsid])
Packit Service b7b338
        return 0
Packit Service b7b338
Packit Service b7b338
    def test_smart_log(self):
Packit Service b7b338
        """ Testcase main """
Packit Service b7b338
        assert_equal(self.get_smart_log_ctrl(), 0)
Packit Service b7b338
        assert_equal(self.get_smart_log_all_ns(), 0)