@@ -118,7 +118,8 @@ def setup_log_dir(self, test_name):
118118 @tools .nottest
119119 def exec_cmd (self , cmd ):
120120 """ Wrapper for executing a shell command and return the result. """
121- proc = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE )
121+ proc = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE ,
122+ encoding = 'utf-8' )
122123 return proc .wait ()
123124
124125 @tools .nottest
@@ -132,14 +133,16 @@ def nvme_reset_ctrl(self):
132133 nvme_reset_cmd = "nvme reset " + self .ctrl
133134 err = subprocess .call (nvme_reset_cmd ,
134135 shell = True ,
135- stdout = subprocess .PIPE )
136+ stdout = subprocess .PIPE ,
137+ encoding = 'utf-8' )
136138 assert_equal (err , 0 , "ERROR : nvme reset failed" )
137139 time .sleep (5 )
138140 rescan_cmd = "echo 1 > /sys/bus/pci/rescan"
139141 proc = subprocess .Popen (rescan_cmd ,
140142 shell = True ,
141143 stdout = subprocess .PIPE ,
142- stderr = subprocess .PIPE )
144+ stderr = subprocess .PIPE ,
145+ encoding = 'utf-8' )
143146 time .sleep (5 )
144147 assert_equal (proc .wait (), 0 , "ERROR : pci rescan failed" )
145148
@@ -154,7 +157,8 @@ def get_ctrl_id(self):
154157 get_ctrl_id = "nvme list-ctrl " + self .ctrl
155158 proc = subprocess .Popen (get_ctrl_id ,
156159 shell = True ,
157- stdout = subprocess .PIPE )
160+ stdout = subprocess .PIPE ,
161+ encoding = 'utf-8' )
158162 err = proc .wait ()
159163 assert_equal (err , 0 , "ERROR : nvme list-ctrl failed" )
160164 line = proc .stdout .readline ()
@@ -177,7 +181,7 @@ def get_ns_list(self):
177181 encoding = 'utf-8' )
178182 assert_equal (proc .wait (), 0 , "ERROR : nvme list namespace failed" )
179183 for line in proc .stdout :
180- ns_list .append (line .replace ( ' \n ' , '' , 1 ) )
184+ ns_list .append (line .split ( 'x' )[ - 1 ] )
181185
182186 return ns_list
183187
@@ -194,7 +198,8 @@ def get_max_ns(self):
194198 max_ns_cmd = "nvme id-ctrl " + self .ctrl
195199 proc = subprocess .Popen (max_ns_cmd ,
196200 shell = True ,
197- stdout = subprocess .PIPE )
201+ stdout = subprocess .PIPE ,
202+ encoding = 'utf-8' )
198203 err = proc .wait ()
199204 assert_equal (err , 0 , "ERROR : reading maximum namespace count failed" )
200205
@@ -218,7 +223,8 @@ def get_ncap(self):
218223 ncap_cmd = "nvme id-ctrl " + self .ctrl
219224 proc = subprocess .Popen (ncap_cmd ,
220225 shell = True ,
221- stdout = subprocess .PIPE )
226+ stdout = subprocess .PIPE ,
227+ encoding = 'utf-8' )
222228 err = proc .wait ()
223229 assert_equal (err , 0 , "ERROR : reading nvm capacity failed" )
224230
@@ -242,7 +248,8 @@ def get_format(self):
242248 nvm_format_cmd = "nvme id-ns " + self .ctrl + " -n1"
243249 proc = subprocess .Popen (nvm_format_cmd ,
244250 shell = True ,
245- stdout = subprocess .PIPE )
251+ stdout = subprocess .PIPE ,
252+ encoding = 'utf-8' )
246253 err = proc .wait ()
247254 assert_equal (err , 0 , "ERROR : reading nvm capacity failed" )
248255
@@ -265,7 +272,8 @@ def delete_all_ns(self):
265272 list_ns_cmd = "nvme list-ns " + self .ctrl + " --all | wc -l"
266273 proc = subprocess .Popen (list_ns_cmd ,
267274 shell = True ,
268- stdout = subprocess .PIPE )
275+ stdout = subprocess .PIPE ,
276+ encoding = 'utf-8' )
269277 output = proc .stdout .read ().strip ()
270278 assert_equal (output , '0' , "ERROR : deleting all namespace failed" )
271279
@@ -303,7 +311,8 @@ def create_and_validate_ns(self, nsid, nsze, ncap, flbas, dps):
303311 id_ns_cmd = "nvme id-ns " + self .ctrl + " -n " + str (nsid )
304312 err = subprocess .call (id_ns_cmd ,
305313 shell = True ,
306- stdout = subprocess .PIPE )
314+ stdout = subprocess .PIPE ,
315+ encoding = 'utf-8' )
307316 return err
308317
309318 @tools .nottest
@@ -320,7 +329,8 @@ def attach_ns(self, ctrl_id, ns_id):
320329 " --controllers=" + ctrl_id
321330 err = subprocess .call (attach_ns_cmd ,
322331 shell = True ,
323- stdout = subprocess .PIPE )
332+ stdout = subprocess .PIPE ,
333+ encoding = 'utf-8' )
324334 time .sleep (5 )
325335 if err == 0 :
326336 # enumerate new namespace block device
@@ -344,7 +354,8 @@ def detach_ns(self, ctrl_id, nsid):
344354 " --controllers=" + ctrl_id
345355 return subprocess .call (detach_ns_cmd ,
346356 shell = True ,
347- stdout = subprocess .PIPE )
357+ stdout = subprocess .PIPE ,
358+ encoding = 'utf-8' )
348359
349360 @tools .nottest
350361 def delete_and_validate_ns (self , nsid ):
@@ -358,7 +369,8 @@ def delete_and_validate_ns(self, nsid):
358369 delete_ns_cmd = "nvme delete-ns " + self .ctrl + " -n " + str (nsid )
359370 err = subprocess .call (delete_ns_cmd ,
360371 shell = True ,
361- stdout = subprocess .PIPE )
372+ stdout = subprocess .PIPE ,
373+ encoding = 'utf-8' )
362374 assert_equal (err , 0 , "ERROR : delete namespace failed" )
363375 return err
364376
@@ -412,7 +424,8 @@ def get_id_ctrl(self, vendor=False):
412424 print (id_ctrl_cmd )
413425 proc = subprocess .Popen (id_ctrl_cmd ,
414426 shell = True ,
415- stdout = subprocess .PIPE )
427+ stdout = subprocess .PIPE ,
428+ encoding = 'utf-8' )
416429 err = proc .wait ()
417430 assert_equal (err , 0 , "ERROR : nvme id controller failed" )
418431 return err
@@ -448,17 +461,19 @@ def run_ns_io(self, nsid, lbads):
448461 - Returns:
449462 - None
450463 """
451- block_size = mmap .PAGESIZE if lbads < 9 else 2 ** int (lbads )
464+ block_size = mmap .PAGESIZE if int ( lbads ) < 9 else 2 ** int (lbads )
452465 ns_path = self .ctrl + "n" + str (nsid )
453466 io_cmd = "dd if=" + ns_path + " of=/dev/null" + " bs=" + \
454467 str (block_size ) + " count=10 > /dev/null 2>&1"
455468 print (io_cmd )
456- run_io = subprocess .Popen (io_cmd , shell = True , stdout = subprocess .PIPE )
469+ run_io = subprocess .Popen (io_cmd , shell = True , stdout = subprocess .PIPE ,
470+ encoding = 'utf-8' )
457471 run_io_result = run_io .communicate ()[1 ]
458472 assert_equal (run_io_result , None )
459473 io_cmd = "dd if=/dev/zero of=" + ns_path + " bs=" + \
460474 str (block_size ) + " count=10 > /dev/null 2>&1"
461475 print (io_cmd )
462- run_io = subprocess .Popen (io_cmd , shell = True , stdout = subprocess .PIPE )
476+ run_io = subprocess .Popen (io_cmd , shell = True , stdout = subprocess .PIPE ,
477+ encoding = 'utf-8' )
463478 run_io_result = run_io .communicate ()[1 ]
464479 assert_equal (run_io_result , None )
0 commit comments