From: Waldemar Kozaczuk <[email protected]>
Committer: Waldemar Kozaczuk <[email protected]>
Branch: master

scripts: enhance test_app_with_test_script.py to allow running with vhost/tap networking

Signed-off-by: Waldemar Kozaczuk <[email protected]>

---
diff --git a/scripts/tests/test_app_with_test_script.py b/scripts/tests/test_app_with_test_script.py
--- a/scripts/tests/test_app_with_test_script.py
+++ b/scripts/tests/test_app_with_test_script.py
@@ -3,12 +3,15 @@
 import argparse
 import runpy

-def run(command, hypervisor_name, host_port, guest_port, script_path, image_path=None, start_line=None, end_line=None): +def run(command, hypervisor_name, host_port, guest_port, script_path, image_path=None, start_line=None, end_line=None, use_vhost_networking=False):
     py_args = []
     if image_path != None:
         py_args = ['--image', image_path]

- app = run_command_in_guest(command, hypervisor=hypervisor_name, run_py_args=py_args, forward=[(host_port, guest_port)])
+    if use_vhost_networking and hypervisor_name != 'firecracker':
+ app = run_command_in_guest(command, hypervisor=hypervisor_name, run_py_args=py_args + ['-nv'])
+    else:
+ app = run_command_in_guest(command, hypervisor=hypervisor_name, run_py_args=py_args, forward=[(host_port, guest_port)])

     if start_line != None:
         wait_for_line_contains(app, start_line)
@@ -44,6 +47,7 @@ def run(command, hypervisor_name, host_port, guest_port, script_path, image_path
                         help="path to test script path")
parser.add_argument("-e", "--execute", action="store", default='runscript /run/default;', metavar="CMD",
                         help="edit command line before execution")
+ parser.add_argument("-n", "--vhost", action="store_true", help="setup tap/vhost networking")

     cmdargs = parser.parse_args()

@@ -57,8 +61,10 @@ def run(command, hypervisor_name, host_port, guest_port, script_path, image_path

     if hypervisor_name == 'firecracker':
         os.environ['OSV_HOSTNAME'] = '172.16.0.2'
+    elif cmdargs.vhost:
+        os.environ['OSV_HOSTNAME'] = '192.168.122.76'
     else:
         os.environ['OSV_HOSTNAME'] = 'localhost'

     set_verbose_output(True)
- run(cmdargs.execute, hypervisor_name, cmdargs.host_port, cmdargs.guest_port, cmdargs.script_path, cmdargs.image, cmdargs.start_line, cmdargs.end_line) + run(cmdargs.execute, hypervisor_name, cmdargs.host_port, cmdargs.guest_port, cmdargs.script_path, cmdargs.image, cmdargs.start_line, cmdargs.end_line, cmdargs.vhost)

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/0000000000006397da05985a6603%40google.com.

Reply via email to