vbox: automated USB device pass-through test

Fixes #2129
This commit is contained in:
Christian Prochaska 2016-10-12 17:55:32 +02:00 committed by Christian Helmuth
parent b41b001003
commit d9c6f46fe5
2 changed files with 441 additions and 0 deletions

View File

@ -0,0 +1,278 @@
#
# This run script tests the VirtualBox USB device pass-through feature
# by running the 'usb_hid' test in a VM.
#
# See 'usb_hid.run' for more information about the setup of the 'Pro Micro' USB
# device for automated testing.
#
# Note: the USB device(s) to be passed through must be included in the whitelist.
#
if { [have_include "power_on/qemu"] || ![have_spec nova] } {
puts "Run script is only supported on NOVA on real hardware"
exit 0
}
set build_components {
core init
drivers/framebuffer
drivers/input
drivers/timer
drivers/usb
server/log_terminal
server/fs_rom
server/ram_fs
server/report_rom
app/usb_report_filter
virtualbox
}
source ${genode_dir}/repos/base/run/platform_drv.inc
# override defaults of platform_drv.inc
proc platform_drv_priority {} { return { priority="-1"} }
append_platform_drv_build_components
build $build_components
create_boot_directory
set config {
<config prio_levels="4">
<parent-provides>
<service name="ROM"/>
<service name="RAM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
}
append_platform_drv_config
append config {
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>
<start name="ps2_drv" priority="-1">
<resource name="RAM" quantum="1M"/>
<provides><service name="Input"/></provides>
</start>
<start name="usb_config_fs" priority="-1">
<binary name="ram_fs"/>
<resource name="RAM" quantum="1M"/>
<provides><service name="File_system"/></provides>
<config verbose="yes">
<content>
<inline name="usb_drv.config">
<config uhci="yes" ehci="yes" xhci="yes">
<raw>
<report devices="yes"/>
</raw>
</config>
</inline>
<inline name="usb_report_filter.config">
<config>
<!-- USB device whitelist -->
<client label="virtualbox"/>
<device vendor_id="0x03eb" product_id="0x204d"/> <!-- 'Pro Micro' test device -->
</config>
</inline>
</content>
<policy label_prefix="usb_report_filter" root="/" writeable="yes" />
<policy label_prefix="usb_config_rom" root="/"/>
</config>
</start>
<start name="usb_config_rom" priority="-1">
<binary name="fs_rom"/>
<resource name="RAM" quantum="1200K"/>
<provides><service name="ROM"/></provides>
<route>
<service name="File_system"><child name="usb_config_fs"/></service>
<any-service><parent/><any-child/></any-service>
</route>
</start>
<start name="usb_report_filter" priority="-1">
<resource name="RAM" quantum="1200K"/>
<configfile name="usb_report_filter.config"/>
<route>
<service name="Report"><child name="report_rom" /></service>
<service name="ROM" label="usb_report_filter.config">
<child name="usb_config_rom"/>
</service>
<service name="ROM" label="devices">
<child name="report_rom"/>
</service>
<service name="ROM" label="usb_drv_config">
<child name="report_rom"/>
</service>
<service name="File_system" label="usb_drv.config">
<child name="usb_config_fs"/>
</service>
<any-service><parent/><any-child /></any-service>
</route>
</start>
<start name="usb_drv" priority="-1">
<resource name="RAM" quantum="16M"/>
<provides><service name="Usb"/></provides>
<configfile name="usb_drv.config"/>
<route>
<service name="IRQ"><child name="acpi_drv" /></service>
<service name="Report"> <child name="report_rom" /> </service>
<service name="ROM" label="usb_drv.config"><child name="usb_config_rom"/></service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="fb_drv" priority="-1">
<resource name="RAM" quantum="4M"/>
<provides><service name="Framebuffer"/></provides>
</start>
<start name="log_terminal" priority="-1">
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Terminal"/>
</provides>
</start>
<start name="report_rom" priority="-1">
<resource name="RAM" quantum="1M"/>
<provides> <service name="Report"/> <service name="ROM"/> </provides>
<config>
<rom>
<policy label="usb_report_filter -> devices" report="usb_drv -> devices"/>
<policy label="usb_report_filter -> usb_drv_config" report="usb_drv -> config"/>
<policy label="virtualbox -> usb_devices" report="usb_report_filter -> usb_devices"/>
</rom>
</config>
</start>
<start name="virtualbox" priority="-2">
<resource name="RAM" quantum="448M"/>
<config vbox_file="vm_genode_usb_hid.vbox" vm_name="TestVM" xhci="yes" force_ioapic="yes">
<libc stdout="/dev/log" stderr="/dev/log">
<vfs>
<dir name="dev"> <log/> </dir>
<dir name="dev"> <terminal/> </dir>
<rom name="vm_genode_usb_hid.vbox" />
<rom name="usb_hid.iso" />
</vfs>
</libc>
</config>
<route>
<service name="Report"><child name="report_rom" /></service>
<service name="ROM">
<if-arg key="label" value="usb_devices"/> <child name="report_rom"/>
</service>
<any-service> <parent/> <any-child /> </any-service>
</route>
</start>
</config>
}
install_config $config
puts "--- executing the 'usb_hid' run script to generate the 'usb_hid.iso' image ---"
global specs
global repositories
exec -ignorestderr \
$::argv0 \
--genode-dir [genode_dir] \
--name usb_hid \
--specs "$specs" \
--repositories "$repositories" \
--cross-dev-prefix "[cross_dev_prefix]" \
--include boot_dir/nova \
--include image/iso \
--include [repository_contains /run/usb_hid.run]/run/usb_hid.run
exec ln -sf ${genode_dir}/repos/ports/run/vm_genode_usb_hid.vbox bin/
exec ln -sf ../var/run/usb_hid.iso bin/
set boot_modules {
core
init
timer
fb_drv
ps2_drv
log_terminal
usb_drv
usb_report_filter
fs_rom
ram_fs
report_rom
virtualbox
usb_hid.iso
vm_genode_usb_hid.vbox
ld.lib.so libc.lib.so libm.lib.so pthread.lib.so libc_pipe.lib.so
libc_terminal.lib.so libiconv.lib.so stdcxx.lib.so
qemu-usb.lib.so
}
append_platform_drv_boot_modules
build_boot_image $boot_modules
if { ![get_cmd_switch --autopilot] } { run_genode_until forever }
# autopilot test
run_genode_until {\[init -\> log_terminal\] \[init -\> test-input\] Input event #1\t} 90
# remove everything before the first interesting line
regexp {(\[init -\> log_terminal\] \[init -\> test-input\] Input event #1\t.*)} $output all output
run_genode_until {.*\[init -\> test-input\] Input event #12.*\n} 60 [output_spawn_id]
unify_output { number [0-9]+} ""
unify_output {(?n)on usb-dummy.*$} ""
unify_output {(?n)using .*$} ""
unify_output {(?n)^.*__wait_event.*$} ""
unify_output {(?n)^.*Failed to submit URB.*$} ""
unify_output {(?n)^.*dev_warn.*$} ""
unify_output {(?n)^.*dangling allocation.*$} ""
unify_output { [0-9][0-9][0-9][0-9]:[0-9][0-9][0-9][0-9] } " "
filter_out_color_escape_sequences
trim_lines
compare_output_to {
[init -> log_terminal] [init -> test-input] Input event #1 type=PRESS code=45 rx=0 ry=0 ax=0 ay=0 key_cnt=1 KEY_X
[init -> log_terminal] [init -> test-input] Input event #2 type=RELEASE code=45 rx=0 ry=0 ax=0 ay=0 key_cnt=-1 KEY_X
[init -> log_terminal] [init -> test-input] Input event #3 type=PRESS code=272 rx=0 ry=0 ax=0 ay=0 key_cnt=1 BTN_LEFT
[init -> log_terminal] [init -> test-input] Input event #4 type=MOTION code=0 rx=-1 ry=0 ax=0 ay=0 key_cnt=1
[init -> log_terminal] [init -> test-input] Input event #5 type=MOTION code=0 rx=0 ry=1 ax=0 ay=0 key_cnt=1
[init -> log_terminal] [init -> test-input] Input event #6 type=RELEASE code=272 rx=0 ry=0 ax=0 ay=0 key_cnt=-1 BTN_LEFT
[init -> usb_drv] dev_info: USB disconnect, device
[init -> log_terminal] [init -> usb_drv] dev_info: USB disconnect, device
[init -> usb_drv] dev_info: new full-speed USB device
[init -> virtualbox] Attach USB device (vendor=3eb, product=204d)
[init -> log_terminal] [init -> usb_drv] dev_info: new full-speed USB device
[init -> log_terminal] [init -> usb_drv] dev_info: D L
[init -> log_terminal] [init -> usb_drv] dev_info: input: USB HID v1.11 Keyboard [D L]
[init -> log_terminal] [init -> usb_drv] dev_info: D L
[init -> log_terminal] [init -> usb_drv] dev_info: input: USB HID v1.11 Mouse [D L]
[init -> log_terminal] [init -> test-input] Input event #7 type=PRESS code=45 rx=0 ry=0 ax=0 ay=0 key_cnt=1 KEY_X
[init -> log_terminal] [init -> test-input] Input event #8 type=RELEASE code=45 rx=0 ry=0 ax=0 ay=0 key_cnt=-1 KEY_X
[init -> log_terminal] [init -> test-input] Input event #9 type=PRESS code=272 rx=0 ry=0 ax=0 ay=0 key_cnt=1 BTN_LEFT
[init -> log_terminal] [init -> test-input] Input event #10 type=MOTION code=0 rx=-1 ry=0 ax=0 ay=0 key_cnt=1
[init -> log_terminal] [init -> test-input] Input event #11 type=MOTION code=0 rx=0 ry=1 ax=0 ay=0 key_cnt=1
[init -> log_terminal] [init -> test-input] Input event #12 type=RELEASE code=272 rx=0 ry=0 ax=0 ay=0 key_cnt=-1 BTN_LEFT
}

View File

@ -0,0 +1,163 @@
<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.innotek.de/VirtualBox-settings" version="1.14-linux">
<Machine uuid="{410f6221-6237-4833-b02c-a54000b7b190}" name="Genode" OSType="Other" snapshotFolder="Snapshots" lastStateChange="2014-10-30T13:26:17Z">
<MediaRegistry>
<HardDisks/>
<DVDImages>
<Image uuid="{81763434-9a51-49e8-9444-528a5a28c4bc}" location="usb_hid.iso"/>
</DVDImages>
<FloppyImages/>
</MediaRegistry>
<ExtraData>
<ExtraDataItem name="GUI/LastGuestSizeHint" value="720,400"/>
<ExtraDataItem name="GUI/LastNormalWindowPosition" value="513,100,720,422"/>
</ExtraData>
<Hardware version="2">
<CPU count="1" hotplug="false">
<HardwareVirtEx enabled="true"/>
<HardwareVirtExNestedPaging enabled="true"/>
<HardwareVirtExVPID enabled="true"/>
<HardwareVirtExUX enabled="false"/>
<PAE enabled="true"/>
<LongMode enabled="true"/>
<HardwareVirtExLargePages enabled="false"/>
<HardwareVirtForce enabled="false"/>
</CPU>
<Memory RAMSize="256" PageFusion="false"/>
<HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
<HPET enabled="false"/>
<Chipset type="PIIX3"/>
<Boot>
<Order position="1" device="Floppy"/>
<Order position="2" device="DVD"/>
<Order position="3" device="HardDisk"/>
<Order position="4" device="None"/>
</Boot>
<Display VRAMSize="12" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
<VideoCapture enabled="false" screens="18446744073709551615" horzRes="1024" vertRes="768" rate="512" fps="25"/>
<RemoteDisplay enabled="false" authType="Null" authTimeout="5000"/>
<BIOS>
<ACPI enabled="true"/>
<IOAPIC enabled="true"/>
<Logo fadeIn="true" fadeOut="true" displayTime="0"/>
<BootMenu mode="MessageAndMenu"/>
<TimeOffset value="0"/>
<PXEDebug enabled="false"/>
</BIOS>
<USB>
<Controllers>
<Controller name="OHCI" type="OHCI"/>
</Controllers>
<DeviceFilters/>
</USB>
<Network>
<Adapter slot="0" enabled="false" MACAddress="08002785385E" cable="true" speed="0" type="82540EM">
<DisabledModes>
<InternalNetwork name="intnet"/>
<NATNetwork name="NatNetwork"/>
</DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</Adapter>
<Adapter slot="1" enabled="false" MACAddress="0800273AD0BB" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="2" enabled="false" MACAddress="0800270786C1" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="3" enabled="false" MACAddress="0800279B9C1E" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="4" enabled="false" MACAddress="080027B94C18" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="5" enabled="false" MACAddress="080027E38E65" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="6" enabled="false" MACAddress="0800275A8627" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="7" enabled="false" MACAddress="0800271CE60A" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
</Network>
<UART>
<Port slot="0" enabled="true" IOBase="0x3f8" IRQ="4" path="/dev/terminal" hostMode="HostDevice"/>
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
</UART>
<LPT>
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
</LPT>
<AudioAdapter controller="AC97" driver="Pulse" enabled="false"/>
<RTC localOrUTC="UTC"/>
<SharedFolders/>
<Clipboard mode="Disabled"/>
<DragAndDrop mode="Disabled"/>
<IO>
<IoCache enabled="true" size="5"/>
<BandwidthGroups/>
</IO>
<HostPci>
<Devices/>
</HostPci>
<EmulatedUSB>
<CardReader enabled="false"/>
</EmulatedUSB>
<Guest memoryBalloonSize="0"/>
<GuestProperties>
<GuestProperty name="/VirtualBox/HostInfo/GUI/LanguageID" value="en_US" timestamp="1414675524029545000" flags=""/>
</GuestProperties>
</Hardware>
<StorageControllers>
<StorageController name="IDE" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
<AttachedDevice passthrough="false" tempeject="true" type="DVD" port="1" device="0">
<Image uuid="{81763434-9a51-49e8-9444-528a5a28c4bc}"/>
</AttachedDevice>
</StorageController>
</StorageControllers>
</Machine>
</VirtualBox>