<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6224">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">runtests.py: Add the --pcap option<br><br>--pcap: Capture all packets for each test in the test's log<br>directory as 'packet.pcap'<br><br>There was stub code in TestCase.__init__ that tried to do this but<br>it never worked.<br><br>N.B. This is completely separate from a test's use of pcap.<br><br>Change-Id: I008c2b71f155f919727bef7e1e59173b70065cc9<br>---<br>M lib/python/asterisk/test_case.py<br>M runtests.py<br>2 files changed, 15 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/24/6224/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/lib/python/asterisk/test_case.py b/lib/python/asterisk/test_case.py<br>index dd5365b..815c4c8 100644<br>--- a/lib/python/asterisk/test_case.py<br>+++ b/lib/python/asterisk/test_case.py<br>@@ -169,9 +169,13 @@<br> <br> LOGGER.info("Executing " + self.test_name)<br> <br>- if PCAP_AVAILABLE and self.create_pcap:<br>- self.pcapfilename = os.path.join(self.testlogdir, "dumpfile.pcap")<br>- self.pcap = self.create_pcap_listener(dumpfile=self.pcapfilename)<br>+ if PCAP_AVAILABLE and os.getenv("PCAP", "no") == "yes":<br>+ # This PcapListener is from pcap_listener NOT from asterisk/pcap.<br>+ # The former is standalone, which we need here, while the latter<br>+ # is meant for use by tests.<br>+ # It's triggered by the --pcap command line.<br>+ dumpfile = os.path.join(self.testlogdir, "packet.pcap")<br>+ PcapListener("lo", dumpfile=dumpfile)<br> <br> self._setup_conditions()<br> <br>diff --git a/runtests.py b/runtests.py<br>index a6a80f6..d057f09 100755<br>--- a/runtests.py<br>+++ b/runtests.py<br>@@ -128,6 +128,9 @@<br> cmd = ["./lib/python/asterisk/test_runner.py",<br> "%s" % self.test_name]<br> if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):<br>+ if self.options.pcap:<br>+ os.environ['PCAP'] = "yes"<br>+<br> self.stdout_print("Running %s ..." % cmd)<br> cmd.append(str(self.ast_version).rstrip())<br> p = subprocess.Popen(cmd, stdout=subprocess.PIPE,<br>@@ -439,6 +442,7 @@<br> <br> def _archive_pcap_dump(self, run_dir, archive_dir):<br> self._archive_files(run_dir, archive_dir, 'dumpfile.pcap')<br>+ self._archive_files(run_dir, archive_dir, 'packet.pcap')<br> <br> def __check_can_run(self, ast_version):<br> """Check tags and dependencies in the test config."""<br>@@ -854,6 +858,10 @@<br> parser.add_option("--stop-on-error", action="store_true",<br> dest="stop_on_error", default=False,<br> help="Stops the testsuite when a test fails.")<br>+ parser.add_option("--pcap", action="store_true",<br>+ dest="pcap", default=False,<br>+ help="Capture packets. Output will be in "<br>+ " the test's log directory as packet.pcap.")<br> (options, args) = parser.parse_args(argv)<br> <br> # Install a signal handler for USR1/TERM, and use it to bail out of running<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6224">change 6224</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6224"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I008c2b71f155f919727bef7e1e59173b70065cc9 </div>
<div style="display:none"> Gerrit-Change-Number: 6224 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>