diff --git a/README.md b/README.md index 56f615a..b707951 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ usage: test-in-vm.py [-h] [--headless] [--scenario FILENAME.yml] --arch ARCHITECTURE [--memory MB] --image FILENAME [--pass OPTION] [--vterm-dump FILENAME.txt] [--last-screenshot FILENAME.png] [--debug] + [--two_network_drvs] Testing of HelenOS in VM @@ -63,6 +64,7 @@ optional arguments: --last-screenshot FILENAME.png Where to store last screenshot. --debug Print debugging messages + --two_network_drvs Specify if HelenOS will run with two network drivers e1000 and ne2k. Typical invocation will use the following arguments: --image helenos.iso diff --git a/htest/vm/controller.py b/htest/vm/controller.py index 832e906..04b949d 100755 --- a/htest/vm/controller.py +++ b/htest/vm/controller.py @@ -37,7 +37,7 @@ class VMManager: Keeps track of running virtual machines. """ - def __init__(self, controller, architecture, vm_config, boot_image, disk_image, memory_amount, headless, extra_opts): + def __init__(self, controller, architecture, vm_config, boot_image, disk_image, memory_amount, headless, extra_opts, two_drvs): self.controller_class = controller self.architecture = architecture self.vm_config = vm_config @@ -46,16 +46,18 @@ def __init__(self, controller, architecture, vm_config, boot_image, disk_image, self.memory_amount = memory_amount self.headless = headless self.extra_options = extra_opts + self.two_drvs = two_drvs self.instances = {} self.last = None def create(self, name): if name in self.instances: raise Exception("Duplicate machine name {}.".format(name)) - self.instances[name] = self.controller_class(self.architecture, name, self.vm_config, self.boot_image, self.disk_image) + self.instances[name] = self.controller_class(self.architecture, name, self.vm_config, self.boot_image, self.disk_image, self.two_drvs) self.instances[name].memory = self.memory_amount self.instances[name].is_headless = self.headless self.instances[name].extra_options = self.extra_options + self.instances[name].two_drvs = self.two_drvs self.last = name return self.instances[name] diff --git a/htest/vm/qemu.py b/htest/vm/qemu.py index affa9b4..fa5d6a3 100755 --- a/htest/vm/qemu.py +++ b/htest/vm/qemu.py @@ -82,13 +82,14 @@ class QemuVMController(VMController): 'ocr.sed' ) - def __init__(self, arch, name, config_ignored, boot_image, disk_image): + def __init__(self, arch, name, config_ignored, boot_image, disk_image, two_drvs): VMController.__init__(self, 'QEMU-' + arch) self.arch = arch self.booted = False self.name = name self.boot_image = boot_image self.disk_image = disk_image + self.two_drvs = two_drvs def is_supported(arch): return arch in QemuVMController.config @@ -136,6 +137,10 @@ def boot(self, **kwargs): elif opt == '{MEMORY}': opt = '{}'.format(self.memory) cmd.append(opt) + if self.two_drvs: + cmd += ['-device', 'ne2k_isa,irq=5,netdev=n2', '-netdev', 'user,id=n2,net=192.168.76.0/24'] + cmd += ['-device', 'e1000,netdev=n1', '-netdev', 'user,id=n1'] + if self.disk_image is not None: cmd.append('-drive') cmd.append('file={},index=0,media=disk,format=raw'.format(self.disk_image)) @@ -148,6 +153,7 @@ def boot(self, **kwargs): cmd.append(opt) self.logger.debug("Starting QEMU: {}".format(format_command(cmd))) + self.proc = subprocess.Popen(cmd) self.monitor = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) for xxx in retries(timeout=30, interval=2, name="ctl-socket", message="Failed to connect to QEMU control socket."): @@ -162,6 +168,7 @@ def boot(self, **kwargs): raise Exception("QEMU not started, aborting.") self.booted = True + #self.logger.info(cmd) self.logger.info("Machine started.") # Skip past GRUB diff --git a/scenarios/pcapctl/pcapctl_append_writer_ops.yml b/scenarios/pcapctl/pcapctl_append_writer_ops.yml new file mode 100644 index 0000000..cae4f7b --- /dev/null +++ b/scenarios/pcapctl/pcapctl_append_writer_ops.yml @@ -0,0 +1,40 @@ +meta: + name: "pcapctl dumping with standard writer_ops and then with append to the same file." +harbours: [] +tasks: + - boot + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 0." + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "332" + - name: Stopping dumping. + command: + args: "pcapctl --stop --device=0" + assert: "Stop dumping on device - 0." + - name: Ping 8.8.8.8 again, file /tmp/data.pcap should not change. + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: " ls -e /tmp" + assert: "332" + - name: Start dumping with differente writer ops + command: + args: "pcapctl --start --device=0 --ops=2 --force --outfile=/tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 2." + - name: Ping 8.8.8.8 again, sholud be dumped to /tmp/data.pcap but without header file. + command: + args: "ping 8.8.8.8" + - name: Assert size of file is 332B + request/answer to ping (which is 484). + command: + args: " ls -e /tmp" + assert: "484" + - name: Stop dumping. + command: + args: "pcapctl --stop --device=0" + assert: "Stop dumping on device - 0." diff --git a/scenarios/pcapctl/pcapctl_default.yml b/scenarios/pcapctl/pcapctl_default.yml new file mode 100644 index 0000000..3051680 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_default.yml @@ -0,0 +1,30 @@ +meta: + name: "pcapctl starting/stopping without specifying ops and device, must use default." + harbours: [] + +tasks: + - boot + - name: Starting the dumping to file data.pcap + command: + args: "pcapctl -r -o /tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 0." + - name: Checking the file was created. + command: + args: "ls /tmp" + assert: "data.pcap" + - name: Ping 8.8.8.8 must go to file + command: "ping 8.8.8.8" + - name: Checking file has right size + command: + args: " ls -e /tmp" + assert: "332" + - name: Stopping the dumping. + command: + args: "pcapctl -t" + assert: "Stop dumping on device - 0." + - name: Ping 8.8.8.8 again, file should not change + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: " ls -e /tmp" + assert: "332" \ No newline at end of file diff --git a/scenarios/pcapctl/pcapctl_force_flag.yml b/scenarios/pcapctl/pcapctl_force_flag.yml new file mode 100644 index 0000000..5822488 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_force_flag.yml @@ -0,0 +1,38 @@ +meta: + name: "pcapctl trying start dumping to already existing file." + harbours: [] +tasks: + - boot + - name: Create empty file. + command: + args: "mkfile /tmp/data.pcap" + - name: Assert file exists. + command: + args: "ls /tmp" + assert: "data.pcap" + - name: Assert file is empty. + command: + args: " ls -e /tmp" + assert: "0" + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data.pcap" + assert: "File /tmp/data.pcap already exists. If you want to overwrite it, then use flag -" + - name: Start dumping with force flag. + command: + args: "pcapctl --start --device=0 --ops=0 --force --outfile=/tmp/data.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "332" + - name: Stopping dumping. + command: + args: "pcapctl -t -d 0" + - name: Ping 8.8.8.8 again, file /tmp/data.pcap should not change. + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: " ls -e /tmp" + assert: "332" diff --git a/scenarios/pcapctl/pcapctl_list.yml b/scenarios/pcapctl/pcapctl_list.yml new file mode 100644 index 0000000..4b22f28 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_list.yml @@ -0,0 +1,12 @@ +meta: + name: "pcapctl list devices" + harbours: [] + +tasks: + - boot + - name: List accessible devices. + command: + args: "pcapctl --list" + assert: "Devices:" + - name: List inetd addrs + command: "inet list-addr" \ No newline at end of file diff --git a/scenarios/pcapctl/pcapctl_short_ops.yml b/scenarios/pcapctl/pcapctl_short_ops.yml new file mode 100644 index 0000000..453b957 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_short_ops.yml @@ -0,0 +1,30 @@ +meta: + name: "pcapctl short ops ping 8.8.8.8" + harbours: [] + +tasks: + - boot + - name: Starting the dumping to file data.pcap + command: + args: "pcapctl -r -d 0 -p 0 -o /tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 0." + - name: Checking the file was created. + command: + args: "ls /tmp" + assert: "data.pcap" + - name: Ping 8.8.8.8 must go to file + command: "ping 8.8.8.8" + - name: Checking file has right size + command: + args: " ls -e /tmp" + assert: "332" + - name: Stopping the dumping. + command: + args: "pcapctl -t -d 0" + assert: "Stop dumping on device - 0." + - name: Ping 8.8.8.8 again, file should not change + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: " ls -e /tmp" + assert: "332" \ No newline at end of file diff --git a/scenarios/pcapctl/pcapctl_short_writer_ops.yml b/scenarios/pcapctl/pcapctl_short_writer_ops.yml new file mode 100644 index 0000000..b8bdbdf --- /dev/null +++ b/scenarios/pcapctl/pcapctl_short_writer_ops.yml @@ -0,0 +1,25 @@ +meta: + name: "pcapctl dumping with short_writer_ops" + harbours: [] +tasks: + - boot + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl --start --device=0 --ops=1 --outfile=/tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 1." + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 328B + command: + args: " ls -e /tmp" + assert: "328" + - name: Stopping dumping. + command: + args: "pcapctl --stop --device=0" + assert: "Stop dumping on device - 0." + - name: Ping 8.8.8.8 again, file /tmp/data.pcap should not change. + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: " ls -e /tmp" + assert: "328" diff --git a/scenarios/pcapctl/pcapctl_two_drvs.yml b/scenarios/pcapctl/pcapctl_two_drvs.yml new file mode 100644 index 0000000..f2cac99 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_two_drvs.yml @@ -0,0 +1,41 @@ +meta: + name: "pcapctl dump on two drivers. Ping for one driver (with address 192....) and dnsres for device (with address 10...)." + harbours: [] + +tasks: + - boot + - name: List accessible devices. + command: + args: "pcapctl --list" + - name: List addresses. + command: "inet list-addr" + + - name: Start dumping on 1. device. + command: + args: "pcapctl --start --device=1 --ops=0 --outfile=/tmp/data1.pcap" + assert: "Start dumping on device - 1, ops - 0." + - name: Start dumping on device 0. + command: + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data0.pcap" + assert: "Start dumping on device - 0, ops - 0." + + - name: Ping 8.8.8.8. + command: "ping 8.8.8.8" + - name: DNS resolve www.google.com + command: " dnsres www.google.com" + + + - name: Stop dumping on 1. device. + command: + args: "pcapctl --stop --device=1" + assert: "Stop dumping on device - 1." + - name: Stop dumping on 0. device. + command: + args: "pcapctl --stop --device=0" + assert: "Stop dumping on device - 0." + + - name: Assert file sizes. + command: + args: " ls -e /tmp" + assert: "636" + assert: "332" diff --git a/scenarios/pcapctl/pcapctl_two_files.yml b/scenarios/pcapctl/pcapctl_two_files.yml new file mode 100644 index 0000000..179b3d8 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_two_files.yml @@ -0,0 +1,43 @@ +meta: + name: "pcapctl trying second file while dumping (for the same device)" + harbours: [] +tasks: + - boot + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data.pcap" + - name: Checking the file was created. + command: + args: "ls /tmp" + assert: "data.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "332" + - name: Trying to start dumping to second file without closing first. New File must not be created and dumping to first file must not be impacted in any way. + command: + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data2.pcap" + assert: "Starting the dumping was not successful." + - name: Checking there is only one file in /tmp. + command: + args: "ls /tmp" + assert: "data.pcap" + negassert: "data2.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking /tmp/data.pcap has size 484. + command: + args: " ls -e /tmp" + assert: "484" + - name: Stopping dumping. + command: + args: "pcapctl --stop --device=0" + - name: Ping 8.8.8.8 again, file /tmp/data.pcap should not change. + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: " ls -e /tmp" + assert: "484" + diff --git a/scenarios/pcapctl/pcapctl_two_files_ok.yml b/scenarios/pcapctl/pcapctl_two_files_ok.yml new file mode 100644 index 0000000..fa3b8d8 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_two_files_ok.yml @@ -0,0 +1,46 @@ +meta: + name: "pcapctl trying second file after dumping to first was stopped (for the same device). First file must stay the same." + harbours: [] +tasks: + - boot + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data.pcap" + - name: Checking the file was created. + command: + args: "ls /tmp" + assert: "data.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "332" + - name: Stopping dumping. + command: + args: "pcapctl --stop --device=0" + - name: Trying to start dumping to second file. New file must be created and dumping must go to the new file. + command: + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data2.pcap" + - name: Checking there are two files in /tmp. + command: + args: "ls /tmp" + assert: "data.pcap" + assert: "data2.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data2.pcap. + command: "ping 8.8.8.8" + - name: Checking /tmp/data2.pcap has size 176B and /tm/data.pcap has 332B. + command: + args: " ls -e /tmp" + assert: "332" + assert: "176" + - name: Stopping dumping. + command: + args: "pcapctl --stop --device=0" + - name: Ping 8.8.8.8 again, file /tmp/data.pcap and /tmp/data2.pcap should not change. + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: " ls -e /tmp" + assert: "332" + assert: "176" \ No newline at end of file diff --git a/scenarios/pcapctl/pcapctl_user_friendly.yml b/scenarios/pcapctl/pcapctl_user_friendly.yml new file mode 100644 index 0000000..da55f09 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_user_friendly.yml @@ -0,0 +1,55 @@ +meta: + name: "pcapctl trying long user friendly options for starting dumping." + harbours: [] +tasks: + - boot + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl --new /tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 0." + - name: Checking the file was created. + command: + args: "ls /tmp" + assert: "data.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "332" + - name: Stopping dumping. + command: + args: "pcapctl -t -d 0" + - name: Continue dumping to file /tmp/data.pcap. + command: + args: "pcapctl --append /tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 2." + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "484" + - name: Stopping dumping. + command: + args: "pcapctl -t -d 0" + - name: Remove /tmp/data.pcap + command: "rm /tmp/data.pcap" + - name: Start dumping to file /tmp/data2.pcap with short ops. + command: + args: "pcapctl --truncated /tmp/data2.pcap" + assert: "Start dumping on device - 0, ops - 1." + - name: Ping to 8.8.8.8 + command: + args: "ping 8.8.8.8" + - name: dns resolve www.googl.com + command: + args: " dnsres -4 www.google.com" + - name: Stop dumping. + command: + args: "pcapctl -t -d 0" + assert: "Stop dumping on device - 0." + - name: Assert /tmp/data2.pcap has size 480B. + command: + args: " ls -e /tmp" + assert: "480" \ No newline at end of file diff --git a/scenarios/pcapctl/pcapctl_user_friendly_short.yml b/scenarios/pcapctl/pcapctl_user_friendly_short.yml new file mode 100644 index 0000000..c754567 --- /dev/null +++ b/scenarios/pcapctl/pcapctl_user_friendly_short.yml @@ -0,0 +1,55 @@ +meta: + name: "pcapctl trying long user friendly options for starting dumping." + harbours: [] +tasks: + - boot + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl -N /tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 0." + - name: Checking the file was created. + command: + args: "ls /tmp" + assert: "data.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "332" + - name: Stopping dumping. + command: + args: "pcapctl -t -d 0" + - name: Continue dumping to file /tmp/data.pcap. + command: + args: "pcapctl -A /tmp/data.pcap" + assert: "Start dumping on device - 0, ops - 2." + - name: Ping 8.8.8.8 must go to /tmp/data.pcap. + command: "ping 8.8.8.8" + - name: Checking the file has size 332B + command: + args: " ls -e /tmp" + assert: "484" + - name: Stopping dumping. + command: + args: "pcapctl -t -d 0" + - name: Remove /tmp/data.pcap + command: "rm /tmp/data.pcap" + - name: Start dumping to file /tmp/data2.pcap with short ops. + command: + args: "pcapctl -T /tmp/data2.pcap" + assert: "Start dumping on device - 0, ops - 1." + - name: Ping to 8.8.8.8 + command: + args: "ping 8.8.8.8" + - name: dns resolve www.googl.com + command: + args: " dnsres -4 www.google.com" + - name: Stop dumping. + command: + args: "pcapctl -t -d 0" + assert: "Stop dumping on device - 0." + - name: Assert /tmp/data2.pcap has size 480B. + command: + args: " ls -e /tmp" + assert: "480" \ No newline at end of file diff --git a/test-in-vm.py b/test-in-vm.py index d2a0961..994a46e 100755 --- a/test-in-vm.py +++ b/test-in-vm.py @@ -122,7 +122,12 @@ action='store_true', help='Print debugging messages' ) - +args.add_argument('--two_network_drvs', + dest='two_drvs', + default=False, + help='Specify if HelenOS will run with two network drivers e1000 and ne2k.', + action='store_true', +) config = args.parse_args() if config.debug: @@ -157,7 +162,7 @@ logger.error("Unsupported architecture {}.".format(config.architecture)) sys.exit(1) -vmm = VMManager(controller, config.architecture, config.vm_config, config.boot_image, config.disk_image, config.memory, config.headless, config.pass_thru_options) +vmm = VMManager(controller, config.architecture, config.vm_config, config.boot_image, config.disk_image, config.memory, config.headless, config.pass_thru_options, config.two_drvs) scenario_tasks = [] for t in scenario['tasks']: