Skip to content

Test-runner device and USB axes, and a Drivers test suite - #3259

Closed
valentinbreiz wants to merge 5 commits into
feature/driver-kit-boot-ownersfrom
feature/driver-kit-test-axes
Closed

valentinbreiz wants to merge 5 commits into
feature/driver-kit-boot-ownersfrom
feature/driver-kit-test-axes

Conversation

@valentinbreiz

Copy link
Copy Markdown
Member

Stacked on #3258 (base feature/driver-kit-boot-owners), itself on #3257. Retarget to gen3 once those merge.

Third step towards letting a user kernel register its own PCI and USB drivers. It adds no kernel code. It teaches the test runner to attach hardware that no built-in driver claims, and adds a Drivers test suite that the driver-engine PRs build on. The only src/ changes are in the QEMU launcher shared with the cosmos tool, and one temporary InternalsVisibleTo line in HAL for the new suite.

Problem

The driver-engine cells need hardware that is on the bus but that no built-in driver takes: QEMU's edu test device, an RTL8139 NIC, an e1000e on ARM64 (the E1000E built-in is x64-only), and a USB mouse. The runner could not express any of these.

  • Fixed axes only. A profile could list disks (ahci, nvme or usb), one nic, a keyboard, a mouse, a VGA backend and a GPU. There was no way to add an arbitrary PCI device such as edu.
  • No xHCI without a USB stick. qemu-xhci was emitted only inside the USB-disk branch of QemuLauncher. "mouse": "usb-mouse" emitted a bare -device usb-mouse, and ARM64 virt has no USB bus of its own, so QEMU refused to start.
  • No suite for driver binding. No kernel checked that such hardware is enumerated and left unowned, which is the precondition for a user driver binding it.

Fix

Two new profile axes (tests/profiles.json, TestProfile, ProfileDeviceModels, QemuLauncher):

Axis Accepts Emits
"devices" edu, rtl8139, e1000e -device <model>. A NIC model gets its own user-mode netdev (devnet<n>) through the existing AppendNetworkCardArgs, and, like "nic", drops QEMU's default NIC.
"usb" usb-mouse, usb-kbd One qemu-xhci,id=usbxhci0 and -device <model>,bus=usbxhci0.0 per entry. A profile that also has a USB disk shares that one controller, so the hot-plug path keeps its QEMU ids.
  • Both lists are checked when the catalog loads, against an allow-list: an unknown model, a blank or duplicate entry, an empty list, or a model already attached by a fixed axis (nic, keyboard, mouse, gpu) fails the load with the profile and axis named, rather than failing QEMU at run time.
  • There is no per-arch column: QEMU 10.2.2's q35 and virt accept every listed model. A profile that only makes sense on one arch uses the existing "architectures" filter.
  • Existing profiles emit exactly the same arguments as before.
  • The catalog header comment and testing.md document both axes.

Cosmos.Kernel.Tests.Drivers (new suite):

  • Profiles: edu, rtl8139, e1000e-arm64 and usb-mouse, composed with the gicv2/gicv3 modifiers on ARM64. That gives 3 cells on x64 and 12 on ARM64.
  • 7 tests per cell:
    • Profile_Recognized;
    • Pci_ProfileFunctionEnumeratedOnce, Pci_ProfileFunctionClassMatches, Pci_ProfileFunctionUnowned;
    • Usb_XhciOwnedByXhci, Usb_MouseEnumeratedOnce, Usb_MouseInterfaceUnbound.
  • The hardware a cell presents is read from the profile name on the kernel command line, so a device that failed to enumerate fails its cell instead of skipping it.
  • A temporary InternalsVisibleTo from HAL lets it read PCI owners and USB interfaces until the kit's public seam lands.

CI. kernel-tests.yml runs the suite on x64 and ARM64.

Verification

Build. make setup: 0 errors.

Host tests.

  • Cosmos.Tests.Patcher: 138 passed, 0 failed.
    • Loader tests cover both axes: parsing, every validation error, the generated arguments, one shared controller with a USB disk.
    • Catalog tests cover the new profiles.
  • Cosmos.Tests.Tools: 37 passed, 0 failed.

QEMU arguments. A harness built the argument line for every existing suite, profile and modifier combination, with the old and the new launcher. The 128 existing combinations are byte-identical; the 30 differences are all new Drivers cells.

Test suites, QEMU (JUnit tests / failed / skipped):

Suite x64 arm64
Drivers 21 / 0 / 9 (3 cells) 84 / 0 / 36 (12 cells)
Storage (all profiles) 450 / 0 / 46 same as #3258

