diff --git a/test/qemu_test.py b/test/qemu_test.py index 3af4112..3786022 100644 --- a/test/qemu_test.py +++ b/test/qemu_test.py @@ -1061,6 +1061,58 @@ CASES = [ "expect": r"(?s)(?=.*hub device slot \d+ disconnected)" r"(?=.*device-manager: reaping \S*usb-hid-keyboard[\s\S]*usb-hid-keyboard: ok)", "fail": r"DANOS-TEST-RESULT: FAIL"}, + # Hot-plug matrix H4 (docs/hot-plug-matrix-plan.md): replug on a DIFFERENT + # port. Registration identity is per-port, so a moved device is simply a new + # device: the old child is removed and its driver reaped; the new port's + # child gets a fresh id and a fresh driver. Nothing may tie a driver to the + # old port. The tail (reaping → hub slot N port 2 device → delegated → ok) + # is unambiguous: port 2 of the hub had nothing before the move. + {"name": "usb-replug-moved", + "build_case": "usb-hid", + "smp": 4, + "timeout": 150, + "qemu_extra": ["-device", "qemu-xhci,id=xhci2", + "-device", "usb-hub,bus=xhci2.0,port=1,id=mhub", + "-device", "usb-kbd,bus=xhci2.0,port=1.1,id=mkbd"], + "qmp_sequence": [ + {"delay": 8, "command": "device_del", "arguments": {"id": "mkbd"}}, + {"delay": 14, "command": "device_add", + "arguments": {"driver": "usb-kbd", "bus": "xhci2.0", "port": "1.2", "id": "mkbd2"}}, + ], + "expect": r"(?s)(?=.*device-manager: reaping \S*usb-hid-keyboard" + r"[\s\S]*hub slot \d+ port 2 device:" + r"[\s\S]*device-manager: delegated device \d+ to /system/drivers/usb-hid-keyboard" + r"[\s\S]*usb-hid-keyboard: ok)", + "fail": r"DANOS-TEST-RESULT: FAIL"}, + # Hot-plug matrix H5 (docs/hot-plug-matrix-plan.md): three unplug/replug + # cycles of the same keyboard on the same hub port. Each cycle must reap the + # old generation and bind a new one — three reaping lines, and a bind after + # the last — proving no state leaks across generations: xHCI slots, the + # bus's open table, and the manager's driver entries must all be reusable. + {"name": "usb-replug-cycles", + "build_case": "usb-hid", + "smp": 4, + "timeout": 150, + "qemu_extra": ["-device", "qemu-xhci,id=xhci2", + "-device", "usb-hub,bus=xhci2.0,port=1,id=chub", + "-device", "usb-kbd,bus=xhci2.0,port=1.1,id=ckbd0"], + "qmp_sequence": [ + {"delay": 8, "command": "device_del", "arguments": {"id": "ckbd0"}}, + {"delay": 12, "command": "device_add", + "arguments": {"driver": "usb-kbd", "bus": "xhci2.0", "port": "1.1", "id": "ckbd1"}}, + {"delay": 18, "command": "device_del", "arguments": {"id": "ckbd1"}}, + {"delay": 22, "command": "device_add", + "arguments": {"driver": "usb-kbd", "bus": "xhci2.0", "port": "1.1", "id": "ckbd2"}}, + {"delay": 28, "command": "device_del", "arguments": {"id": "ckbd2"}}, + {"delay": 32, "command": "device_add", + "arguments": {"driver": "usb-kbd", "bus": "xhci2.0", "port": "1.1", "id": "ckbd3"}}, + ], + "expect": r"(?s)(?=.*device-manager: reaping \S*usb-hid-keyboard" + r"[\s\S]*device-manager: reaping \S*usb-hid-keyboard" + r"[\s\S]*device-manager: reaping \S*usb-hid-keyboard" + r"[\s\S]*device-manager: delegated device \d+ to /system/drivers/usb-hid-keyboard" + r"[\s\S]*usb-hid-keyboard: ok)", + "fail": r"DANOS-TEST-RESULT: FAIL"}, # The kernel VFS root (M-F): the mount table serves the initrd at /system — # path resolution, node status/read (an ELF magic), and directory listing, # asserted kernel-side.