All of lore.kernel.org
 help / color / mirror / Atom feed
* [nvme-cli 0/9] Update tests for qemu
@ 2019-04-30  6:05 Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 1/9] tests/nvme_writezeros_test.py: check if write zeroes is supported Hannes Reinecke
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


Hi all,

here's an update to the nvme-cli test suite, to bring it more in
line with the spec and to allow it to run under qemu.
The first part fixes up various tests to check if the functionality
is implemented before running the test.
The second part is to make it to run under the quirky qemu NVMe
emulation, which chose not to implement some mandatory features
and log pages. But as this is qemu we sure can update the emulation,
but that won't help us for existing platforms.
So there really is no good way except for masking it out in the
tests.

As usual, comments and reviews are welcome

Hannes Reinecke (9):
  tests/nvme_writezeros_test.py: check if write zeroes is supported
  tests/nvme_writeuncor_test.py: check if write uncorrectable is
    supported
  tests/nvme_compare_test.py: check if compare is supported
  tests: ignore log tests for Qemu
  tests/nvme_text.py: add test for namespace management
  tests/nvme_attach_detach_ns_test.py: skip if namespace mgmt is not
    supported
  tests/nvme_create_max_ns_test.py: skip if namespace mgmt is not
    supported
  tests/nvme_get_features_test.py: skip features for Qemu
  tests/nvme_format_test.py: skip test if namespace management is not
    supported

 tests/nvme_attach_detach_ns_test.py |  13 ++--
 tests/nvme_compare_test.py          |   7 ++-
 tests/nvme_create_max_ns_test.py    |  10 ++-
 tests/nvme_error_log_test.py        |   3 +-
 tests/nvme_format_test.py           |  10 ++-
 tests/nvme_get_features_test.py     |   2 +
 tests/nvme_smart_log_test.py        |   5 +-
 tests/nvme_test.py                  | 119 ++++++++++++++++++++++++++++++++++++
 tests/nvme_writeuncor_test.py       |  11 ++--
 tests/nvme_writezeros_test.py       |  15 ++---
 10 files changed, 167 insertions(+), 28 deletions(-)

-- 
2.13.7

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [nvme-cli 1/9] tests/nvme_writezeros_test.py: check if write zeroes is supported
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30 16:48   ` Heitke, Kenneth
  2019-04-30  6:05 ` [nvme-cli 2/9] tests/nvme_writeuncor_test.py: check if write uncorrectable " Hannes Reinecke
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


Before testing the WRITE ZEROS command we should be testing the
ONCS value of the IDENTIFY CONTROLLER command to figure out if
the command is supported.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_test.py            | 23 +++++++++++++++++++++++
 tests/nvme_writezeros_test.py | 15 ++++++++-------
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/tests/nvme_test.py b/tests/nvme_test.py
index 80939dc..1c17ba1 100644
--- a/tests/nvme_test.py
+++ b/tests/nvme_test.py
@@ -253,6 +253,29 @@ class TestNVMe(object):
         return int(nvm_format)
 
     @tools.nottest
