Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions htest/vm/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]

Expand Down
9 changes: 8 additions & 1 deletion htest/vm/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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."):
Expand All @@ -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
Expand Down
40 changes: 40 additions & 0 deletions scenarios/pcapctl/pcapctl_append_writer_ops.yml
Original file line number Diff line number Diff line change
@@ -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."
30 changes: 30 additions & 0 deletions scenarios/pcapctl/pcapctl_default.yml
Original file line number Diff line number Diff line change
@@ -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"
38 changes: 38 additions & 0 deletions scenarios/pcapctl/pcapctl_force_flag.yml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 12 additions & 0 deletions scenarios/pcapctl/pcapctl_list.yml
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 30 additions & 0 deletions scenarios/pcapctl/pcapctl_short_ops.yml
Original file line number Diff line number Diff line change
@@ -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"
25 changes: 25 additions & 0 deletions scenarios/pcapctl/pcapctl_short_writer_ops.yml
Original file line number Diff line number Diff line change
@@ -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"
41 changes: 41 additions & 0 deletions scenarios/pcapctl/pcapctl_two_drvs.yml
Original file line number Diff line number Diff line change
@@ -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"
43 changes: 43 additions & 0 deletions scenarios/pcapctl/pcapctl_two_files.yml
Original file line number Diff line number Diff line change
@@ -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"

Loading