Real hardware. The runs above are QEMU only. No kernel code changes.

Known gaps.

  • kernel-tests does not trigger on a change to tests/profiles.json alone.
  • A modifier's machineOptions silently replace the profile's own. No current profile sets both.
  • The CI summary has no "Virtio" row. This was already the case before this PR.
  • The design notes named the controller xhci; this reuses the existing usbxhci0 id so the USB-disk hot-plug path keeps its ids.

Profiles had fixed axes only, so a suite could not boot QEMU with a
device no built-in driver handles: no edu or rtl8139, and no USB
device without a USB stick, since qemu-xhci was only emitted alongside
one. On ARM64 virt, which has no USB bus of its own, a bare
"mouse": "usb-mouse" even stops QEMU from starting.

- "devices": ["edu", "rtl8139", "e1000e"] adds one -device per model.
  A NIC model gets its own user netdev (devnet0, devnet1, ...) through
  the existing AppendNetworkCardArgs, so it never collides with net0.
- "usb": ["usb-mouse", "usb-kbd"] adds one qemu-xhci controller and
  puts each device on its bus, on x64 and ARM64. A profile that also
  has a USB stick shares that controller, and the stick keeps its ids
  (usbxhci0, usbdisk0, usbstick0), so QemuHotPlug works unchanged.

Both lists are checked against an allow-list when the catalog loads,
so a typo, a duplicate, an empty list or a model another axis already
attaches fails on the host instead of in QEMU. Every listed model is
accepted by both q35 and virt. Existing profiles emit the same
arguments as before.
The loader tests cover parsing both axes and every validation error
(unknown model, a model in the wrong axis, duplicates, conflicts with
nic/keyboard/mouse/gpu, empty lists, blank or non-string entries). The
launcher tests pin the exact arguments of a devices profile, a usb
profile, and a usb profile sharing its controller with a USB stick.
ProfileLaunchArgs builds those arguments through the same methods
BuildAsync uses, without resolving a QEMU binary or probing for KVM.
Cosmos.Kernel.Tests.Drivers boots hardware that the upcoming driver
kit's test drivers will bind: edu, rtl8139, e1000e on ARM64 (the
E1000E built-in is x64 only) and a USB mouse. Each profile runs bare
and with the gicv2 and gicv3 modifiers on ARM64: 3 cells on x64, 12
on ARM64.

Its 7 tests check what holds before any user driver exists: the
profile is one the suite knows, the profile's PCI function is
enumerated exactly once with the expected IDs and class and no owner,
and in the USB cell the xHCI function is owned by "xhci" and the HID
boot mouse interface is enumerated once with no class driver bound.

The suite reads HAL internals through a temporary InternalsVisibleTo
that goes away once the driver kit's public API lands. Catalog tests
pin each Drivers cell and its QEMU arguments, and the arguments of the
existing USB stick and virtio profiles.
Adds the Drivers suite to the kernel tests on x64 and ARM64, with its
results job and summary row, on the same timeouts as the Pci and
Virtio suites.
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Fat Tests

Cell x64 arm64
all ✅ 42/42 ✅ 42/42

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 File Tests

Cell x64 arm64
all ✅ 37/37 ✅ 37/37

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 GarbageCollector Tests

Cell x64 arm64
all ✅ 50/50 ✅ 50/50

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 HelloWorld Tests

Cell x64 arm64
all ✅ 3/3 ✅ 3/3

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Interrupts Tests

Cell x64 arm64
all ✅ 18/18 ✅ 31/54, 23 skip
bare ✅ 18/18 ⚠️ 8/18, 10 skip
bare+gicv2 n/a ✅ 10/18, 8 skip
bare+gicv3 n/a ✅ 13/18, 5 skip

Skipped

  • arm64: 23 skipped: no MSI routing in this cell (GICv2 has no ITS) (6), needs MSI routing and an MSI-X function no driver has enabled (arm64: virtio-net owns the only one) (6), self-IPI harness is x64-only (3), LAPIC MSI address contract is x64-only (3), LAPIC timer vector is x64-only (3), gic-version not pinned by this cell (2)

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Math Tests

Cell x64 arm64
all ✅ 30/30 ✅ 30/30

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Pci Tests

Cell x64 arm64
all ✅ 10/10 ✅ 9/10, 1 skip

Skipped

  • arm64: 1 skipped: no Intel Ethernet function on this machine (1)

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Power Tests

