xref: /freebsd/tools/boot/boot-test.sh.8 (revision a7ebe2d436e5d2fabf223796f992683c17acf50f)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.Dd July 5, 2026
5.Dt BOOT-TEST.SH 8
6.Os
7.Sh NAME
8.Nm boot-test.sh
9.Nd automated boot loader regression tests under QEMU
10.Sh SYNOPSIS
11.Nm
12.Op Fl A
13.Op Fl a Ar arch
14.Op Fl b | Fl B
15.Op Fl j Ar jobs
16.Op Fl o Ar dir
17.Op Fl t Ar regex
18.Op Fl T Ar seconds
19.Nm
20.Fl -netboot-teardown
21.Sh DESCRIPTION
22.Nm
23builds a minimal bootable tree, assembles disk, CD, and network boot images
24for every boot configuration a target architecture supports, boots each image
25under
26.Xr qemu 1 ,
27and checks that it reaches userland and prints a success marker.
28It runs almost entirely as an unprivileged user, with one exception: the
29.Ar netboot-bios
30and
31.Ar netboot-efi
32tests need a real
33.Xr vmnet 4
34interface and
35.Xr dnsmasq 8
36instead of QEMU's user-mode networking, so that DHCP can hand out a
37root-path.
38Creating the interface and giving it an address require root, so
39.Nm
40runs
41.Xr sudo 8
42once to set both up, then leaves them running; later runs detect the
43existing setup and do not prompt again.
44See
45.Sx Netboot networking
46below.
47.Pp
48.Nm
49must be run from the
50.Pa stand
51directory of a FreeBSD source tree and assumes that
52.Cm buildworld
53and
54.Cm buildkernel
55have already completed for each target architecture.
56Per-architecture parameters
57.Pq QEMU machine, boot capabilities, kernel config, and so on
58are read from
59.Pa boot-test.json
60in the same directory as the script.
61.Pp
62Each architecture is processed in five phases:
63extract a minimal userland from a release ISO
64.Pq 0 ,
65install the kernel and boot loaders into a tree
66.Pq 1 ,
67create the base filesystem images
68.Pq 2 ,
69assemble the per-configuration boot images and register a test for each
70.Pq 3 ,
71and run the registered tests
72.Pq 4 .
73Images are built one architecture at a time; the tests for all selected
74architectures then run in parallel so that a run costs roughly one timeout
75rather than one per test.
76.Pp
77The options are as follows:
78.Bl -tag -width indent
79.It Fl a Ar arch
80Test
81.Ar arch .
82May be given more than once to test several.
83The default is the host architecture reported by
84.Nm uname Fl p .
85Supported values are
86.Ar amd64 ,
87.Ar aarch64 ,
88.Ar armv7 ,
89.Ar riscv64 ,
90.Ar powerpc ,
91.Ar powerpc64 ,
92and
93.Ar powerpc64le .
94.It Fl A
95Test every supported architecture.
96.It Fl b
97Skip the build and install phase and reuse the existing boot tree.
98.It Fl B
99Skip the build, install, and image-creation phases and reuse existing images.
100.It Fl j Ar jobs
101Run at most
102.Ar jobs
103QEMU instances at once.
104The default is unlimited.
105.It Fl o Ar dir
106Write images and logs to
107.Ar dir
108instead of the per-architecture object directory.
109May only be used with a single architecture.
110.It Fl t Ar regex
111Run only the tests whose name matches the extended regular expression
112.Ar regex .
113.It Fl T Ar seconds
114Set the per-test QEMU timeout.
115The default is 60 seconds, or 180 for the powerpc targets.
116.It Fl -netboot-teardown
117Destroy the
118.Xr vmnet 4
119interfaces and stop the
120.Xr dnsmasq 8
121instance created for the netboot tests
122.Pq Sx Netboot networking .
123Must be run with
124.Xr sudo 8 .
125Not needed in normal use; the setup is left running between runs on purpose.
126.El
127.Ss Tests per architecture
128The tests generated for an architecture are the applicable combinations of the
129boot interface, the on-disk layout, and the loader interpreter.
130The interpreters are
131.Ar lua ,
132.Ar 4th ,
133and
134.Ar simp ,
135plus the
136.Ar boot1
137chain loader for UEFI; the filesystems are UFS and, where the platform supports
138it, ZFS.
139Which of the following families are built is driven by each architecture's
140capabilities declared in
141.Pa boot-test.json :
142.Bl -tag -width "linuxboot" -compact
143.It Sy BIOS
144GPT (UFS, ZFS) and MBR (UFS) disks, once per interpreter.
145.It Sy UEFI
146GPT (UFS, ZFS) and MBR (UFS) disks, once per interpreter.
147.It Sy hybrid
148A single GPT or MBR image booted both as BIOS and as UEFI.
149.It Sy OFW
150Apple Partition Map disk (UFS, ZFS) on
151.Ar powerpc .
152.It Sy PReP
153MBR disk on
154.Ar powerpc64
155and
156.Ar powerpc64le .
157.It Sy CD
158El Torito for BIOS, a hybrid BIOS+UEFI ISO, and the OFW and CHRP variants.
159.It Sy linuxboot
160UFS and ZFS, booted through the Linux kexec loader.
161.It Sy netboot
162BIOS PXE, UEFI, and iPXE memory-disk boot of a RAM root.
163.El
164A full run
165.Pq Fl A
166currently yields on the order of 80 tests.
167.Ss Netboot networking
168QEMU's user-mode
169.Pq slirp
170networking can hand out an address and a TFTP bootfile, but it cannot send a
171DHCP root-path
172.Pq option 17 .
173Without one, the FreeBSD loader falls back to NFS for every file fetch after
174the initial bootfile and fails, since there is no NFS server to fall back to.
175Sending a root-path of
176.Dq Li tftp://<gw>/
177keeps the loader on TFTP instead, which is what
178.Ar netboot-bios
179and
180.Ar netboot-efi
181need.
182.Pp
183To get a real root-path,
184.Nm
185gives each of those tests its own
186.Xr vmnet 4
187interface and a private
188.Li /30
189carved out of
190.Cm netboot_subnet_base
191in
192.Pa boot-test.json ,
193and runs a single
194.Xr dnsmasq 8
195instance serving all of them.
196.Xr vmnet 4
197is used rather than the more familiar
198.Xr tap 4 ,
199even though QEMU treats them identically and both are clones of the same
200underlying driver: closing the control device automatically brings a
201.Xr tap 4
202interface down and deletes its address, which would undo the setup below
203every time QEMU exits, but
204.Xr vmnet 4
205interfaces keep their configuration across opens.
206Creating the interface and assigning it an address both require root even
207when
208.Va net.link.tap.user_open
209is set
210.Pq that only governs opening the cloning device itself ,
211so
212.Nm
213invokes
214.Xr sudo 8
215once to create the interfaces
216.Pq chowning the resulting device nodes back to the invoking user
217and start
218.Xr dnsmasq 8 .
219Because the interfaces persist until explicitly destroyed,
220.Nm
221leaves them and
222.Xr dnsmasq 8
223running afterward; subsequent runs detect the existing setup by comparing a
224hash of the intended configuration and skip
225.Xr sudo 8
226entirely, so the prompt is normally seen once per boot rather than once per
227run.
228Use
229.Fl -netboot-teardown
230to tear the setup down manually.
231.Pp
232The
233.Ar netboot-ramdisk
234and
235.Ar netboot-bios-memdisk
236tests boot entirely from an in-memory image and never need a root-path, so
237they stay on QEMU's user-mode networking.
238.Sh REQUIREMENTS
239.Nm
240uses
241.Xr makefs 8
242and
243.Xr mkimg 1
244from the base system, and the
245.Xr jq 1 ,
246.Xr expect 1 ,
247.Xr qemu 1 ,
248and
249.Xr dnsmasq 8
250packages
251.Pq Pa textproc/jq , Pa lang/expect , Pa emulators/qemu , Pa dns/dnsmasq .
252The network boot tests additionally require the
253.Pa sysutils/ipxe
254and
255.Pa sysutils/syslinux
256packages.
257.Sh ENVIRONMENT
258.Bl -tag -width ".Ev HOME"
259.It Ev HOME
260Release ISO images and the optional custom
261.Pa openbios-ppc
262firmware are looked for in
263.Pa ~/iso .
264.El
265.Sh FILES
266.Bl -tag -width ".Pa boot-test.json" -compact
267.It Pa boot-test.json
268Per-architecture configuration, parsed with
269.Xr jq 1 .
270.It Pa ~/iso/FreeBSD-*-RELEASE-*-disc1.iso.xz
271Release ISO supplying the minimal userland.
272.It Pa ~/iso/openbios-ppc
273Optional replacement OpenBIOS firmware for the powerpc targets.
274.El
275.Sh EXIT STATUS
276.Nm
277exits 0 if every test that ran passed, and non-zero if any test failed or
278timed out.
279.Sh EXAMPLES
280Test the host architecture:
281.Pp
282.Dl "sh ../tools/boot/boot-test.sh"
283.Pp
284Re-run only the ZFS tests for
285.Ar amd64
286against previously built images:
287.Pp
288.Dl "sh ../tools/boot/boot-test.sh -a amd64 -B -t zfs"
289.Pp
290Test every architecture:
291.Pp
292.Dl "sh ../tools/boot/boot-test.sh -A"
293.Sh SEE ALSO
294.Xr expect 1 ,
295.Xr jq 1 ,
296.Xr mkimg 1 ,
297.Xr gptboot 8 ,
298.Xr loader 8 ,
299.Xr makefs 8 ,
300.Xr pxeboot 8 ,
301.Xr uefi 8
302.Sh AUTHORS
303.An Warner Losh Aq Mt imp@FreeBSD.org
304