xref: /freebsd/tools/boot/full-test.sh (revision 058ac3e8063366dafa634d9107642e12b038bf09)
1#!/bin/sh
2
3# STAND_ROOT is the root of a tree:
4# cache - Cached binaries that we have downloaded
5# trees - binary trees that we use to make image
6#      trees/${ARCH}/$thing
7# images - bootable images that we use to test
8#	images/${ARCH}/$thing
9# bios - cached bios images (as well as 'vars' files when we start testing
10#	different booting scenarios in the precense / absence of variables).
11# scripts - generated scripts that uses images to run the tests.
12#
13# Strategy:
14#	Download FreeBSD release isos, Linux kernels (for the kboot tests) and
15#	other misc things. We use these to generate dozens of test images that we
16#	use qemu-system-XXXX to boot. They all boot the same thing at the moment:
17#	an /etc/rc script that prints the boot method, echos success and then
18#	halts.
19
20# What version of FreeBSD to we snag the ISOs from to extract the binaries
21# we are testing
22FREEBSD_VERSION=13.1
23# eg https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/FreeBSD-13.1-RELEASE-amd64-bootonly.iso.xz
24URLBASE="https://download.freebsd.org/releases"
25: ${STAND_ROOT:="${HOME}/stand-test-root"}
26CACHE=${STAND_ROOT}/cache
27TREES=${STAND_ROOT}/trees
28IMAGES=${STAND_ROOT}/images
29BIOS=${STAND_ROOT}/bios
30SCRIPTS=${STAND_ROOT}/scripts
31OVERRIDE=${STAND_ROOT}/override
32
33# hack -- I have extra junk in my qemu, but it's not needed to recreate things
34if [ $(whoami) = imp ]; then
35    qemu_bin=/home/imp/git/qemu/00-build
36else
37    qemu_bin=/usr/local/bin
38fi
39
40# All the architectures under test
41# Note: we can't yet do armv7 because we don't have a good iso for it and would
42# need root to extract the files.
43ARCHES="amd64:amd64 i386:i386 powerpc:powerpc powerpc:powerpc64 powerpc:powerpc64le powerpc:powerpcspe arm64:aarch64 riscv:riscv64"
44
45# The smallest FAT32 filesystem is 33292 KB
46espsize=33292
47
48SRCTOP=$(make -v SRCTOP)
49
50mkdir -p ${CACHE} ${TREES} ${IMAGES} ${BIOS}
51
52die()
53{
54    echo Fatal Error: $*
55    exit 1
56}
57
58ma_combo()
59{
60    local m=$1
61    local ma=$2
62    local ma_combo="${m}"
63
64    [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
65    echo ${ma_combo}
66}
67
68fetch_one()
69{
70    local m=$1
71    local ma=$2
72    local v=$3
73    local flavor=$4
74    local ma_combo=$(ma_combo $m $ma)
75    local file="FreeBSD-${v}-RELEASE-${ma_combo}-${flavor}"
76    local url="${URLBASE}/${m}/${ma}/ISO-IMAGES/${v}/${file}.xz"
77
78    mkdir -p ${CACHE}
79    [ -r ${CACHE}/${file} ] && echo "Using cached ${file}" && return
80    cd ${CACHE}
81    echo "Fetching ${url}"
82    fetch ${url} || die "Can't fetch ${file} from ${url}"
83    xz -d ${file}.xz || die "Can't uncompress ${file}.xz"
84    cd ..
85}
86
87update_freebsd_img_cache()
88{
89    local a m ma
90
91    for a in $ARCHES; do
92	m=${a%%:*}
93	ma=${a##*:}
94	fetch_one $m $ma ${FREEBSD_VERSION} bootonly.iso
95    done
96
97    fetch_one arm armv7 ${FREEBSD_VERSION} GENERICSD.img
98}
99
100make_minimal_freebsd_tree()
101{
102    local m=$1
103    local ma=$2
104    local v=$3
105    local flavor=$4
106    local file d
107    local ma_combo="${m}"
108    [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
109
110    file="FreeBSD-${v}-RELEASE-${ma_combo}-${flavor}"
111    dir=${TREES}/${ma_combo}/freebsd
112    rm -rf ${dir}
113
114    # Make a super simple userland. It has just enough to print a santiy value,
115    # then say test succeeded, and then halt the system. We assume that /bin/sh
116    # has all the library prereqs for the rest...
117    mkdir -p ${dir}
118    # Make required dirs
119    for d in boot/kernel boot/defaults boot/lua boot/loader.conf.d \
120			 sbin bin lib libexec etc dev; do
121	mkdir -p ${dir}/${d}
122    done
123    # Pretend we don't have a separate /usr
124    ln -s . ${dir}/usr
125    # snag the binaries for my simple /etc/rc file
126    tar -C ${dir} -xf ${CACHE}/$file sbin/reboot sbin/halt sbin/init bin/sh sbin/sysctl \
127	lib/libncursesw.so.9 lib/libc.so.7 lib/libedit.so.8 libexec/ld-elf.so.1
128
129    # My simple etc/rc
130    cat > ${dir}/etc/rc <<EOF
131#!/bin/sh
132
133sysctl machdep.bootmethod
134echo "RC COMMAND RUNNING -- SUCCESS!!!!!"
135halt -p
136EOF
137    chmod +x ${dir}/etc/rc
138
139    # Check to see if we have overrides here... So we can insert our own kernel
140    # instead of the one from the release.
141    echo "CHECKING ${OVERRIDE}/${ma_combo}/boot"
142    if [ -d ${OVERRIDE}/${ma_combo}/boot ]; then
143	o=${OVERRIDE}/${ma_combo}
144	for i in \
145	    boot/device.hints \
146	    boot/kernel/kernel \
147	    boot/kernel/acl_nfs4.ko \
148	    boot/kernel/cryptodev.ko \
149	    boot/kernel/zfs.ko \
150	    boot/kernel/geom_eli.ko; do
151	    [ -r $o/$i ] && echo Copying override $i && cp $o/$i ${dir}/$i
152	done
153    else
154	# Copy the kernel (but not the boot loader, we'll add the one to test later)
155	# This will take care of both UFS and ZFS boots as well as geli
156	# Note: It's OK for device.hints to be missing. It's mostly for legacy platforms.
157	tar -C ${dir} -xf ${CACHE}/$file \
158	    boot/device.hints \
159	    boot/kernel/kernel \
160	    boot/kernel/acl_nfs4.ko \
161	    boot/kernel/cryptodev.ko \
162	    boot/kernel/zfs.ko \
163	    boot/kernel/geom_eli.ko || true
164	# XXX WHAT TO DO ABOUT LINKER HINTS -- PUNT FOR NOW
165	# XXX also, ZFS not supported on 32-bit powerpc platforms
166    fi
167
168    # Setup some common settings for serial console, etc
169    echo -h -D -S115200 > ${dir}/boot.config
170    cat > ${dir}/boot/loader.conf <<EOF
171comconsole_speed=115200
172autoboot_delay=2
173# XXXX TEST with arm64 iso...
174#vfs.root.mountfrom="cd9660:/dev/iso9660/13_1_RELEASE_AARCH64_BO"
175# XXX not so good for ZFS, what to do?
176vfs.root.mountfrom="ufs:/dev/ufs/root"
177boot_verbose=yes
178kern.cfg.order="acpi,fdt"
179EOF
180}
181
182make_freebsd_minimal_trees()
183{
184    for a in $ARCHES; do
185	m=${a%%:*}
186	ma=${a##*:}
187	make_minimal_freebsd_tree $m $ma ${FREEBSD_VERSION} bootonly.iso
188    done
189    # Note: armv7 isn't done yet as its the odd-man out -- we need to extract things
190    # in a special way, so punt for the moment
191}
192
193make_freebsd_test_trees()
194{
195    for a in $ARCHES; do
196	m=${a%%:*}
197	ma=${a##*:}
198	ma_combo="${m}"
199	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
200	dir=${TREES}/${ma_combo}/test-stand
201	mkdir -p ${dir}
202	mtree -deUW -f ${SRCTOP}/etc/mtree/BSD.root.dist -p ${dir}
203	echo "Creating tree for ${m}:${ma}"
204	cd ${SRCTOP}/stand
205	# Indirection needed because our build system is too complex
206#	SHELL="make clean" make buildenv TARGET=${m} TARGET_ARCH=${ma}
207	SHELL="make -j 100 all" make buildenv TARGET=${m} TARGET_ARCH=${ma}
208	SHELL="make install DESTDIR=${dir} MK_MAN=no MK_INSTALL_AS_USER=yes WITHOUT_DEBUG_FILES=yes" \
209	     make buildenv TARGET=${m} TARGET_ARCH=${ma}
210	rm -rf ${dir}/bin ${dir}/[ac-z]*	# Don't care about anything here
211    done
212}
213
214make_linux_initrds()
215{
216    # At the moment, we have just two
217    for a in amd64:amd64 arm64:aarch64; do
218	m=${a%%:*}
219	ma=${a##*:}
220	ma_combo="${m}"
221	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
222	dir=${TREES}/${ma_combo}/linuxboot
223	dir2=${TREES}/${ma_combo}/test-stand
224	dir3=${TREES}/${ma_combo}/freebsd
225	initrd=${TREES}/${ma_combo}/initrd.img
226	rm -rf ${dir}
227	mkdir -p ${dir}
228	cp ${dir2}/boot/loader.kboot ${dir}/init
229	# Copy the boot loader
230	tar -c -f - -C ${dir2} boot | tar -xf - -C ${dir}
231	# Copy the boot kernel
232	tar -c -f - -C ${dir3} boot | tar -xf - -C ${dir}
233	(cd ${dir} ; find . | LC_ALL=C sort | cpio -o -H newc | gzip > ${initrd})
234    done
235}
236
237make_linux_esps()
238{
239    # At the moment, we have just two
240    for a in amd64:amd64 arm64:aarch64; do
241	m=${a%%:*}
242	ma=${a##*:}
243	ma_combo="${m}"
244	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
245	dir=${TREES}/${ma_combo}/linuxboot-esp
246	initrd=${TREES}/${ma_combo}/initrd.img
247	mkdir -p ${dir}
248	case ${ma} in
249	    amd64) bin=x64 cons="console=ttyS0,115200" ;;
250	    aarch64) bin=aa64 ;;
251	esac
252	mkdir -p ${dir}/efi/boot
253	cp ${CACHE}/linux/linux${bin}.efi ${dir}
254	cp ${CACHE}/linux/shell${bin}.efi ${dir}/efi/boot/boot${bin}.efi
255	cat > ${dir}/startup.nsh <<EOF
256# Run linux
257# Tell it to run with out special initrd that then boot FreeBSD
258
259\linux${bin} ${cons} initrd=\initrd.img
260EOF
261	cp $initrd ${dir}
262    done
263}
264
265make_linuxboot_images()
266{
267    # ESP variant: In this variant, amd64 and arm64 are both created more or
268    # less the same way. Both are EFI + ACPI implementations
269    for a in amd64:amd64 arm64:aarch64; do
270	m=${a%%:*}
271	ma=${a##*:}
272	ma_combo="${m}"
273	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
274	src=${TREES}/${ma_combo}/linuxboot-esp
275	dir=${TREES}/${ma_combo}/freebsd
276	dir2=${TREES}/${ma_combo}/test-stand
277	esp=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.esp
278	ufs=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.ufs
279	zfs=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.zfs
280	img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.img
281	img2=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-zfs.img
282	mkdir -p ${IMAGES}/${ma_combo}
283	makefs -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
284	       -o volume_label=EFISYS -s100m ${esp} ${src}
285	makefs -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
286	mkimg -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
287	makefs -t zfs -s 200m \
288	       -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
289		${zfs} ${dir} ${dir2}
290	mkimg -s gpt \
291	      -p efi:=${esp} \
292	      -p freebsd-zfs:=${zfs} -o ${img2}
293	rm -f ${esp}	# Don't need to keep this around
294    done
295
296    # The raw variant, currently used only on arm64. It boots with the raw interface of qemu
297    # for testing purposes.  This means it makes a good test for the DTB variation, but not ACPI
298    # since qemu doesn't currently provide that...
299    for a in arm64:aarch64; do
300	m=${a%%:*}
301	ma=${a##*:}
302	ma_combo="${m}"
303	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
304	linux="${CACHE}/linux/vmlinux-${m}*"
305	initrd=${TREES}/${ma_combo}/initrd.img
306	img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-raw
307	cp ${linux} ${img}.kernel
308	cp ${initrd} ${img}.initrd
309    done
310}
311
312make_linuxboot_scripts()
313{
314    # At the moment, we have just two -- and the images we've built so far are just
315    # the hostfs boot. The boot off anything more complex isn't here.
316    for a in amd64:amd64 arm64:aarch64; do
317	m=${a%%:*}
318	ma=${a##*:}
319	ma_combo="${m}"
320	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
321
322	# First off, update the edk firmware
323	bios_code=${BIOS}/edk2-${ma_combo}-code.fd
324	bios_vars=${BIOS}/edk2-${ma_combo}-vars.fd
325	case ${ma} in
326	    amd64)
327		if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
328		    cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
329		    # vars file works on both 32 and 64 bit x86
330		    cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
331		fi
332		;;
333	    aarch64)
334		if [ ${bios_code} -ot /usr/local/share/qemu/edk2-aarch64-code.fd ]; then
335		    # aarch64 vars starts as an empty file
336		    dd if=/dev/zero of=${bios_code} bs=1M count=64
337		    dd if=/dev/zero of=${bios_vars} bs=1M count=64
338		    dd if=/usr/local/share/qemu/edk2-aarch64-code.fd of=${bios_code} conv=notrunc
339		fi
340		;;
341	esac
342
343	# Now make me a script
344	img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.img
345	img2=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-raw
346	img3=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-zfs.img
347	out=${SCRIPTS}/${ma_combo}/linuxboot-test.sh
348	out2=${SCRIPTS}/${ma_combo}/linuxboot-test-raw.sh
349	out3=${SCRIPTS}/${ma_combo}/linuxboot-test-zfs.sh
350	cd=${CACHE}/FreeBSD-13.1-RELEASE-arm64-aarch64-bootonly.iso
351	mkdir -p ${SCRIPTS}/${ma_combo}
352	case ${ma} in
353	    amd64)
354		cat > ${out} <<EOF
355${qemu_bin}/qemu-system-x86_64 -nographic -m 512M \\
356        -drive file=${img},if=none,id=drive0,cache=writeback,format=raw \\
357        -device virtio-blk,drive=drive0,bootindex=0 \\
358        -drive file=${bios_code},format=raw,if=pflash \\
359        -drive file=${bios_vars},format=raw,if=pflash \\
360        -monitor telnet::4444,server,nowait \\
361        -serial stdio \$*
362EOF
363		;;
364	    aarch64)
365		# ESP version
366		raw=${IMAGES}/${ma_combo}/freebsd-arm64-aarch64.img
367		cat > ${out} <<EOF
368${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 \\
369        -cpu cortex-a57 \\
370	-drive file=${img},if=none,id=drive0,cache=writeback \\
371	-device virtio-blk,drive=drive0,bootindex=0 \\
372        -drive file=${raw},if=none,id=drive1,cache=writeback \\
373	-device nvme,serial=fboot,drive=drive1,bootindex=1 \\
374        -drive file=${bios_code},format=raw,if=pflash \\
375        -drive file=${bios_vars},format=raw,if=pflash \\
376        -monitor telnet::4444,server,nowait \\
377        -serial stdio \$*
378EOF
379		# RAW version
380		# Note: We have to use cortex-a57 for raw mode because the
381		# kernel we use has issues with max.
382		cat > ${out2} <<EOF
383${qemu_bin}/qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt \\
384	-kernel ${img2}.kernel -initrd ${img2}.initrd \\
385	-append "console=ttyAMA0" \\
386        -drive file=${cd},if=none,id=drive0,cache=writeback,format=raw \\
387        -device virtio-blk,drive=drive0,bootindex=0 \\
388	-nographic -monitor telnet::4444,server,nowait \\
389	-serial stdio \$*
390EOF
391		# ZFS version
392		# Note: We have to use cortex-a57 for raw mode because the
393		# kernel we use has issues with max.
394		cat > ${out3} <<EOF
395${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 \\
396        -cpu cortex-a57 \\
397	-drive file=${img3},if=none,id=drive0,cache=writeback \\
398	-device virtio-blk,drive=drive0,bootindex=0 \\
399        -drive file=${bios_code},format=raw,if=pflash \\
400        -drive file=${bios_vars},format=raw,if=pflash \\
401        -monitor telnet::4444,server,nowait \\
402        -serial stdio \$*
403EOF
404		;;
405	esac
406    done
407}
408
409make_freebsd_esps()
410{
411    # At the moment, we have just three (armv7 could also be here too, but we're not doing that)
412    for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
413	m=${a%%:*}
414	ma=${a##*:}
415	ma_combo="${m}"
416	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
417	dir=${TREES}/${ma_combo}/freebsd-esp
418	dir2=${TREES}/${ma_combo}/test-stand
419	rm -rf ${dir}
420	mkdir -p ${dir}
421	case ${ma} in
422	    amd64) bin=x64 ;;
423	    aarch64) bin=aa64 ;;
424	esac
425	mkdir -p ${dir}/efi/boot
426	cp ${dir2}/boot/loader.efi ${dir}/efi/boot/boot${bin}.efi
427    done
428}
429
430make_freebsd_images()
431{
432    # ESP variant: In this variant, riscv, amd64 and arm64 are created more or
433    # less the same way. UEFI + ACPI implementations
434    for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
435	m=${a%%:*}
436	ma=${a##*:}
437	ma_combo="${m}"
438	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
439	src=${TREES}/${ma_combo}/freebsd-esp
440	dir=${TREES}/${ma_combo}/freebsd
441	dir2=${TREES}/${ma_combo}/test-stand
442	esp=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.esp
443	ufs=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.ufs
444	img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
445	mkdir -p ${IMAGES}/${ma_combo}
446# XXX 4096 sector?
447	makefs -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
448	       -o volume_label=EFISYS -s100m ${esp} ${src}
449	makefs -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
450	mkimg -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
451	# rm -f ${esp} ${ufs}	# Don't need to keep this around
452    done
453
454    set -x
455
456    # PowerPC for 32-bit mac
457    a=powerpc:powerpc
458    m=${a%%:*}
459    ma=${a##*:}
460    ma_combo="${m}"
461    [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
462    dir=${TREES}/${ma_combo}/freebsd
463    dir2=${TREES}/${ma_combo}/test-stand
464    ufs=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.ufs
465    img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
466    mkdir -p ${IMAGES}/${ma_combo}
467    makefs -t ffs -B big -s 200m \
468	   -o label=root,version=2,bsize=32768,fsize=4096,density=16384 \
469	   ${ufs} ${dir} ${dir2}
470    mkimg -a 1 -s apm \
471        -p freebsd-boot:=${dir2}/boot/boot1.hfs \
472        -p freebsd-ufs:=${ufs} \
473        -o ${img}
474
475    set +x
476}
477
478make_freebsd_scripts()
479{
480    # At the moment, we have just two
481    for a in amd64:amd64 arm64:aarch64; do
482	m=${a%%:*}
483	ma=${a##*:}
484	ma_combo="${m}"
485	[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
486
487	# First off, update the edk firmware
488	bios_code=${BIOS}/edk2-${ma_combo}-code.fd
489	bios_vars=${BIOS}/edk2-${ma_combo}-vars.fd
490	case ${ma} in
491	    amd64)
492		if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
493		    cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
494		    # vars file works on both 32 and 64 bit x86
495		    cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
496		fi
497		;;
498	    aarch64)
499		if [ ${bios_code} -ot /usr/local/share/qemu/edk2-aarch64-code.fd ]; then
500		    # aarch64 vars starts as an empty file
501		    dd if=/dev/zero of=${bios_code} bs=1M count=64
502		    dd if=/dev/zero of=${bios_vars} bs=1M count=64
503		    dd if=/usr/local/share/qemu/edk2-aarch64-code.fd of=${bios_code} conv=notrunc
504		fi
505		;;
506	esac
507
508	# Now make me a script
509	img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
510	out=${SCRIPTS}/${ma_combo}/freebsd-test.sh
511	mkdir -p ${SCRIPTS}/${ma_combo}
512	case ${ma} in
513	    amd64)
514		cat > ${out} <<EOF
515${qemu_bin}/qemu-system-x86_64 -nographic -m 512M \\
516        -drive file=${img},if=none,id=drive0,cache=writeback,format=raw \\
517        -device virtio-blk,drive=drive0,bootindex=0 \\
518        -drive file=${bios_code},format=raw,if=pflash \\
519        -drive file=${bios_vars},format=raw,if=pflash \\
520        -monitor telnet::4444,server,nowait \\
521        -serial stdio \$*
522EOF
523		;;
524	    aarch64)
525		# ESP version
526		raw=${IMAGES}/${ma_combo}/nvme-test-empty.raw
527		cat > ${out} <<EOF
528${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M \\
529        -cpu cortex-a57 -drive file=${img},if=none,id=drive0,cache=writeback -smp 4 \\
530        -device virtio-blk,drive=drive0,bootindex=0 \\
531        -drive file=${bios_code},format=raw,if=pflash \\
532        -drive file=${bios_vars},format=raw,if=pflash \\
533        -drive file=${raw},if=none,id=drive1,cache=writeback,format=raw \\
534	-device nvme,serial=deadbeef,drive=drive1 \\
535        -monitor telnet::4444,server,nowait \\
536        -serial stdio \$*
537EOF
538		;;
539	esac
540    done
541
542    set -x
543    a=powerpc:powerpc
544    m=${a%%:*}
545    ma=${a##*:}
546    ma_combo="${m}"
547    [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
548    img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
549    out=${SCRIPTS}/${ma_combo}/freebsd-test.sh
550    mkdir -p ${SCRIPTS}/${ma_combo}
551    cat > ${out} <<EOF
552${qemu_bin}/qemu-system-ppc -m 1g -M mac99,via=pmu \\
553	-vga none -nographic \\
554	-drive file=${img},if=virtio \\
555	-prom-env "boot-device=/pci@f2000000/scsi/disk@0:,\\\\\\:tbxi" \\
556        -monitor telnet::4444,server,nowait \\
557        -serial stdio \$*
558EOF
559}
560
561# The smallest FAT32 filesystem is 33292 KB
562espsize=33292
563
564set -e
565echo "src/stand test in ${STAND_ROOT}"
566update_freebsd_img_cache
567make_freebsd_minimal_trees
568make_freebsd_test_trees
569make_linux_initrds
570make_linux_esps
571make_freebsd_esps
572make_freebsd_images
573make_freebsd_scripts
574make_linuxboot_images
575make_linuxboot_scripts
576