Cell x64 arm64
all ✅ 4/4 ✅ 4/4

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Runtime Tests

Cell x64 arm64
all ✅ 103/103 ✅ 103/103

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Storage Tests

Cell x64 arm64
all ✅ 434/480, 46 skip ⚠️ 683/1440, 757 skip
ahci ✅ 70/80, 10 skip ✅ 70/80, 10 skip
ahci+acpi-off ✅ 70/80, 10 skip ⚠️ 3/80, 77 skip
ahci+gicv2 n/a ✅ 70/80, 10 skip
ahci+gicv2+acpi-off n/a ⚠️ 3/80, 77 skip
ahci+gicv3 n/a ✅ 70/80, 10 skip
ahci+gicv3+acpi-off n/a ⚠️ 3/80, 77 skip
nvme ✅ 74/80, 6 skip ✅ 71/80, 9 skip
nvme+acpi-off ✅ 73/80, 7 skip ⚠️ 3/80, 77 skip
nvme+gicv2 n/a ✅ 72/80, 8 skip
nvme+gicv2+acpi-off n/a ⚠️ 3/80, 77 skip
nvme+gicv3 n/a ✅ 72/80, 8 skip
nvme+gicv3+acpi-off n/a ⚠️ 3/80, 77 skip
usb ✅ 76/80, 4 skip ✅ 76/80, 4 skip
usb+acpi-off ✅ 71/80, 9 skip ⚠️ 4/80, 76 skip
usb+gicv2 n/a ✅ 76/80, 4 skip
usb+gicv2+acpi-off n/a ⚠️ 4/80, 76 skip
usb+gicv3 n/a ✅ 76/80, 4 skip
usb+gicv3+acpi-off n/a ⚠️ 4/80, 76 skip

Skipped

  • x64: 46 skipped: not a USB profile (24), 64-bit BAR relocation probe is nvme-profile only (8), USB hot-plug thread not running (scheduler timer not ticking) (5), not an NVMe profile (4), NVMe controller API is nvme-profile only (4), acpi-off has no MSI routing to pin (1)
  • arm64: 757 skipped: no block device bound for partition-table tests (441), no block device bound for this profile (180), not a USB profile (72), x64 mapper cell; arm64 installs Device mappings via DeviceMapper (18), BAR relocation probe is x64-only (same harness as the mapper cell) (18), NVMe controller API is nvme-profile only (15), not an NVMe profile (12), interrupt mode not pinned by this cell (1)

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Threading Tests

Cell x64 arm64
all ✅ 78/78 ✅ 78/78

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Timer Tests

Cell x64 arm64
all ✅ 26/26 ✅ 20/20

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🧪 Virtio Tests

Cell x64 arm64
all ✅ 12/12 ✅ 19/24, 5 skip
virtio-mmio n/a ✅ 7/12, 5 skip
virtio-pci ✅ 12/12 ✅ 12/12

Skipped

  • arm64: 5 skipped: this cell presents virtio over MMIO (5)

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

Copy link
Copy Markdown

🧪 Graphic Tests

Cell x64 arm64
all ✅ 53/81, 28 skip ✅ 27/54, 27 skip
bare ⚠️ 13/27, 14 skip ⚠️ 13/27, 14 skip
virtio-gpu ✅ 14/27, 13 skip ✅ 14/27, 13 skip
vmware-svga ✅ 26/27, 1 skip n/a

Skipped

  • x64: 28 skipped: VMware SVGA II adapter not present, needs the vmware-svga profile (26), virtio-gpu not attached, needs the virtio-gpu profile (2)
  • arm64: 27 skipped: VMware SVGA II adapter not present, needs the vmware-svga profile (26), virtio-gpu not attached, needs the virtio-gpu profile (1)

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

Copy link
Copy Markdown

🧪 Memory Tests

Cell x64 arm64
all ✅ 71/71 ✅ 71/71

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

Copy link
Copy Markdown

🧪 Network Tests

Cell x64 arm64
all ✅ 48/48 ✅ 48/48
e1000e ✅ 24/24 n/a
virtio-net-mmio n/a ✅ 24/24
virtio-net-pci ✅ 24/24 ✅ 24/24

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

@github-actions

Copy link
Copy Markdown

🧪 TypeCasting Tests

Cell x64 arm64
all ✅ 17/17 ✅ 17/17

📎 Artifacts

Architecture Test Results UART Log Kernel ISO
x64 XML Log ISO
arm64 XML Log ISO

📋 View full test summary | 📄 Kernel.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant