Skip to content

Commit 7d12fdf

Browse files
committed
tests: fix python TypeError errors
This is to fix the errors below. if self.host_behavior_data[4] & cross_namespace_copy: ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ TypeError: unsupported operand type(s) for &: 'str' and 'int' data = self.host_behavior_data[:4] + cross_namespace_copy.to_bytes... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TypeError: can only concatenate str (not "bytes") to str Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 48969fd commit 7d12fdf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/nvme_copy_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
1717
"""
1818

19+
import base64
20+
1921
from nvme_test import TestNVMe
2022

2123

@@ -44,12 +46,12 @@ def setUp(self):
4446
self.assertEqual(err, 0, "ERROR : nvme get-feature failed")
4547
self.host_behavior_data = result.stdout
4648
# enable cross-namespace copy formats
47-
if self.host_behavior_data[4] & cross_namespace_copy:
49+
if int.from_bytes(base64.b64decode(self.host_behavior_data[4])) & cross_namespace_copy:
4850
# skip if already enabled
4951
print("Cross-namespace copy already enabled, skipping set-features")
5052
self.host_behavior_data = None
5153
else:
52-
data = self.host_behavior_data[:4] + cross_namespace_copy.to_bytes(2, 'little') + self.host_behavior_data[6:]
54+
data = self.host_behavior_data[:4] + str(cross_namespace_copy.to_bytes(2, 'little')) + self.host_behavior_data[6:]
5355
set_features_cmd = f"{self.nvme_bin} set-feature " + \
5456
f"{self.ctrl} --feature-id=0x16 --data-len=512"
5557
result = self.run_cmd(set_features_cmd, stdin_data=data)

0 commit comments

Comments
 (0)