test: python3 fix for test_uprobes
Treat strings as bytes. This is independent of the larger refactor
from which it is cherry-picked)
@@ -88,9 +88,13 @@ int count(struct pt_regs *ctx) {
p = subprocess.Popen(["ldconfig", "-p"], stdout=subprocess.PIPE)
for l in p.stdout:
n = l.split()
- if n[0] == "libz.so.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)
@@ -104,15 +108,15 @@ int count(struct pt_regs *ctx) {
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)