+    def get_oncs_write_zeroes(self):
+        """ Wrapper for extracting write zeroes command support.
+            - Args:
+                - None
+            - Returns:
+                - true if supported.
+        """
+        pattern = re.compile("^oncs[ ]+: [0-9]", re.IGNORECASE)
+        oncs = 0
+        get_ctrl_id = "nvme id-ctrl " + self.ctrl
+        proc = subprocess.Popen(get_ctrl_id,
+                                shell=True,
+                                stdout=subprocess.PIPE)
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : reading oncs value failed")
+
+        for line in proc.stdout:
+            if pattern.match(line):
+                oncs = line.split(":")[1].strip()
+                break
+        return int(oncs, 16) & 8
+
+    @tools.nottest
     def delete_all_ns(self):
         """ Wrapper for deleting all the namespaces.
             - Args:
diff --git a/tests/nvme_writezeros_test.py b/tests/nvme_writezeros_test.py
index 157fd78..e549f3b 100644
--- a/tests/nvme_writezeros_test.py
+++ b/tests/nvme_writezeros_test.py
@@ -93,10 +93,11 @@ class TestNVMeWriteZeros(TestNVMeIO):
         return 0 if filecmp.cmp(self.zero_file, self.read_file) is True else 1
 
     def test_write_zeros(self):
-        """ Testcae main """
-        assert_equal(self.nvme_write(), 0)
-        assert_equal(self.nvme_read(), 0)
-        assert_equal(self.validate_write_read(), 0)
-        assert_equal(self.write_zeroes(), 0)
-        assert_equal(self.nvme_read(), 0)
-        assert_equal(self.validate_zeroes(), 0)
+        """ Testcase main """
+        if self.get_oncs_write_zeroes() == 1:
+            assert_equal(self.nvme_write(), 0)
+            assert_equal(self.nvme_read(), 0)
+            assert_equal(self.validate_write_read(), 0)
+            assert_equal(self.write_zeroes(), 0)
+            assert_equal(self.nvme_read(), 0)
+            assert_equal(self.validate_zeroes(), 0)
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 2/9] tests/nvme_writeuncor_test.py: check if write uncorrectable is supported
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 1/9] tests/nvme_writezeros_test.py: check if write zeroes is supported Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30 18:56   ` Heitke, Kenneth
  2019-04-30  6:05 ` [nvme-cli 3/9] tests/nvme_compare_test.py: check if compare " Hannes Reinecke
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


Before testing the WRITE UNCORRECTABLE command we should be testing the
ONCS value of the IDENTIFY CONTROLLER command to figure out if
the command is supported.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_test.py            | 24 ++++++++++++++++++++++++
 tests/nvme_writeuncor_test.py | 11 ++++++-----
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/tests/nvme_test.py b/tests/nvme_test.py
index 1c17ba1..7db277f 100644
--- a/tests/nvme_test.py
+++ b/tests/nvme_test.py
@@ -276,6 +276,30 @@ class TestNVMe(object):
         return int(oncs, 16) & 8
 
     @tools.nottest
+    def get_oncs_write_uncorr(self):
+        """ Wrapper for extracting write uncorrectable command support.
+            - Args:
+                - None
+            - Returns:
+                - true if supported.
+        """
+        pattern = re.compile("^oncs[ ]+: [0-9]", re.IGNORECASE)
+        oncs = 0
+        get_ctrl_id = "nvme id-ctrl " + self.ctrl
+        proc = subprocess.Popen(get_ctrl_id,
+                                shell=True,
+                                stdout=subprocess.PIPE)
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : reading oncs value failed")
+
+        for line in proc.stdout:
+            if pattern.match(line):
+                oncs = line.split(":")[1].strip()
+                break
+
+        return int(oncs, 16) & 2
+
+    @tools.nottest
     def delete_all_ns(self):
         """ Wrapper for deleting all the namespaces.
             - Args:
diff --git a/tests/nvme_writeuncor_test.py b/tests/nvme_writeuncor_test.py
index 9f96f63..e4dc7b4 100644
--- a/tests/nvme_writeuncor_test.py
+++ b/tests/nvme_writeuncor_test.py
@@ -69,8 +69,9 @@ class TestNVMeUncor(TestNVMeIO):
 
     def test_write_uncor(self):
         """ Testcase main """
-        assert_equal(self.nvme_read(), 0)
-        assert_equal(self.write_uncor(), 0)
-        assert_not_equal(self.nvme_read(), 0)
-        assert_equal(self.nvme_write(), 0)
-        assert_equal(self.nvme_read(), 0)
+        if self.get_oncs_write_uncorr() == 1:
+            assert_equal(self.nvme_read(), 0)
+            assert_equal(self.write_uncor(), 0)
+            assert_not_equal(self.nvme_read(), 0)
+            assert_equal(self.nvme_write(), 0)
+            assert_equal(self.nvme_read(), 0)
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 3/9] tests/nvme_compare_test.py: check if compare is supported
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 1/9] tests/nvme_writezeros_test.py: check if write zeroes is supported Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 2/9] tests/nvme_writeuncor_test.py: check if write uncorrectable " Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 4/9] tests: ignore log tests for Qemu Hannes Reinecke
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


Before testing the COMPARE command we should be testing the
ONCS value of the IDENTIFY CONTROLLER command to figure out if
the command is supported.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_compare_test.py |  7 ++++---
 tests/nvme_test.py         | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/tests/nvme_compare_test.py b/tests/nvme_compare_test.py
index c919c07..2dd0298 100644
--- a/tests/nvme_compare_test.py
+++ b/tests/nvme_compare_test.py
@@ -74,6 +74,7 @@ class TestNVMeCompareCmd(TestNVMeIO):
 
     def test_nvme_compare(self):
         """ Testcase main """
-        assert_equal(self.nvme_write(), 0)
-        assert_not_equal(self.nvme_compare(self.compare_file), 0)
-        assert_equal(self.nvme_compare(self.write_file), 0)
+        if self.get_oncs_compare() == 1:
+            assert_equal(self.nvme_write(), 0)
+            assert_not_equal(self.nvme_compare(self.compare_file), 0)
+            assert_equal(self.nvme_compare(self.write_file), 0)
diff --git a/tests/nvme_test.py b/tests/nvme_test.py
index 7db277f..7fa0734 100644
--- a/tests/nvme_test.py
+++ b/tests/nvme_test.py
@@ -300,6 +300,30 @@ class TestNVMe(object):
         return int(oncs, 16) & 2
 
     @tools.nottest
+    def get_oncs_compare(self):
+        """ Wrapper for extracting compare command support.
+            - Args:
+                - None
+            - Returns:
+                - true if supported.
+        """
+        pattern = re.compile("^oncs[ ]+: [0-9]", re.IGNORECASE)
+        oncs = 0
+        get_ctrl_id = "nvme id-ctrl " + self.ctrl
+        proc = subprocess.Popen(get_ctrl_id,
+                                shell=True,
+                                stdout=subprocess.PIPE)
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : reading oncs value failed")
+
+        for line in proc.stdout:
+            if pattern.match(line):
+                oncs = line.split(":")[1].strip()
+                break
+
+        return int(oncs, 16) & 1
+
+    @tools.nottest
     def delete_all_ns(self):
         """ Wrapper for deleting all the namespaces.
             - Args:
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 4/9] tests: ignore log tests for Qemu
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
                   ` (2 preceding siblings ...)
  2019-04-30  6:05 ` [nvme-cli 3/9] tests/nvme_compare_test.py: check if compare " Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 5/9] tests/nvme_text.py: add test for namespace management Hannes Reinecke
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


The Qemu NVMe implementation doesn't support the GET LOG command,
so these tests are expected to fail.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_error_log_test.py |  3 ++-
 tests/nvme_smart_log_test.py |  5 +++--
 tests/nvme_test.py           | 24 ++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/tests/nvme_error_log_test.py b/tests/nvme_error_log_test.py
index a6a451d..68a0b1f 100644
--- a/tests/nvme_error_log_test.py
+++ b/tests/nvme_error_log_test.py
@@ -60,4 +60,5 @@ class TestNVMeErrorLogCmd(TestNVMe):
 
     def test_get_error_log(self):
         """ Testcase main """
-        assert_equal(self.get_error_log_ctrl(), 0)
+        if self.is_qemu_controller() == 0:
+            assert_equal(self.get_error_log_ctrl(), 0)
diff --git a/tests/nvme_smart_log_test.py b/tests/nvme_smart_log_test.py
index e1eb6e5..ddfac72 100644
--- a/tests/nvme_smart_log_test.py
+++ b/tests/nvme_smart_log_test.py
@@ -82,5 +82,6 @@ class TestNVMeSmartLogCmd(TestNVMe):
 
     def test_smart_log(self):
         """ Testcase main """
-        assert_equal(self.get_smart_log_ctrl(), 0)
-        assert_equal(self.get_smart_log_all_ns(), 0)
+        if self.is_qemu_controller() == 0:
+            assert_equal(self.get_smart_log_ctrl(), 0)
+            assert_equal(self.get_smart_log_all_ns(), 0)
diff --git a/tests/nvme_test.py b/tests/nvme_test.py
index 7fa0734..538d30c 100644
--- a/tests/nvme_test.py
+++ b/tests/nvme_test.py
@@ -324,6 +324,30 @@ class TestNVMe(object):
         return int(oncs, 16) & 1
 
     @tools.nottest
+    def is_qemu_controller(self):
+        """ Wrapper for checking for Qemu NVMe controller.
+            - Args:
+                - None
+            - Returns:
+                - true if supported.
+        """
+        pattern = re.compile("^mn[ ]+: [a-z ]", re.IGNORECASE)
+        model = ""
+        get_ctrl_id = "nvme id-ctrl " + self.ctrl
+        proc = subprocess.Popen(get_ctrl_id,
+                                shell=True,
+                                stdout=subprocess.PIPE)
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : reading controller model value failed")
+
+        for line in proc.stdout:
+            if pattern.match(line):
+                model = line.split(":")[1].strip()
+                break
+
+        return model in "QEMU NVMe Ctrl"
+
+    @tools.nottest
     def delete_all_ns(self):
         """ Wrapper for deleting all the namespaces.
             - Args:
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 5/9] tests/nvme_text.py: add test for namespace management
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
                   ` (3 preceding siblings ...)
  2019-04-30  6:05 ` [nvme-cli 4/9] tests: ignore log tests for Qemu Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 6/9] tests/nvme_attach_detach_ns_test.py: skip if namespace mgmt is not supported Hannes Reinecke
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


Some commands are only mandatory if namespace management is
supported, so add a test to detect it.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_test.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/nvme_test.py b/tests/nvme_test.py
index 538d30c..2f50a51 100644
--- a/tests/nvme_test.py
+++ b/tests/nvme_test.py
@@ -324,6 +324,30 @@ class TestNVMe(object):
         return int(oncs, 16) & 1
 
     @tools.nottest
+    def get_oacs_namespace_mgmt(self):
+        """ Wrapper for extracting namespace management support.
+            - Args:
+                - None
+            - Returns:
+                - true if supported.
+        """
+        pattern = re.compile("^oacs[ ]+: [0-9]", re.IGNORECASE)
+        oacs = 0
+        get_ctrl_id = "nvme id-ctrl " + self.ctrl
+        proc = subprocess.Popen(get_ctrl_id,
+                                shell=True,
+                                stdout=subprocess.PIPE)
+        err = proc.wait()
+        assert_equal(err, 0, "ERROR : reading oacs value failed")
+
+        for line in proc.stdout:
+            if pattern.match(line):
+                oacs = line.split(":")[1].strip()
+                break
+
+        return int(oacs, 16) & 8
+
+    @tools.nottest
     def is_qemu_controller(self):
         """ Wrapper for checking for Qemu NVMe controller.
             - Args:
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 6/9] tests/nvme_attach_detach_ns_test.py: skip if namespace mgmt is not supported
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
                   ` (4 preceding siblings ...)
  2019-04-30  6:05 ` [nvme-cli 5/9] tests/nvme_text.py: add test for namespace management Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 7/9] tests/nvme_create_max_ns_test.py: " Hannes Reinecke
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


If namespace management is not supported the test will fail, too.
So check for it prior to executing the test.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_attach_detach_ns_test.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/nvme_attach_detach_ns_test.py b/tests/nvme_attach_detach_ns_test.py
index 92a82dd..2225e2c 100644
--- a/tests/nvme_attach_detach_ns_test.py
+++ b/tests/nvme_attach_detach_ns_test.py
@@ -53,18 +53,17 @@ class TestNVMeAttachDetachNSCmd(TestNVMe):
         self.nsze = 0x1400000
         self.ncap = 0x1400000
         self.setup_log_dir(self.__class__.__name__)
-        self.ctrl_id = self.get_ctrl_id()
-        self.delete_all_ns()
-        time.sleep(1)
 
     def __del__(self):
         """
         Post Section for TestNVMeAttachDetachNSCmd
 
             - Create primary namespace.
-            - Atttach it to controller.
+            - Attach it to controller.
             - Call super class's destructor.
         """
+        if self.get_oacs_namespace_mgmt() == 0:
+            return
         assert_equal(self.create_and_validate_ns(self.default_nsid,
                                                  self.nsze,
                                                  self.ncap,
@@ -75,6 +74,12 @@ class TestNVMeAttachDetachNSCmd(TestNVMe):
 
     def test_attach_detach_ns(self):
         """ Testcase main """
+        if self.get_oacs_namespace_mgmt() == 0:
+            return
+
+        self.ctrl_id = self.get_ctrl_id()
+        self.delete_all_ns()
+        time.sleep(1)
         err = self.create_and_validate_ns(self.default_nsid,
                                           self.nsze,
                                           self.ncap,
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 7/9] tests/nvme_create_max_ns_test.py: skip if namespace mgmt is not supported
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
                   ` (5 preceding siblings ...)
  2019-04-30  6:05 ` [nvme-cli 6/9] tests/nvme_attach_detach_ns_test.py: skip if namespace mgmt is not supported Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 8/9] tests/nvme_get_features_test.py: skip features for Qemu Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 9/9] tests/nvme_format_test.py: skip test if namespace management is not supported Hannes Reinecke
  8 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


If namespace management is not supported the test will fail, too.
So check for it prior to executing the test.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_create_max_ns_test.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tests/nvme_create_max_ns_test.py b/tests/nvme_create_max_ns_test.py
index f853732..b2b11b2 100644
--- a/tests/nvme_create_max_ns_test.py
+++ b/tests/nvme_create_max_ns_test.py
@@ -54,9 +54,6 @@ class TestNVMeCreateMaxNS(TestNVMe):
         self.ncap = self.nsze
         self.setup_log_dir(self.__class__.__name__)
         self.max_ns = self.get_max_ns()
-        self.ctrl_id = self.get_ctrl_id()
-        self.delete_all_ns()
-        time.sleep(1)
 
     def __del__(self):
         """
@@ -66,6 +63,8 @@ class TestNVMeCreateMaxNS(TestNVMe):
             - Atttach it to controller.
             - Call super class's destructor.
         """
+        if self.get_oacs_namespace_mgmt() == 0:
+            return
         assert_equal(self.create_and_validate_ns(self.default_nsid,
                                                  self.nsze,
                                                  self.ncap,
@@ -76,6 +75,11 @@ class TestNVMeCreateMaxNS(TestNVMe):
 
     def test_attach_detach_ns(self):
         """ Testcase main """
+        if self.get_oacs_namespace_mgmt() == 0:
+            return
+        self.ctrl_id = self.get_ctrl_id()
+        self.delete_all_ns()
+        time.sleep(1)
         for nsid in range(1, self.max_ns):
             print("##### Creating " + str(nsid))
             err = self.create_and_validate_ns(nsid,
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 8/9] tests/nvme_get_features_test.py: skip features for Qemu
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
                   ` (6 preceding siblings ...)
  2019-04-30  6:05 ` [nvme-cli 7/9] tests/nvme_create_max_ns_test.py: " Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  2019-04-30  6:05 ` [nvme-cli 9/9] tests/nvme_format_test.py: skip test if namespace management is not supported Hannes Reinecke
  8 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


Qemu doesn't implement all mandatory features, so we should
only be querying the implemented features when running under
qemu.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_get_features_test.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/nvme_get_features_test.py b/tests/nvme_get_features_test.py
index 8888e4a..7236b60 100644
--- a/tests/nvme_get_features_test.py
+++ b/tests/nvme_get_features_test.py
@@ -54,6 +54,8 @@ class TestNVMeGetMandatoryFeatures(TestNVMe):
         self.setup_log_dir(self.__class__.__name__)
         self.feature_id_list = ["0x01", "0x02", "0x04", "0x05", "0x07",
                                 "0x08", "0x09", "0x0A", "0x0B"]
+        if self.is_qemu_controller():
+            self.feature_id_list = [ "0x06", "0x07" ]
         get_vector_list_cmd = "cat /proc/interrupts | grep nvme |" \
                               " cut -d : -f 1 | tr -d ' ' | tr '\n' ' '"
         proc = subprocess.Popen(get_vector_list_cmd,
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 9/9] tests/nvme_format_test.py: skip test if namespace management is not supported
  2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
                   ` (7 preceding siblings ...)
  2019-04-30  6:05 ` [nvme-cli 8/9] tests/nvme_get_features_test.py: skip features for Qemu Hannes Reinecke
@ 2019-04-30  6:05 ` Hannes Reinecke
  8 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2019-04-30  6:05 UTC (permalink / raw)


While the spec doesn't make any explicit reference to namespace management,
the 'format' command itself is optional, and as such should be allowed
to fail. And the test requires the use of the controller identifier, which
in itself requires namespace management.
So add a check for namespace management before executing the tests.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 tests/nvme_format_test.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tests/nvme_format_test.py b/tests/nvme_format_test.py
index ce93f5e..093d1da 100644
--- a/tests/nvme_format_test.py
+++ b/tests/nvme_format_test.py
@@ -65,14 +65,11 @@ class TestNVMeFormatCmd(TestNVMe):
         self.flbas = 0               # ns formattes logical block settings
         self.nsze = 0x1400000        # ns size
         self.ncap = 0x1400000        # ns capacity
-        self.ctrl_id = self.get_ctrl_id()
         self.lba_format_list = []
         self.ms_list = []
         self.lbads_list = []
         self.test_log_dir = self.log_dir + "/" + self.__class__.__name__
         self.setup_log_dir(self.__class__.__name__)
-        self.delete_all_ns()
-        time.sleep(1)
 
     def __del__(self):
         """
@@ -82,6 +79,8 @@ class TestNVMeFormatCmd(TestNVMe):
             - Atttach it to controller.
             - Call super class's destructor.
         """
+        if self.get_oacs_namespace_mgmt() == 0:
+            return
         assert_equal(self.create_and_validate_ns(self.default_nsid,
                                                  self.nsze,
                                                  self.ncap,
@@ -92,6 +91,9 @@ class TestNVMeFormatCmd(TestNVMe):
 
     def attach_detach_primary_ns(self):
         """ Extract supported format information using default namespace """
+        self.ctrl_id = self.get_ctrl_id()
+        self.delete_all_ns()
+        time.sleep(1)
         assert_equal(self.create_and_validate_ns(self.default_nsid,
                                                  self.nsze,
                                                  self.ncap,
@@ -123,6 +125,8 @@ class TestNVMeFormatCmd(TestNVMe):
     def test_format_ns(self):
         """ Testcase main """
         # extract the supported format information.
+        if self.get_oacs_namespace_mgmt() == 0:
+            return
         self.attach_detach_primary_ns()
 
         # iterate through all supported format
-- 
2.13.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [nvme-cli 1/9] tests/nvme_writezeros_test.py: check if write zeroes is supported
  2019-04-30  6:05 ` [nvme-cli 1/9] tests/nvme_writezeros_test.py: check if write zeroes is supported Hannes Reinecke
@ 2019-04-30 16:48   ` Heitke, Kenneth
  0 siblings, 0 replies; 12+ messages in thread
From: Heitke, Kenneth @ 2019-04-30 16:48 UTC (permalink / raw)




On 4/30/2019 12:05 AM, Hannes Reinecke wrote:
> Before testing the WRITE ZEROS command we should be testing the
> ONCS value of the IDENTIFY CONTROLLER command to figure out if
> the command is supported.
> 
> Signed-off-by: Hannes Reinecke <hare at suse.com>
> ---
>   tests/nvme_test.py            | 23 +++++++++++++++++++++++
>   tests/nvme_writezeros_test.py | 15 ++++++++-------
>   2 files changed, 31 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/nvme_test.py b/tests/nvme_test.py
> index 80939dc..1c17ba1 100644
> --- a/tests/nvme_test.py
> +++ b/tests/nvme_test.py
> @@ -253,6 +253,29 @@ class TestNVMe(object):
>           return int(nvm_format)
>   
>       @tools.nottest
> +    def get_oncs_write_zeroes(self):
> +        """ Wrapper for extracting write zeroes command support.
> +            - Args:
> +                - None
> +            - Returns:
> +                - true if supported.
> +        """
> +        pattern = re.compile("^oncs[ ]+: [0-9]", re.IGNORECASE)
> +        oncs = 0
> +        get_ctrl_id = "nvme id-ctrl " + self.ctrl
> +        proc = subprocess.Popen(get_ctrl_id,
> +                                shell=True,
> +                                stdout=subprocess.PIPE)
> +        err = proc.wait()
> +        assert_equal(err, 0, "ERROR : reading oncs value failed")
> +
> +        for line in proc.stdout:
> +            if pattern.match(line):
> +                oncs = line.split(":")[1].strip()
> +                break
> +        return int(oncs, 16) & 8
> +
> +    @tools.nottest
>       def delete_all_ns(self):
>           """ Wrapper for deleting all the namespaces.
>               - Args:
> diff --git a/tests/nvme_writezeros_test.py b/tests/nvme_writezeros_test.py
> index 157fd78..e549f3b 100644
> --- a/tests/nvme_writezeros_test.py
> +++ b/tests/nvme_writezeros_test.py
> @@ -93,10 +93,11 @@ class TestNVMeWriteZeros(TestNVMeIO):
>           return 0 if filecmp.cmp(self.zero_file, self.read_file) is True else 1
>   
>       def test_write_zeros(self):
> -        """ Testcae main """
> -        assert_equal(self.nvme_write(), 0)
> -        assert_equal(self.nvme_read(), 0)
> -        assert_equal(self.validate_write_read(), 0)
> -        assert_equal(self.write_zeroes(), 0)
> -        assert_equal(self.nvme_read(), 0)
> -        assert_equal(self.validate_zeroes(), 0)
> +        """ Testcase main """
> +        if self.get_oncs_write_zeroes() == 1:

I think you'll either need to shift the bit down in fhte get function, 
check here for 0x08, of check for a True condition


> +            assert_equal(self.nvme_write(), 0)
> +            assert_equal(self.nvme_read(), 0)
> +            assert_equal(self.validate_write_read(), 0)
> +            assert_equal(self.write_zeroes(), 0)
> +            assert_equal(self.nvme_read(), 0)
> +            assert_equal(self.validate_zeroes(), 0)
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [nvme-cli 2/9] tests/nvme_writeuncor_test.py: check if write uncorrectable is supported
  2019-04-30  6:05 ` [nvme-cli 2/9] tests/nvme_writeuncor_test.py: check if write uncorrectable " Hannes Reinecke
@ 2019-04-30 18:56   ` Heitke, Kenneth
  0 siblings, 0 replies; 12+ messages in thread
From: Heitke, Kenneth @ 2019-04-30 18:56 UTC (permalink / raw)




