Skip to content

Commit

Permalink
tests: Use Python 3 for integration tests + test fix (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
javierhonduco authored and ajor committed May 19, 2019
1 parent 32dd14b commit 4b0e477
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/main.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

import time
from datetime import timedelta
Expand Down
2 changes: 1 addition & 1 deletion tests/parser.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

from fnmatch import fnmatch
from collections import namedtuple
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime-tests.sh
Expand Up @@ -7,4 +7,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
BPFTRACE_RUNTIME_TEST_EXECUTABLE=${BPFTRACE_RUNTIME_TEST_EXECUTABLE:-$DIR/../src/};
export BPFTRACE_RUNTIME_TEST_EXECUTABLE;

python main.py $@
python3 main.py $@
2 changes: 1 addition & 1 deletion tests/runtime/basic
Expand Up @@ -15,7 +15,7 @@ TIMEOUT 1

NAME errors on non existent file
RUN bpftrace non_existent_file.bt
EXPECT Error: Could not open file 'non_existent_file.bt'
EXPECT Error opening file 'non_existent_file.bt': No such file or directory
TIMEOUT 1

NAME it lists kprobes
Expand Down
8 changes: 5 additions & 3 deletions tests/utils.py
@@ -1,3 +1,5 @@
#!/usr/bin/python3

import subprocess
import signal
from os import environ, uname, devnull
Expand Down Expand Up @@ -101,14 +103,14 @@ def run_test(test):

while p.poll() is None:
nextline = p.stdout.readline()
output += nextline
output += nextline.decode()
if nextline == "Running...\n":
signal.alarm(test.timeout or DEFAULT_TIMEOUT)
if not after and test.after:
after = subprocess.Popen(test.after, shell=True)
break

output += p.communicate()[0]
output += p.communicate()[0].decode()

signal.alarm(0)
result = re.search(test.expect, output)
Expand All @@ -118,7 +120,7 @@ def run_test(test):
# bpftrace process might still be alive
if p.poll() is None:
p.kill()
output += p.communicate()[0]
output += p.communicate()[0].decode()
result = re.search(test.expect, output)
if not result:
print(fail("[ TIMEOUT ] ") + "%s.%s" % (test.suite, test.name))
Expand Down

0 comments on commit 4b0e477

Please sign in to comment.