#
# USB HID test
#
# Test connect and disconnect on Qemu
assert_spec x86
if {[have_spec linux]} {
puts "Run script does not support Linux."
exit 0
}
if {![have_include "power_on/qemu"]} {
puts "Test requires to be run on Qemu."
exit 0
}
create_boot_directory
import_from_depot [depot_user]/src/[base_src] \
[depot_user]/pkg/test_usb_host_drv-[board] \
[depot_user]/src/dynamic_rom \
[depot_user]/src/report_rom \
[depot_user]/src/usb_hid_drv \
[depot_user]/src/init
build { server/event_dump }
install_config {
}
#
# Define USB host controller config
#
set fd [open [run_dir]/genode/usb_host_drv.config w]
puts $fd {
}
close $fd
build_boot_image [build_artifacts]
append qemu_args " -device nec-usb-xhci,id=xhci -device usb-kbd,bus=xhci.0 -nographic"
# wait for keyboard
run_genode_until {.*USB HID.*Keyboard.*} 60
set spawn_id $qemu_spawn_id
# send Ctrl-a+c to enter Qemu's monitor mode
send "\x01\x63"
# wait for monitor to become ready
run_genode_until {(qemu)} 20 $spawn_id
for {set i 0} {$i < 50} {incr i} {
# connect keyboard
send "device_add usb-kbd,id=ukb1\n"
# wait for keyboard
run_genode_until {.*USB HID.*Keyboard.*\n} 10 $spawn_id
# disconnect keyboard
send "device_del ukb1\n"
# wait for disconnect
run_genode_until {.*USB disconnect.*\n} 10 $spawn_id
}
puts "\nTest succeeded\n"