On 4/30/2019 12:05 AM, Hannes Reinecke wrote:
> Before testing the WRITE UNCORRECTABLE command we should be testing the
> ONCS value of the IDENTIFY CONTROLLER command to figure out if
> the command is supported.
> 
> Signed-off-by: Hannes Reinecke <hare at suse.com>
> ---
>   tests/nvme_test.py            | 24 ++++++++++++++++++++++++
>   tests/nvme_writeuncor_test.py | 11 ++++++-----
>   2 files changed, 30 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/nvme_test.py b/tests/nvme_test.py
> index 1c17ba1..7db277f 100644
> --- a/tests/nvme_test.py
> +++ b/tests/nvme_test.py
> @@ -276,6 +276,30 @@ class TestNVMe(object):
>           return int(oncs, 16) & 8
>   
>       @tools.nottest
> +    def get_oncs_write_uncorr(self):
> +        """ Wrapper for extracting write uncorrectable command support.
> +            - Args:
> +                - None
> +            - Returns:
> +                - true if supported.
> +        """
> +        pattern = re.compile("^oncs[ ]+: [0-9]", re.IGNORECASE)
> +        oncs = 0
> +        get_ctrl_id = "nvme id-ctrl " + self.ctrl
> +        proc = subprocess.Popen(get_ctrl_id,
> +                                shell=True,
> +                                stdout=subprocess.PIPE)
> +        err = proc.wait()
> +        assert_equal(err, 0, "ERROR : reading oncs value failed")
> +
> +        for line in proc.stdout:
> +            if pattern.match(line):
> +                oncs = line.split(":")[1].strip()
> +                break
> +
> +        return int(oncs, 16) & 2
> +
> +    @tools.nottest
>       def delete_all_ns(self):
>           """ Wrapper for deleting all the namespaces.
>               - Args:
> diff --git a/tests/nvme_writeuncor_test.py b/tests/nvme_writeuncor_test.py
> index 9f96f63..e4dc7b4 100644
> --- a/tests/nvme_writeuncor_test.py
> +++ b/tests/nvme_writeuncor_test.py
> @@ -69,8 +69,9 @@ class TestNVMeUncor(TestNVMeIO):
>   
>       def test_write_uncor(self):
>           """ Testcase main """
> -        assert_equal(self.nvme_read(), 0)
> -        assert_equal(self.write_uncor(), 0)
> -        assert_not_equal(self.nvme_read(), 0)
> -        assert_equal(self.nvme_write(), 0)
> -        assert_equal(self.nvme_read(), 0)
> +        if self.get_oncs_write_uncorr() == 1:

I think this needs to be '== 0x2' or change the get_oncs_write_uncorr
function to shift the bit down, or check for a True condition

> +            assert_equal(self.nvme_read(), 0)
> +            assert_equal(self.write_uncor(), 0)
> +            assert_not_equal(self.nvme_read(), 0)
> +            assert_equal(self.nvme_write(), 0)
> +            assert_equal(self.nvme_read(), 0)
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-04-30 18:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30  6:05 [nvme-cli 0/9] Update tests for qemu Hannes Reinecke
2019-04-30  6:05 ` [nvme-cli 1/9] tests/nvme_writezeros_test.py: check if write zeroes is supported Hannes Reinecke
2019-04-30 16:48   ` Heitke, Kenneth
2019-04-30  6:05 ` [nvme-cli 2/9] tests/nvme_writeuncor_test.py: check if write uncorrectable " Hannes Reinecke
2019-04-30 18:56   ` Heitke, Kenneth
2019-04-30  6:05 ` [nvme-cli 3/9] tests/nvme_compare_test.py: check if compare " Hannes Reinecke
2019-04-30  6:05 ` [nvme-cli 4/9] tests: ignore log tests for Qemu Hannes Reinecke
2019-04-30  6:05 ` [nvme-cli 5/9] tests/nvme_text.py: add test for namespace management Hannes Reinecke
2019-04-30  6:05 ` [nvme-cli 6/9] tests/nvme_attach_detach_ns_test.py: skip if namespace mgmt is not supported Hannes Reinecke
2019-04-30  6:05 ` [nvme-cli 7/9] tests/nvme_create_max_ns_test.py: " Hannes Reinecke
2019-04-30  6:05 ` [nvme-cli 8/9] tests/nvme_get_features_test.py: skip features for Qemu Hannes Reinecke
2019-04-30  6:05 ` [nvme-cli 9/9] tests/nvme_format_test.py: skip test if namespace management is not supported Hannes Reinecke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.