use PcapWriter to log dataplane traffic
When we write a logfile we'll also write a pcap file with the extension
replaced by ".pcap". If per-test logging is enabled we'll open a new pcap file
for each test.
diff --git a/src/python/oftest/base_tests.py b/src/python/oftest/base_tests.py
index 3b59bc1..a2b25ac 100644
--- a/src/python/oftest/base_tests.py
+++ b/src/python/oftest/base_tests.py
@@ -7,6 +7,7 @@
import logging
import unittest
+import os
import oftest
from oftest import config
@@ -103,6 +104,9 @@
SimpleProtocol.setUp(self)
self.dataplane = oftest.dataplane_instance
self.dataplane.flush()
+ if config["log_dir"] != None:
+ filename = os.path.join(config["log_dir"], str(self)) + ".pcap"
+ self.dataplane.start_pcap(filename)
def inheritSetup(self, parent):
"""
@@ -114,6 +118,8 @@
self.dataplane = parent.dataplane
def tearDown(self):
+ if config["log_dir"] != None:
+ self.dataplane.stop_pcap()
SimpleProtocol.tearDown(self)
class DataPlaneOnly(BaseTest):
@@ -125,6 +131,11 @@
BaseTest.setUp(self)
self.dataplane = oftest.dataplane_instance
self.dataplane.flush()
+ if config["log_dir"] != None:
+ filename = os.path.join(config["log_dir"], str(self)) + ".pcap"
+ self.dataplane.start_pcap(filename)
def tearDown(self):
+ if config["log_dir"] != None:
+ self.dataplane.stop_pcap()
BaseTest.tearDown(self)