-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QA: add support for running measurement_kit
This will be very helpful for #810. It will allow us, in fact, to compare the result obtained by MK to the one obtained by miniooni in specific censorship conditions.
- Loading branch information
1 parent
944a390
commit 099573d
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" This script takes in input the name of the tool to run followed by | ||
arguments and followed by the nettest name. The format recognized is | ||
the same of miniooni. Depending on the tool that we want to run, we | ||
reorder arguments so that they make sense for the tool. | ||
This is necessary because, albeit miniooni, MK, and OONI v2.x have | ||
more or less the same arguments, there are some differences. We could | ||
modify other tools to match miniooni, but this seems useless. """ | ||
|
||
import argparse | ||
import shlex | ||
import sys | ||
|
||
sys.path.insert(0, ".") | ||
import common | ||
|
||
|
||
def main(): | ||
apa = argparse.ArgumentParser() | ||
apa.add_argument("command", nargs=1, help="command to execute") | ||
|
||
# subset of arguments accepted by miniooni | ||
apa.add_argument( | ||
"-n", "--no-collector", action="count", help="don't submit measurement" | ||
) | ||
apa.add_argument("-o", "--reportfile", help="specify report file to use") | ||
apa.add_argument("-i", "--input", help="input for nettests taking an input") | ||
apa.add_argument("--home", help="override home directory") | ||
apa.add_argument("nettest", nargs=1, help="nettest to run") | ||
out = apa.parse_args() | ||
command, nettest = out.command[0], out.nettest[0] | ||
|
||
if "miniooni" not in command and "measurement_kit" not in command: | ||
raise RuntimeError("unrecognized tool") | ||
|
||
args = [] | ||
args.append(command) | ||
if out.home and "miniooni" in command: | ||
args.extend(["--home", out.home]) # home applies to miniooni only | ||
if out.input: | ||
if "miniooni" in command: | ||
args.extend(["-i", out.input]) # input is -i for miniooni | ||
if out.no_collector: | ||
args.append("-n") | ||
if out.reportfile: | ||
args.extend(["-o", out.reportfile]) | ||
args.append(nettest) | ||
if out.input and "measurement_kit" in command: | ||
if nettest == "web_connectivity": | ||
args.extend(["-u", out.input]) # MK's Web Connectivity uses -u for input | ||
|
||
sys.stderr.write("minioonilike.py: {}\n".format(shlex.join(args))) | ||
common.execute(args) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |