From: Ondrej Lichtner olichtne@redhat.com
The TestPMD test module can be used to start a testpmd process that comes with dpdk as a background process.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Tests/TestPMD.py | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lnst/Tests/TestPMD.py
diff --git a/lnst/Tests/TestPMD.py b/lnst/Tests/TestPMD.py new file mode 100644 index 0000000..dd26c88 --- /dev/null +++ b/lnst/Tests/TestPMD.py @@ -0,0 +1,47 @@ +import logging +import subprocess +import signal +from lnst.Common.Parameters import Param, StrParam, IntParam, FloatParam +from lnst.Common.Parameters import IpParam, DeviceOrIpParam +from lnst.Tests.BaseTestModule import BaseTestModule, TestModuleError + +class TestPMD(BaseTestModule): + coremask = StrParam(mandatory=True) + + #TODO make ListParam + nics = Param(mandatory=True) + peer_macs = Param(mandatory=True) + + def format_command(self): + testpmd_args = ["testpmd", + "-c", self.params.coremask, + "-n", "4", "--socket-mem", "1024,0"] + for nic in self.params.nics: + testpmd_args.extend(["-w", nic]) + + testpmd_args.extend(["--", "-i", "--forward-mode", "mac"]) + + for i, mac in enumerate(self.params.peer_macs): + testpmd_args.extend(["--eth-peer", "{},{}".format(i, mac)]) + + return " ".join(testpmd_args) + + + def run(self): + cmd = self.format_command() + process = subprocess.Popen(cmd, shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True) + + process.stdin.write("start tx_first\n") + + self.wait_for_interrupt() + + process.stdin.write("stop\n") + process.stdin.write("quit\n") + + out, err = process.communicate() + self._res_data = {"stdout": out, "stderr": err} + return True