Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark using cachegrind #1137

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Runs quality assurance checks
name: "qa"
on:
pull_request:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to run this workflow on every pull request because it is slow and it will hence slow down development. We usually only want to run QA tests when we are inside a release branch.

push:
branches:
- "release/**"
Expand Down
25 changes: 18 additions & 7 deletions QA/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,28 @@


def execute(args):
""" Execute a specified command """
"""Execute a specified command"""
subprocess.run(args)


def execute_jafar_and_miniooni(ooni_exe, outfile, experiment, tag, args):
""" Executes jafar and miniooni. Returns the test keys. """
"""Executes jafar and miniooni. Returns the test keys."""
tmpoutfile = "/tmp/{}".format(outfile)
with contextlib.suppress(FileNotFoundError):
os.remove(tmpoutfile) # just in case
execute(
[
# Disable ASLR
"setarch",
"--addr-no-randomize",
# Run cachegrind
"valgrind",
"--tool=cachegrind",
"--I1=32768,8,64",
"--D1=32768,8,64",
"--LL=8388608,16,64",
"--cachegrind-out-file=cachegrind.out",
# Run jafar
"./jafar",
"-main-command",
"./QA/minioonilike.py {} -n -o '{}' --home /tmp {}".format(
Expand All @@ -40,17 +51,17 @@ def execute_jafar_and_miniooni(ooni_exe, outfile, experiment, tag, args):


def read_result(outfile):
""" Reads the result of an experiment """
"""Reads the result of an experiment"""
return json.load(open(outfile, "rb"))


def test_keys(result):
""" Returns just the test keys of a specific result """
"""Returns just the test keys of a specific result"""
return result["test_keys"]


def check_maybe_binary_value(value):
""" Make sure a maybe binary value is correct """
"""Make sure a maybe binary value is correct"""
assert isinstance(value, str) or (
isinstance(value, dict)
and value["format"] == "base64"
Expand All @@ -59,8 +70,8 @@ def check_maybe_binary_value(value):


def with_free_port(func):
""" This function executes |func| passing it a port number on localhost
which is bound but not listening for new connections """
"""This function executes |func| passing it a port number on localhost
which is bound but not listening for new connections"""
# See <https://stackoverflow.com/a/45690594>
with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.bind(("127.0.0.1", 0))
Expand Down
2 changes: 1 addition & 1 deletion QA/rundocker.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GOVERSION=$(cat GOVERSION)

cat > QA/Dockerfile << EOF
FROM golang:$GOVERSION-alpine
RUN apk add gcc go git musl-dev iptables tmux bind-tools curl sudo python3
RUN apk add gcc go git musl-dev iptables tmux bind-tools curl sudo python3 util-linux valgrind
EOF

$DOCKER build -t jafar-qa ./QA/
Expand Down