-
Notifications
You must be signed in to change notification settings - Fork 9
/
run
executable file
·82 lines (68 loc) · 1.98 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
"""
Runs scenario simulation with veins and veins-vlc current directory
"""
import os
import argparse
def relpath(s):
root = os.path.dirname(os.path.realpath(__file__))
return os.path.relpath(os.path.join(root, s), ".")
parser = argparse.ArgumentParser("Run a Veins-VLC simulation")
parser.add_argument(
"-d",
"--debug",
action="store_true",
help="Run using opp_run_dbg (instead of opp_run)",
)
parser.add_argument(
"-t",
"--tool",
metavar="TOOL",
dest="tool",
choices=["lldb", "gdb", "memcheck"],
help="Wrap opp_run execution in TOOL (lldb, gdb or memcheck)",
)
parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="Print command line before executing",
)
parser.add_argument(
"--", dest="arguments", help="Arguments to pass to opp_run"
)
args, omnet_args = parser.parse_known_args()
if (len(omnet_args) > 0) and omnet_args[0] == "--":
omnet_args = omnet_args[1:]
run_libs = [
relpath(s) for s in ["lib/veins/src/veins", "lib/veins-vlc/src/veins-vlc"]
]
run_neds = [
relpath(s)
for s in ["src", "lib/veins/src/veins", "lib/veins-vlc/src/veins-vlc"]
] + ["."]
run_imgs = [relpath(s) for s in ["lib/veins/images", "lib/veins-vlc/images"]]
run = "../src/experiment" if not args.debug else "../src/experiment_dbg"
lib_flags = ["-l%s" % s for s in run_libs]
ned_flags = ["-n" + ";".join(run_neds)]
img_flags = ["--image-path=" + ";".join(run_imgs)]
prefix = []
if args.tool == "lldb":
prefix = ["lldb", "--"]
if args.tool == "gdb":
prefix = ["gdb", "--args"]
if args.tool == "memcheck":
prefix = [
"valgrind",
"--tool=memcheck",
"--leak-check=full",
"--dsymutil=yes",
"--log-file=valgrind.out",
]
cmdline = prefix + [run] + lib_flags + ned_flags + img_flags + omnet_args
if args.verbose:
print(
"Running with command line arguments: %s"
% " ".join(['"%s"' % arg for arg in cmdline])
)
os.execvp("env", ["env"] + cmdline)