]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/boot/full-test.sh
MFV: xz 5.4.1.
[FreeBSD/FreeBSD.git] / tools / boot / full-test.sh
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
22 FREEBSD_VERSION=13.1
23 # eg https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/FreeBSD-13.1-RELEASE-amd64-bootonly.iso.xz
24 URLBASE="https://download.freebsd.org/releases"
25 : ${STAND_ROOT:="${HOME}/stand-test-root"}
26 CACHE=${STAND_ROOT}/cache
27 TREES=${STAND_ROOT}/trees
28 IMAGES=${STAND_ROOT}/images
29 BIOS=${STAND_ROOT}/bios
30 SCRIPTS=${STAND_ROOT}/scripts
31 OVERRIDE=${STAND_ROOT}/override
32
33 # hack -- I have extra junk in my qemu, but it's not needed to recreate things
34 if [ $(whoami) = imp ]; then
35     qemu_bin=/home/imp/git/qemu/00-build
36 else
37     qemu_bin=/usr/local/bin
38 fi
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.
43 ARCHES="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
46 espsize=33292
47
48 SRCTOP=$(make -v SRCTOP)
49
50 mkdir -p ${CACHE} ${TREES} ${IMAGES} ${BIOS}
51
52 die()
53 {
54     echo Fatal Error: $*
55     exit 1
56 }
57
58 ma_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
68 fetch_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
87 update_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
100 make_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
133 sysctl machdep.bootmethod
134 echo "RC COMMAND RUNNING -- SUCCESS!!!!!"
135 halt -p
136 EOF
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
171 comconsole_speed=115200
172 autoboot_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?
176 vfs.root.mountfrom="ufs:/dev/ufs/root"
177 boot_verbose=yes
178 kern.cfg.order="acpi,fdt"
179 EOF
180 }
181
182 make_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
193 make_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
214 make_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
237 make_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
260 EOF
261         cp $initrd ${dir}
262     done
263 }
264
265 make_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         pool="linuxboot-testing"
283         mkdir -p ${IMAGES}/${ma_combo}
284         makefs -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
285                -o volume_label=EFISYS -s100m ${esp} ${src}
286         makefs -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
287         mkimg -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
288         makefs -t zfs -s 200m \
289                -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
290                 ${zfs} ${dir} ${dir2}
291         mkimg -s gpt \
292               -p efi:=${esp} \
293               -p freebsd-zfs:=${zfs} -o ${img2}
294         rm -f ${esp}    # Don't need to keep this around
295     done
296
297     # The raw variant, currently used only on arm64. It boots with the raw interface of qemu
298     # for testing purposes.  This means it makes a good test for the DTB variation, but not ACPI
299     # since qemu doesn't currently provide that...
300     for a in arm64:aarch64; do
301         m=${a%%:*}
302         ma=${a##*:}
303         ma_combo="${m}"
304         [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
305         linux="${CACHE}/linux/vmlinux-${m}*"
306         initrd=${TREES}/${ma_combo}/initrd.img
307         img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-raw
308         cp ${linux} ${img}.kernel
309         cp ${initrd} ${img}.initrd
310     done
311 }
312
313 make_linuxboot_scripts()
314 {
315     # At the moment, we have just two -- and the images we've built so far are just
316     # the hostfs boot. The boot off anything more complex isn't here.
317     for a in amd64:amd64 arm64:aarch64; do
318         m=${a%%:*}
319         ma=${a##*:}
320         ma_combo="${m}"
321         [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
322
323         # First off, update the edk firmware
324         bios_code=${BIOS}/edk2-${ma_combo}-code.fd
325         bios_vars=${BIOS}/edk2-${ma_combo}-vars.fd
326         case ${ma} in
327             amd64)
328                 if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
329                     cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
330                     # vars file works on both 32 and 64 bit x86
331                     cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
332                 fi
333                 ;;
334             aarch64)
335                 if [ ${bios_code} -ot /usr/local/share/qemu/edk2-aarch64-code.fd ]; then
336                     # aarch64 vars starts as an empty file
337                     dd if=/dev/zero of=${bios_code} bs=1M count=64
338                     dd if=/dev/zero of=${bios_vars} bs=1M count=64
339                     dd if=/usr/local/share/qemu/edk2-aarch64-code.fd of=${bios_code} conv=notrunc
340                 fi
341                 ;;
342         esac
343
344         # Now make me a script
345         img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.img
346         img2=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-raw
347         img3=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-zfs.img
348         out=${SCRIPTS}/${ma_combo}/linuxboot-test.sh
349         out2=${SCRIPTS}/${ma_combo}/linuxboot-test-raw.sh
350         out3=${SCRIPTS}/${ma_combo}/linuxboot-test-zfs.sh
351         cd=${CACHE}/FreeBSD-13.1-RELEASE-arm64-aarch64-bootonly.iso
352         mkdir -p ${SCRIPTS}/${ma_combo}
353         case ${ma} in
354             amd64)
355                 cat > ${out} <<EOF
356 ${qemu_bin}/qemu-system-x86_64 -nographic -m 512M \\
357         -drive file=${img},if=none,id=drive0,cache=writeback,format=raw \\
358         -device virtio-blk,drive=drive0,bootindex=0 \\
359         -drive file=${bios_code},format=raw,if=pflash \\
360         -drive file=${bios_vars},format=raw,if=pflash \\
361         -monitor telnet::4444,server,nowait \\
362         -serial stdio \$*
363 EOF
364                 ;;
365             aarch64)
366                 # ESP version
367                 raw=${IMAGES}/${ma_combo}/freebsd-arm64-aarch64.img
368                 cat > ${out} <<EOF
369 ${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 \\
370         -cpu cortex-a57 \\
371         -drive file=${img},if=none,id=drive0,cache=writeback \\
372         -device virtio-blk,drive=drive0,bootindex=0 \\
373         -drive file=${raw},if=none,id=drive1,cache=writeback \\
374         -device nvme,serial=fboot,drive=drive1,bootindex=1 \\
375         -drive file=${bios_code},format=raw,if=pflash \\
376         -drive file=${bios_vars},format=raw,if=pflash \\
377         -monitor telnet::4444,server,nowait \\
378         -serial stdio \$*
379 EOF
380                 # RAW version
381                 # Note: We have to use cortex-a57 for raw mode because the
382                 # kernel we use has issues with max.
383                 cat > ${out2} <<EOF
384 ${qemu_bin}/qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt \\
385         -kernel ${img2}.kernel -initrd ${img2}.initrd \\
386         -append "console=ttyAMA0" \\
387         -drive file=${cd},if=none,id=drive0,cache=writeback,format=raw \\
388         -device virtio-blk,drive=drive0,bootindex=0 \\
389         -nographic -monitor telnet::4444,server,nowait \\
390         -serial stdio \$*
391 EOF
392                 # ZFS version
393                 # Note: We have to use cortex-a57 for raw mode because the
394                 # kernel we use has issues with max.
395                 cat > ${out3} <<EOF
396 ${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 \\
397         -cpu cortex-a57 \\
398         -drive file=${img3},if=none,id=drive0,cache=writeback \\
399         -device virtio-blk,drive=drive0,bootindex=0 \\
400         -drive file=${bios_code},format=raw,if=pflash \\
401         -drive file=${bios_vars},format=raw,if=pflash \\
402         -monitor telnet::4444,server,nowait \\
403         -serial stdio \$*
404 EOF
405                 ;;
406         esac
407     done
408 }
409
410 make_freebsd_esps()
411 {
412     # At the moment, we have just three (armv7 could also be here too, but we're not doing that)
413     for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
414         m=${a%%:*}
415         ma=${a##*:}
416         ma_combo="${m}"
417         [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
418         dir=${TREES}/${ma_combo}/freebsd-esp
419         dir2=${TREES}/${ma_combo}/test-stand
420         rm -rf ${dir}
421         mkdir -p ${dir}
422         case ${ma} in
423             amd64) bin=x64 ;;
424             aarch64) bin=aa64 ;;
425         esac
426         mkdir -p ${dir}/efi/boot
427         cp ${dir2}/boot/loader.efi ${dir}/efi/boot/boot${bin}.efi
428     done
429 }
430
431 make_freebsd_images()
432 {
433     # ESP variant: In this variant, riscv, amd64 and arm64 are created more or
434     # less the same way. UEFI + ACPI implementations
435     for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
436         m=${a%%:*}
437         ma=${a##*:}
438         ma_combo="${m}"
439         [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
440         src=${TREES}/${ma_combo}/freebsd-esp
441         dir=${TREES}/${ma_combo}/freebsd
442         dir2=${TREES}/${ma_combo}/test-stand
443         esp=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.esp
444         ufs=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.ufs
445         img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
446         mkdir -p ${IMAGES}/${ma_combo}
447 # XXX 4096 sector?
448         makefs -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
449                -o volume_label=EFISYS -s100m ${esp} ${src}
450         makefs -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
451         mkimg -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
452         # rm -f ${esp} ${ufs}   # Don't need to keep this around
453     done
454
455     set -x
456
457     # PowerPC for 32-bit mac
458     a=powerpc:powerpc
459     m=${a%%:*}
460     ma=${a##*:}
461     ma_combo="${m}"
462     [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
463     dir=${TREES}/${ma_combo}/freebsd
464     dir2=${TREES}/${ma_combo}/test-stand
465     ufs=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.ufs
466     img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
467     mkdir -p ${IMAGES}/${ma_combo}
468     makefs -t ffs -B big -s 200m \
469            -o label=root,version=2,bsize=32768,fsize=4096,density=16384 \
470            ${ufs} ${dir} ${dir2}
471     mkimg -a 1 -s apm \
472         -p freebsd-boot:=${dir2}/boot/boot1.hfs \
473         -p freebsd-ufs:=${ufs} \
474         -o ${img}
475
476     set +x
477 }
478
479 make_freebsd_scripts()
480 {
481     # At the moment, we have just two
482     for a in amd64:amd64 arm64:aarch64; do
483         m=${a%%:*}
484         ma=${a##*:}
485         ma_combo="${m}"
486         [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
487
488         # First off, update the edk firmware
489         bios_code=${BIOS}/edk2-${ma_combo}-code.fd
490         bios_vars=${BIOS}/edk2-${ma_combo}-vars.fd
491         case ${ma} in
492             amd64)
493                 if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
494                     cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
495                     # vars file works on both 32 and 64 bit x86
496                     cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
497                 fi
498                 ;;
499             aarch64)
500                 if [ ${bios_code} -ot /usr/local/share/qemu/edk2-aarch64-code.fd ]; then
501                     # aarch64 vars starts as an empty file
502                     dd if=/dev/zero of=${bios_code} bs=1M count=64
503                     dd if=/dev/zero of=${bios_vars} bs=1M count=64
504                     dd if=/usr/local/share/qemu/edk2-aarch64-code.fd of=${bios_code} conv=notrunc
505                 fi
506                 ;;
507         esac
508
509         # Now make me a script
510         img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
511         out=${SCRIPTS}/${ma_combo}/freebsd-test.sh
512         mkdir -p ${SCRIPTS}/${ma_combo}
513         case ${ma} in
514             amd64)
515                 cat > ${out} <<EOF
516 ${qemu_bin}/qemu-system-x86_64 -nographic -m 512M \\
517         -drive file=${img},if=none,id=drive0,cache=writeback,format=raw \\
518         -device virtio-blk,drive=drive0,bootindex=0 \\
519         -drive file=${bios_code},format=raw,if=pflash \\
520         -drive file=${bios_vars},format=raw,if=pflash \\
521         -monitor telnet::4444,server,nowait \\
522         -serial stdio \$*
523 EOF
524                 ;;
525             aarch64)
526                 # ESP version
527                 raw=${IMAGES}/${ma_combo}/nvme-test-empty.raw
528                 cat > ${out} <<EOF
529 ${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M \\
530         -cpu cortex-a57 -drive file=${img},if=none,id=drive0,cache=writeback -smp 4 \\
531         -device virtio-blk,drive=drive0,bootindex=0 \\
532         -drive file=${bios_code},format=raw,if=pflash \\
533         -drive file=${bios_vars},format=raw,if=pflash \\
534         -drive file=${raw},if=none,id=drive1,cache=writeback,format=raw \\
535         -device nvme,serial=deadbeef,drive=drive1 \\
536         -monitor telnet::4444,server,nowait \\
537         -serial stdio \$*
538 EOF
539                 ;;
540         esac
541     done
542
543     set -x
544     a=powerpc:powerpc
545     m=${a%%:*}
546     ma=${a##*:}
547     ma_combo="${m}"
548     [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
549     img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
550     out=${SCRIPTS}/${ma_combo}/freebsd-test.sh
551     mkdir -p ${SCRIPTS}/${ma_combo}
552     cat > ${out} <<EOF
553 ${qemu_bin}/qemu-system-ppc -m 1g -M mac99,via=pmu \\
554         -vga none -nographic \\
555         -drive file=${img},if=virtio \\
556         -prom-env "boot-device=/pci@f2000000/scsi/disk@0:,\\\\\\:tbxi" \\
557         -monitor telnet::4444,server,nowait \\
558         -serial stdio \$*
559 EOF
560 }
561
562 # The smallest FAT32 filesystem is 33292 KB
563 espsize=33292
564
565 set -e
566 echo "src/stand test in ${STAND_ROOT}"
567 update_freebsd_img_cache
568 make_freebsd_minimal_trees
569 make_freebsd_test_trees
570 make_linux_initrds
571 make_linux_esps
572 make_freebsd_esps
573 make_freebsd_images
574 make_freebsd_scripts
575 make_linuxboot_images
576 make_linuxboot_scripts