From 922fa10b60965a579818344cc97e41bc5527f0c7 Mon Sep 17 00:00:00 2001 From: Nataliia Korop Date: Sat, 24 Feb 2024 20:50:51 +0100 Subject: [PATCH 1/4] basic test, cant run --- scenarios/coast/pcapctl/basic.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scenarios/coast/pcapctl/basic.yml diff --git a/scenarios/coast/pcapctl/basic.yml b/scenarios/coast/pcapctl/basic.yml new file mode 100644 index 0000000..494ddf4 --- /dev/null +++ b/scenarios/coast/pcapctl/basic.yml @@ -0,0 +1,31 @@ +meta: + name: "pcapctl ping 8.8.8.8" + harbours: + - pcapctl + +tasks: + - boot + - name: Starting the dumping to file data.pcap + command: + args: "pcapctl start /tmp/data.pcap" + assert: "Using device: devices/\hw\sys\\00:03.0\\port0" + - 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 stop" + assert: "Using device: devices/\hw\sys\\00:03.0\\port0\nDumping was stopped" + - 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 From 6761bfda72119bf458236fc7ce626c013a4d6ff9 Mon Sep 17 00:00:00 2001 From: Nataliia Korop Date: Sun, 25 Feb 2024 11:36:33 +0100 Subject: [PATCH 2/4] 2nd test --- scenarios/{coast => }/pcapctl/basic.yml | 5 ++- scenarios/pcapctl/two_files.yml | 44 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) rename scenarios/{coast => }/pcapctl/basic.yml (95%) create mode 100644 scenarios/pcapctl/two_files.yml diff --git a/scenarios/coast/pcapctl/basic.yml b/scenarios/pcapctl/basic.yml similarity index 95% rename from scenarios/coast/pcapctl/basic.yml rename to scenarios/pcapctl/basic.yml index 494ddf4..409a100 100644 --- a/scenarios/coast/pcapctl/basic.yml +++ b/scenarios/pcapctl/basic.yml @@ -1,12 +1,11 @@ meta: name: "pcapctl ping 8.8.8.8" - harbours: - - pcapctl + harbours: [] tasks: - boot - name: Starting the dumping to file data.pcap - command: + command: args: "pcapctl start /tmp/data.pcap" assert: "Using device: devices/\hw\sys\\00:03.0\\port0" - name: Checking the file was created. diff --git a/scenarios/pcapctl/two_files.yml b/scenarios/pcapctl/two_files.yml new file mode 100644 index 0000000..cf75bc4 --- /dev/null +++ b/scenarios/pcapctl/two_files.yml @@ -0,0 +1,44 @@ +meta: + name: "pcapctl 2 files" + harbours: [] + +tasks: + - boot + - name: Starting the dumping to file data.pcap. + command: + args: "pcapctl start /tmp/data.pcap" + assert: "Using device: devices/\hw\sys\\00:03.0\\port0" + - 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: "ls -e /tmp" + assert: "332" + - name: Starting dumping again, must close and save /tmp/data.pcap and create new file. + command: + args: "pcaptl start /tmp/data2.pcap" + assert: "Using device: devices/\hw\sys\\00:03.0\\port0" + - name: Checking there are two files in /tmp. + command: + args: "ls /tmp" + assert: "data.pcap\ndata2.pcap" + - name: Ping 8.8.8.8 must go to /tmp/data2.pcap and /tmp/data.pcap should not change. + command: "ping 8.8.8.8" + - name: Checking /tmp/data2.pcap has size 176 and /tmp/data.pcap has size 332. + command: + args: "ls -e /tmp" + assert: "332\n176" + - name: Stopping dumping. + command: + args: "pcapctl stop" + assert: "Using device: devices/\hw\sys\\00:03.0\\port0\nDumping was stopped" + - name: Ping 8.8.8.8 again, files should not change + command: "ping 8.8.8.8" + - name: Checking file has the same size. + command: + args: "ls -e /tmp" + assert: "332\n176" + From d7ebd48519d85d8fa937258b1b33f6610eb47dea Mon Sep 17 00:00:00 2001 From: Nataliia Korop Date: Sat, 2 Mar 2024 20:10:49 +0100 Subject: [PATCH 3/4] basic and two_files pass OK --- scenarios/pcapctl/basic.yml | 19 ++++++++------- scenarios/pcapctl/two_files.yml | 43 ++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/scenarios/pcapctl/basic.yml b/scenarios/pcapctl/basic.yml index 409a100..606879a 100644 --- a/scenarios/pcapctl/basic.yml +++ b/scenarios/pcapctl/basic.yml @@ -7,7 +7,7 @@ tasks: - name: Starting the dumping to file data.pcap command: args: "pcapctl start /tmp/data.pcap" - assert: "Using device: devices/\hw\sys\\00:03.0\\port0" + assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" - name: Checking the file was created. command: args: "ls /tmp" @@ -15,16 +15,17 @@ tasks: - 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" + command: + args: " ls -e /tmp" + assert: "332" - name: Stopping the dumping. - command: - args: "pcapctl stop" - assert: "Using device: devices/\hw\sys\\00:03.0\\port0\nDumping was stopped" + command: + args: "pcapctl stop" + assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" + assert: "Dumping was stopped" - name: Ping 8.8.8.8 again, file should not change - command: "ping 8.8.8.8" + command: "ping 8.8.8.8" - name: Checking file has the same size. command: - args: "ls -e /tmp" + args: " ls -e /tmp" assert: "332" \ No newline at end of file diff --git a/scenarios/pcapctl/two_files.yml b/scenarios/pcapctl/two_files.yml index cf75bc4..317b40f 100644 --- a/scenarios/pcapctl/two_files.yml +++ b/scenarios/pcapctl/two_files.yml @@ -7,38 +7,43 @@ tasks: - name: Starting the dumping to file data.pcap. command: args: "pcapctl start /tmp/data.pcap" - assert: "Using device: devices/\hw\sys\\00:03.0\\port0" + assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" - 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" + command: "ping 8.8.8.8" - name: Checking the file has size 332B - command: "ls -e /tmp" + command: + args: " ls -e /tmp" assert: "332" - name: Starting dumping again, must close and save /tmp/data.pcap and create new file. - command: - args: "pcaptl start /tmp/data2.pcap" - assert: "Using device: devices/\hw\sys\\00:03.0\\port0" + command: + args: "pcapctl start /tmp/data2.pcap" + assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" - name: Checking there are two files in /tmp. - command: - args: "ls /tmp" - assert: "data.pcap\ndata2.pcap" + command: + args: "ls /tmp" + assert: "data.pcap" + assert: "data2.pcap" - name: Ping 8.8.8.8 must go to /tmp/data2.pcap and /tmp/data.pcap should not change. - command: "ping 8.8.8.8" + command: "ping 8.8.8.8" - name: Checking /tmp/data2.pcap has size 176 and /tmp/data.pcap has size 332. - command: - args: "ls -e /tmp" - assert: "332\n176" + command: + args: " ls -e /tmp" + assert: "332" + assert: "176" - name: Stopping dumping. - command: - args: "pcapctl stop" - assert: "Using device: devices/\hw\sys\\00:03.0\\port0\nDumping was stopped" + command: + args: "pcapctl stop" + assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" + assert: "Dumping was stopped" - name: Ping 8.8.8.8 again, files should not change - command: "ping 8.8.8.8" + command: "ping 8.8.8.8" - name: Checking file has the same size. command: - args: "ls -e /tmp" - assert: "332\n176" + args: " ls -e /tmp" + assert: "332" + assert: "176" From ecc269ca93057fa9dfc4e0882dfd1f3a3085ee94 Mon Sep 17 00:00:00 2001 From: Nataliia Korop Date: Tue, 12 Mar 2024 09:20:31 +0100 Subject: [PATCH 4/4] packet-capture: add scenarios, run HelenOS with 2 net drvs --- README.md | 2 + htest/vm/controller.py | 6 +- htest/vm/qemu.py | 9 ++- .../pcapctl/pcapctl_append_writer_ops.yml | 40 ++++++++++++++ .../{basic.yml => pcapctl_default.yml} | 11 ++-- scenarios/pcapctl/pcapctl_force_flag.yml | 38 +++++++++++++ scenarios/pcapctl/pcapctl_list.yml | 12 ++++ scenarios/pcapctl/pcapctl_short_ops.yml | 30 ++++++++++ .../pcapctl/pcapctl_short_writer_ops.yml | 25 +++++++++ scenarios/pcapctl/pcapctl_two_drvs.yml | 41 ++++++++++++++ scenarios/pcapctl/pcapctl_two_files.yml | 43 +++++++++++++++ ...two_files.yml => pcapctl_two_files_ok.yml} | 29 +++++----- scenarios/pcapctl/pcapctl_user_friendly.yml | 55 +++++++++++++++++++ .../pcapctl/pcapctl_user_friendly_short.yml | 55 +++++++++++++++++++ test-in-vm.py | 9 ++- 15 files changed, 378 insertions(+), 27 deletions(-) create mode 100644 scenarios/pcapctl/pcapctl_append_writer_ops.yml rename scenarios/pcapctl/{basic.yml => pcapctl_default.yml} (68%) create mode 100644 scenarios/pcapctl/pcapctl_force_flag.yml create mode 100644 scenarios/pcapctl/pcapctl_list.yml create mode 100644 scenarios/pcapctl/pcapctl_short_ops.yml create mode 100644 scenarios/pcapctl/pcapctl_short_writer_ops.yml create mode 100644 scenarios/pcapctl/pcapctl_two_drvs.yml create mode 100644 scenarios/pcapctl/pcapctl_two_files.yml rename scenarios/pcapctl/{two_files.yml => pcapctl_two_files_ok.yml} (51%) create mode 100644 scenarios/pcapctl/pcapctl_user_friendly.yml create mode 100644 scenarios/pcapctl/pcapctl_user_friendly_short.yml 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/basic.yml b/scenarios/pcapctl/pcapctl_default.yml similarity index 68% rename from scenarios/pcapctl/basic.yml rename to scenarios/pcapctl/pcapctl_default.yml index 606879a..3051680 100644 --- a/scenarios/pcapctl/basic.yml +++ b/scenarios/pcapctl/pcapctl_default.yml @@ -1,13 +1,13 @@ meta: - name: "pcapctl ping 8.8.8.8" + 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 start /tmp/data.pcap" - assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" + 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" @@ -20,9 +20,8 @@ tasks: assert: "332" - name: Stopping the dumping. command: - args: "pcapctl stop" - assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" - assert: "Dumping was stopped" + 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. 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/two_files.yml b/scenarios/pcapctl/pcapctl_two_files_ok.yml similarity index 51% rename from scenarios/pcapctl/two_files.yml rename to scenarios/pcapctl/pcapctl_two_files_ok.yml index 317b40f..fa3b8d8 100644 --- a/scenarios/pcapctl/two_files.yml +++ b/scenarios/pcapctl/pcapctl_two_files_ok.yml @@ -1,13 +1,11 @@ meta: - name: "pcapctl 2 files" + 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 /tmp/data.pcap" - assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" + args: "pcapctl --start --device=0 --ops=0 --outfile=/tmp/data.pcap" - name: Checking the file was created. command: args: "ls /tmp" @@ -15,35 +13,34 @@ tasks: - 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: + command: args: " ls -e /tmp" assert: "332" - - name: Starting dumping again, must close and save /tmp/data.pcap and create new file. + - name: Stopping dumping. command: - args: "pcapctl start /tmp/data2.pcap" - assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" + 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 and /tmp/data.pcap should not change. + - 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 176 and /tmp/data.pcap has size 332. + - 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" - assert: "Using device: devices\/\\hw\\sys\\00:03.0\\port0" - assert: "Dumping was stopped" - - name: Ping 8.8.8.8 again, files should not change + 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" - + 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']: