summaryrefslogtreecommitdiffstats
path: root/test/vpp_qemu_utils.py
diff options
context:
space:
mode:
authorNaveen Joy <najoy@cisco.com>2021-05-11 10:31:18 -0700
committerNaveen Joy <najoy@cisco.com>2022-08-04 12:19:35 -0700
commit7ea7ab5f215a95dbc1a38acc03b7fea6d3dbedcf (patch)
tree0fbc23c6fc67019a785c577204ca01a26272a173 /test/vpp_qemu_utils.py
parent157e4f5d249a262bd8a9c920b8591411e179763c (diff)
tests: run a test inside a QEMU VM
Use the script test/run.py to run a test named test_vm_tap inside a QEMU VM. The run script builds out a virtual env, launches a light weight QEMU VM, mounts host directories, starts VPP inside the VM and runs the test. The test named test_vm_tap, creates two tap v2 interfaces in separate Linux namespaces and using iPerf, streams traffic between the VM and VPP. All data files are stored in the directory named /tmp/vpp-vm-tests. To clean up, use the make test-wipe command. Usage: test/run.py --vm --debug --test test_vm_tap Type: improvement Change-Id: I4425dbef52acee1e5b8af5acaa169b89a2c0f171 Signed-off-by: Naveen Joy <najoy@cisco.com>
Diffstat (limited to 'test/vpp_qemu_utils.py')
-rw-r--r--test/vpp_qemu_utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/vpp_qemu_utils.py b/test/vpp_qemu_utils.py
new file mode 100644
index 00000000000..50fc1c865a6
--- /dev/null
+++ b/test/vpp_qemu_utils.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+# Utility functions for QEMU tests ##
+
+import subprocess
+
+
+def create_namespace(ns):
+ try:
+ subprocess.run(["ip", "netns", "add", ns])
+ except subprocess.CalledProcessError as e:
+ raise Exception("Error creating namespace:", e.output)
+
+
+def list_namespace(ns):
+ """List the IP address of a namespace"""
+ try:
+ subprocess.run(["ip", "netns", "exec", ns, "ip", "addr"])
+ except subprocess.CalledProcessError as e:
+ raise Exception("Error listing namespace IP:", e.output)