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 " + \
@@ -85,6 +88,14 @@ def _check_format_supported(self, desc_format):
8588 if not self .ocfs & (1 << desc_format ):
8689 self .skipTest (f"descriptor format { desc_format } is not supported" )
8790
91+ def _check_ns_copy_limits (self ):
92+ """ Skip test if namespace copy limits (mcl, mssrl, msrc) are not set """
93+ missing = [name for name , val in
94+ [("mcl" , self .mcl ), ("mssrl" , self .mssrl ), ("msrc" , self .msrc )]
95+ if val == 0 ]
96+ if missing :
97+ self .skipTest (f"{ ', ' .join (missing )} are 0, copy not supported on this namespace" )
98+
8899 def copy (self , sdlba , blocks , slbs , ** kwargs ):
89100 """ Wrapper for nvme copy
90101 - Args:
@@ -112,29 +123,35 @@ def copy(self, sdlba, blocks, slbs, **kwargs):
112123 def test_copy_format_0 (self ):
113124 """ Test copy with descriptor format 0 """
114125 self ._check_format_supported (0 )
126+ self ._check_ns_copy_limits ()
115127 self .copy (0 , 1 , 2 , descriptor_format = 0 )
116128
117129 def test_copy_format_1 (self ):
118130 """ Test copy with descriptor format 1 """
119131 self ._check_format_supported (1 )
132+ self ._check_ns_copy_limits ()
120133 self .copy (0 , 1 , 2 , descriptor_format = 1 )
121134
122135 def test_copy_format_2 (self ):
123136 """ Test copy with descriptor format 2 """
124137 self ._check_format_supported (2 )
138+ self ._check_ns_copy_limits ()
125139 self .copy (0 , 1 , 2 , descriptor_format = 2 , snsids = self .ns1_nsid )
126140
127141 def test_copy_format_2_sopts (self ):
128142 """ Test copy with descriptor format 2 and source options """
129143 self ._check_format_supported (2 )
144+ self ._check_ns_copy_limits ()
130145 self .copy (0 , 1 , 2 , descriptor_format = 2 , snsids = self .ns1_nsid , sopts = 0 )
131146
132147 def test_copy_format_3 (self ):
133148 """ Test copy with descriptor format 3 """
134149 self ._check_format_supported (3 )
150+ self ._check_ns_copy_limits ()
135151 self .copy (0 , 1 , 2 , descriptor_format = 3 , snsids = self .ns1_nsid )
136152
137153 def test_copy_format_3_sopts (self ):
138154 """ Test copy with descriptor format 3 and source options """
139155 self ._check_format_supported (3 )
156+ self ._check_ns_copy_limits ()
140157 self .copy (0 , 1 , 2 , descriptor_format = 3 , snsids = self .ns1_nsid , sopts = 0 )
0 commit comments