1818
1919import json
2020
21- from nvme_test import TestNVMe
21+ from nvme_test import TestNVMe , to_decimal
2222
2323
2424class TestNVMeCopy (TestNVMe ):
@@ -36,6 +36,9 @@ def setUp(self):
3636 super ().setUp ()
3737 self .ocfs = self .get_ocfs ()
3838 self .original_cdfe = None
39+ self .mcl = to_decimal (self .get_id_ns_field_value ("mcl" ))
40+ self .mssrl = to_decimal (self .get_id_ns_field_value ("mssrl" ))
41+ self .msrc = to_decimal (self .get_id_ns_field_value ("msrc" ))
3942 cross_namespace_copy = self .ocfs & 0xc
4043 if cross_namespace_copy :
4144 get_features_cmd = f"{ self .nvme_bin } feat host-behavior-support " + \
@@ -81,6 +84,14 @@ def _check_format_supported(self, desc_format):
8184 if not self .ocfs & (1 << desc_format ):
8285 self .skipTest (f"descriptor format { desc_format } is not supported" )
8386
87+ def _check_ns_copy_limits (self ):
88+ """ Skip test if namespace copy limits (mcl, mssrl, msrc) are not set """
89+ missing = [name for name , val in
90+ [("mcl" , self .mcl ), ("mssrl" , self .mssrl ), ("msrc" , self .msrc )]
91+ if val == 0 ]
92+ if missing :
93+ self .skipTest (f"{ ', ' .join (missing )} are 0, copy not supported on this namespace" )
94+
8495 def copy (self , sdlba , blocks , slbs , ** kwargs ):
8596 """ Wrapper for nvme copy
8697 - Args:
@@ -108,29 +119,35 @@ def copy(self, sdlba, blocks, slbs, **kwargs):
108119 def test_copy_format_0 (self ):
109120 """ Test copy with descriptor format 0 """
110121 self ._check_format_supported (0 )
122+ self ._check_ns_copy_limits ()
111123 self .copy (0 , 1 , 2 , descriptor_format = 0 )
112124
113125 def test_copy_format_1 (self ):
114126 """ Test copy with descriptor format 1 """
115127 self ._check_format_supported (1 )
128+ self ._check_ns_copy_limits ()
116129 self .copy (0 , 1 , 2 , descriptor_format = 1 )
117130
118131 def test_copy_format_2 (self ):
119132 """ Test copy with descriptor format 2 """
120133 self ._check_format_supported (2 )
134+ self ._check_ns_copy_limits ()
121135 self .copy (0 , 1 , 2 , descriptor_format = 2 , snsids = self .ns1_nsid )
122136
123137 def test_copy_format_2_sopts (self ):
124138 """ Test copy with descriptor format 2 and source options """
125139 self ._check_format_supported (2 )
140+ self ._check_ns_copy_limits ()
126141 self .copy (0 , 1 , 2 , descriptor_format = 2 , snsids = self .ns1_nsid , sopts = 0 )
127142
128143 def test_copy_format_3 (self ):
129144 """ Test copy with descriptor format 3 """
130145 self ._check_format_supported (3 )
146+ self ._check_ns_copy_limits ()
131147 self .copy (0 , 1 , 2 , descriptor_format = 3 , snsids = self .ns1_nsid )
132148
133149 def test_copy_format_3_sopts (self ):
134150 """ Test copy with descriptor format 3 and source options """
135151 self ._check_format_supported (3 )
152+ self ._check_ns_copy_limits ()
136153 self .copy (0 , 1 , 2 , descriptor_format = 3 , snsids = self .ns1_nsid , sopts = 0 )
0 commit comments