Skip to content

Commit

Permalink
test: python3 fix for test_uprobes (iovisor#1228)
Browse files Browse the repository at this point in the history
Treat strings as bytes. This is independent of the larger refactor
(iovisor#1139) from which it is cherry-picked)

Signed-off-by: Brenden Blanco <[email protected]>
  • Loading branch information
drzaeus77 authored and goldshtn committed Jun 23, 2017
1 parent 9aa1d75 commit 1ffe18f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/python/test_uprobes.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ def test_mount_namespace(self):
p = subprocess.Popen(["ldconfig", "-p"], stdout=subprocess.PIPE)
for l in p.stdout:
n = l.split()
if n[0] == "libz.so.1":
libz_path = n[-1]
if n[0] == b"libz.so.1":
# if libz was already found, override only if new lib is more
# specific (e.g. libc6,x86-64 vs libc6)
if not libz_path or len(n[1].split(b",")) > 1:
libz_path = n[-1]
p.wait()
p.stdout.close()
p = None

self.assertIsNotNone(libz_path)
Expand All @@ -104,15 +108,15 @@ def test_mount_namespace(self):
raise OSError(e, errno.errorcode[e])

# Remount root MS_REC|MS_PRIVATE
if libc.mount(None, "/", None, (1<<14)|(1<<18) , None) == -1:
if libc.mount(None, b"/", None, (1<<14)|(1<<18) , None) == -1:
e = ctypes.get_errno()
raise OSError(e, errno.errorcode[e])

if libc.mount("tmpfs", "/tmp", "tmpfs", 0, None) == -1:
if libc.mount(b"tmpfs", b"/tmp", b"tmpfs", 0, None) == -1:
e = ctypes.get_errno()
raise OSError(e, errno.errorcode[e])

shutil.copy(libz_path, "/tmp")
shutil.copy(libz_path, b"/tmp")

libz = ctypes.CDLL("/tmp/libz.so.1")
time.sleep(1)
Expand Down

0 comments on commit 1ffe18f

Please sign in to comment.