build: fix ns3 run from source file path, add lldb option and tests
This commit is contained in:
9
ns3
9
ns3
@@ -182,6 +182,9 @@ def parse_args(argv):
|
||||
parser_run.add_argument('--gdb',
|
||||
help='Change the default command template to run programs with gdb',
|
||||
action="store_true", default=None)
|
||||
parser_run.add_argument('--lldb',
|
||||
help='Change the default command template to run programs with lldb',
|
||||
action="store_true", default=None)
|
||||
parser_run.add_argument('--valgrind',
|
||||
help='Change the default command template to run programs with valgrind',
|
||||
action="store_true", default=None)
|
||||
@@ -571,7 +574,7 @@ def get_program_shortcuts(build_profile, ns3_version):
|
||||
# Check if there is a .cc file for that specific program
|
||||
source_file_path = os.sep.join(temp_path) + ".cc"
|
||||
source_shortcut = False
|
||||
if os.path.exists(ns3_path + source_file_path):
|
||||
if os.path.exists(os.path.join(ns3_path, source_file_path)):
|
||||
source_shortcut = True
|
||||
|
||||
program = program.strip()
|
||||
@@ -872,6 +875,10 @@ def run_step(args, target_to_run, target_args):
|
||||
if args.gdb:
|
||||
debugging_software.extend([shutil.which("gdb"), "--args"])
|
||||
|
||||
# running lldb?
|
||||
if args.lldb:
|
||||
debugging_software.extend([shutil.which("lldb"), "--"])
|
||||
|
||||
# running with the visualizer?
|
||||
if args.visualize:
|
||||
target_args.append("--SimulatorImplementationType=ns3::VisualSimulatorImpl")
|
||||
|
||||
@@ -1237,6 +1237,7 @@ class NS3BuildBaseTestCase(NS3BaseTestCase):
|
||||
"""
|
||||
# Build.
|
||||
targets = {"scratch/scratch-simulator": "scratch-simulator",
|
||||
"scratch/scratch-simulator.cc": "scratch-simulator",
|
||||
"scratch-simulator": "scratch-simulator",
|
||||
"scratch/subdir/scratch-simulator-subdir": "subdir_scratch-simulator-subdir",
|
||||
"subdir/scratch-simulator-subdir": "subdir_scratch-simulator-subdir",
|
||||
@@ -1254,7 +1255,7 @@ class NS3BuildBaseTestCase(NS3BaseTestCase):
|
||||
self.assertEqual(return_code, 0)
|
||||
self.assertIn(build_line, stdout)
|
||||
stdout = stdout.replace("scratch_%s" % target_cmake, "") # remove build lines
|
||||
self.assertIn(target_to_run.split("/")[-1], stdout)
|
||||
self.assertIn(target_to_run.split("/")[-1].replace(".cc", ""), stdout)
|
||||
|
||||
NS3BuildBaseTestCase.cleaned_once = False
|
||||
|
||||
@@ -1498,9 +1499,9 @@ class NS3ExpectedUseTestCase(NS3BaseTestCase):
|
||||
self.assertEqual(return_code, 1)
|
||||
self.assertIn("Couldn't find the specified program: nonsense", stderr)
|
||||
|
||||
def test_08_RunNoBuildGdb(self):
|
||||
def test_08_RunNoBuildGdbAndLldb(self):
|
||||
"""!
|
||||
Test if scratch simulator is executed through gdb
|
||||
Test if scratch simulator is executed through gdb and lldb
|
||||
@return None
|
||||
"""
|
||||
return_code, stdout, stderr = run_ns3("run scratch-simulator --gdb --verbose --no-build")
|
||||
@@ -1508,6 +1509,11 @@ class NS3ExpectedUseTestCase(NS3BaseTestCase):
|
||||
self.assertIn("scratch-simulator", stdout)
|
||||
self.assertIn("No debugging symbols found", stdout)
|
||||
|
||||
return_code, stdout, stderr = run_ns3("run scratch-simulator --lldb --verbose --no-build")
|
||||
self.assertEqual(return_code, 0)
|
||||
self.assertIn("scratch-simulator", stdout)
|
||||
self.assertIn("(lldb) target create", stdout)
|
||||
|
||||
def test_09_RunNoBuildValgrind(self):
|
||||
"""!
|
||||
Test if scratch simulator is executed through valgrind
|
||||
|
||||
Reference in New Issue
Block a user