Commit 1ffe18f8 authored by Brenden Blanco's avatar Brenden Blanco Committed by Sasha Goldshtein

test: python3 fix for test_uprobes (#1228)

Treat strings as bytes. This is independent of the larger refactor
(#1139) from which it is cherry-picked)
Signed-off-by: default avatarBrenden Blanco <bblanco@gmail.com>
parent 9aa1d752
...@@ -88,9 +88,13 @@ int count(struct pt_regs *ctx) { ...@@ -88,9 +88,13 @@ int count(struct pt_regs *ctx) {
p = subprocess.Popen(["ldconfig", "-p"], stdout=subprocess.PIPE) p = subprocess.Popen(["ldconfig", "-p"], stdout=subprocess.PIPE)
for l in p.stdout: for l in p.stdout:
n = l.split() n = l.split()
if n[0] == "libz.so.1": if n[0] == b"libz.so.1":
libz_path = n[-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.wait()
p.stdout.close()
p = None p = None
self.assertIsNotNone(libz_path) self.assertIsNotNone(libz_path)
...@@ -104,15 +108,15 @@ int count(struct pt_regs *ctx) { ...@@ -104,15 +108,15 @@ int count(struct pt_regs *ctx) {
raise OSError(e, errno.errorcode[e]) raise OSError(e, errno.errorcode[e])
# Remount root MS_REC|MS_PRIVATE # 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() e = ctypes.get_errno()
raise OSError(e, errno.errorcode[e]) 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() e = ctypes.get_errno()
raise OSError(e, errno.errorcode[e]) raise OSError(e, errno.errorcode[e])
shutil.copy(libz_path, "/tmp") shutil.copy(libz_path, b"/tmp")
libz = ctypes.CDLL("/tmp/libz.so.1") libz = ctypes.CDLL("/tmp/libz.so.1")
time.sleep(1) time.sleep(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment