Testing¶
scripts/run-all.sh # with ntbd
NTB_IMPL=qemu scripts/run-all.sh # with the QEMU device
NTB_IMPL=qemu scripts/run-all.sh netdev # only tests whose name contains "netdev"
run-all.sh builds what it needs, runs every test in fresh VMs and prints a
summary. It takes about four minutes. Logs of each test are kept in
out/run-all/<test>/.
The QEMU device has two memory window paths. The default run uses the fast
one (scripts/run-vm.sh sets fast-mw=on); run the suite once more with
FAST_MW=off to cover the message path.
Tests¶
| Test | What it checks |
|---|---|
p2-basic |
ntb_tool: link, spads, doorbells, both windows in both directions, a closed window reads as all ones |
p2-pingpong |
kernel ntb_pingpong |
p2-adversarial |
a window opened onto read-only ROM: the write is dropped and the device survives |
p3-netdev |
ntb_transport + ntb_netdev: ping and a 4 MiB integrity check with tcpblast |
p3-netdev-dma |
the same with use_dma=1 and 64 MiB |
p4-perf |
ntb_perf, CPU and DMA paths; a slow DMA path counts as a failure |
p5-selftest |
Linux's own ntb_test.sh in a one-VM loopback, plus a count of delivered ntb_msi interrupts |
p5-dma-adversarial |
tests/kmod/qntb_dmatest.ko: DMA error codes 1–8, HEAD rewind, closing a window during a copy, BAR0 access rules, translation checks, register latency during DMA; CPU writes through a window (rate and data), and four ways of closing the path while another CPU keeps writing (XLAT off, sender link down, target BME off, target reset): after the barrier read the target's memory must not change |
p5-db64 |
the same module with 64 doorbells: an 8-byte doorbell write raises one interrupt, two separate 32-bit writes raise two |
p5-selftest-fix |
the unmodified selftest fails with the kernel's ntb_tool and passes with the fixed one (an upstream regression) |
p5-ntb_tool-uaf |
the fix for an upstream ntb_tool crash on removal |
p5-dmaengine-client |
tests/kmod/qntb_dmaclient.ko: the driver's dmaengine error paths |
p5-reconnect |
B's QEMU is killed and started again: the link goes down and up, spads work |
p7-peer-stall |
B's QEMU is stopped with SIGSTOP: A notices within seconds, and the link returns after SIGCONT (QEMU device only) |
scripts/run-migration.sh checks that live migration is refused. It passes
with the QEMU device. With ntbd it fails by design: QEMU 11.1.3 does not
block migration for vfio-user devices (reported upstream, see
Upstream notes).
When a test fails¶
A test fails when:
- the guest test reports a failure or writes no result (a guest passes only
if its result file ends with
RESULT: 0 failures); - a VM times out;
ntbddies or exits with an error;- the guest kernel log shows a bug detector: lockdep, sleeping in atomic context, oops, panic, hung task, soft or hard lockup, RCU stall, UBSAN, KFENCE, KASAN, list corruption.
The guest kernel is built with lockdep, DEBUG_ATOMIC_SLEEP, the hung task
and lockup detectors, DMA_API_DEBUG, KFENCE and UBSAN. A separate KASAN
build (third_party/build/linux-kasan) is used for upstream bug reports.
Runners¶
| Script | Setup |
|---|---|
run-pair.sh |
two VMs, one end each |
run-single.sh |
one VM with both ends (loopback) |
run-reconnect.sh |
two VMs; B is killed and restarted |
run-stall.sh |
two VMs; B is stopped and continued |
run-mesh.sh <n> |
n VMs (2 to 6), an NTB link between every two |
Shared logic is in scripts/lib-harness.sh. A single test:
NTB_IMPL=qemu scripts/run-pair.sh tests/p2-basic.sh. The guests run the
test through qntb.autorun and synchronise through files in
out/share/sync. Logs go to out/logs/, results to
out/share/result-{a,b}.txt. P3_MIB and TRANSPORT_PARAMS are passed to
the p3 test. QNTB_OPTS (QEMU device) and NTBD_OPTS (ntbd) pass extra
device options, e.g. QNTB_OPTS=doorbells=64 NTBD_OPTS=--doorbells=64.
A mesh of VMs¶
scripts/run-mesh.sh 3 tests/m1-mesh.sh starts VMs a, b and c with a link
between every two: each VM gets one NTB device per peer, at consecutive PCI
slots in peer order, and out/share/mesh.txt lists every VM's peers in that
order. With the QEMU device the links are direct; with ntbd there is one
ntbd per link. MESH_NET=1 also joins the VMs on a virtio-net network
(UDP multicast on the host's loopback) for traffic that should not use the
links, such as a control plane. tests/m1-mesh.sh checks every link, the
scratchpads of every peer on the right device and that network. It passes
with both implementations, and with four VMs.
This is how an NTB switch with one device per peer, or a set of two-port NTB cards, looks to a node. ntb-lab runs its mesh tests (shared memory, pushseg, gridlane) on it.
Writing a test¶
A test is a shell script that runs in the guest with its name (a or b)
as $1. It writes PASS ... and FAIL ... lines to
/mnt/share/result-$1.txt and ends with RESULT: <n> failures. Copy one of
the p2 tests as a start, and add it to the CASES list in run-all.sh.