python3 fixes and testing support (#1916)
* python3: check ksymname calls with _assert_is_bytes
Fixes a bytes/string concatenation error when get/fix_syscall_fnname is
called from a python3 system.
* python3: use env python invocation in tools
In order to facilitate testing, but not necessarily as an example of
good practice, I am changing the invocation of the test tools to use
`/usr/bin/env python`, so that we can control which python (2 vs 3)
gets invoked for the test. On the buildbots, I plan to add an optional
`ln -s /usr/bin/python3 /usr/local/bin/python` on systems that have
python3-bcc package built. This way, we get more test coverage. Having a
cmake mechanism to enable both python2 and python3 testing could be a
further enhancement.
* tools/memleak: add an explicit stdout.flush to print loop
The stdout flush behavior seems to have changed in python3, breaking one
of the tests. I think it makes sense to flush stdout at the end of each
timed interval loop anyway, so adding that to the tool itself.
* tests: add b'' strings and fix dangling handles
Add b'' strings in a few places in the test tools, and fix one dangling
process handle in the memleak test tool runner.
diff --git a/tools/memleak.py b/tools/memleak.py
index 5d69538..4021bf8 100755
--- a/tools/memleak.py
+++ b/tools/memleak.py
@@ -18,6 +18,7 @@
import argparse
import subprocess
import os
+import sys
class Allocation(object):
def __init__(self, stack, size):
@@ -517,6 +518,7 @@
print_outstanding_combined()
else:
print_outstanding()
+ sys.stdout.flush()
count_so_far += 1
if num_prints is not None and count_so_far >= num_prints:
exit()