2
1
Fork 0
mirror of https://git.savannah.gnu.org/git/gnuboot.git synced 2025-01-24 00:00:19 +01:00
gnuboot/resources/packages/roms/test
Denis 'GNUtoo' Carikli 9cc02ddde1
packages: roms: Start adding automatic tests.
In GNU Boot, at the time of writing, we want to advise users to use
the GRUB images as they don't require users to modify their
distribtions.

However before the commit aec2e2f2bcf7693a05e416f9722e15b9d1854516
("Fix bug #65663 (No support for LVM2)."), most computers using LVM2
would not boot with these images.

The bug is now fixed by this commit, however since we ship a custom
grub.cfg and that it is very important to get it right, it's a good
idea to have some sort of automated testing for it.

It uses Trisquel (instead of other FSF certified distributions) for
several reasons:
- Trisquel can be used by less technical users, and so it's important
  to make sure it works as less technical users tend to have harder
  times finding workaround when things break.

- It's probably the GNU/Linux distribution that most current and
  potential GNU Boot users use.

- It is also maintained by a community that welcome contributions, so
  if we hit some issues, we can also contribute to get it fixed (we
  also verified that multiple times by contributing to it).

Note that we also welcome tests that reuse other distributions as
well.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
neox: fixed typos in the commit message and fixed copyright notice
Acked-by: Adrien Bourmault <neox@gnu.org>
2024-09-08 17:11:04 +02:00

105 lines
3.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright (C) 2023-2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -e
. resources/scripts/misc/sysexits.sh
usage()
{
progname="$1"
printf "Usage: %s [options]\n\n" "${progname}"
printf "Available options:\n"
printf "\t-h, --help\n"
printf "\t\tDisplay this help and exit.\n"
}
run_qemu_x86_64()
{
source config.sh
gnuboot_img_path="$1"
rootfs_path="$2"
guix_system="$3"
qemu_pkg="$(guix time-machine \
--commit="${GUIX_REVISION}" \
-- \
build \
--system="${guix_system}" \
qemu | grep -v '\-doc$' | grep -v '\-static$')"
if [ "${kvm}" = "yes" ] ; then
extra_qemu_args="-enable-kvm"
fi
qemu_system_x86_64="${qemu_pkg}/bin/qemu-system-x86_64"
# shellcheck disable=SC2086
"${qemu_system_x86_64}" \
-bios "${gnuboot_img_path}" \
-M pc \
-m 790M \
-nographic \
-blockdev '{"driver":"file","filename":"'"${rootfs_path}"'","node-name":"libvirt-1-storage"}' \
-blockdev '{"node-name":"libvirt-1-format","driver":"raw","file":"libvirt-1-storage"}' \
-device '{"driver":"virtio-scsi-pci","id":"scsi0","bus":"pci.0","addr":"0x4"}' \
-device '{"driver":"ahci","id":"sata0","bus":"pci.0","addr":"0x5"}' \
-device '{"driver":"ide-hd","bus":"sata0.0","drive":"libvirt-1-format","id":"sata0-0-0"}' \
${extra_qemu_args}
}
test_grub_cfg_with_lvm()
{
source config.sh
test_name="Test grub.cfg with Trisquel LVM install"
# TODO: Make the test also work with i686.
if [ "${build_cpu}" != "x86_64" ] ; then
printf '[ SKIP ] %s: %s\n' \
"${test_name}" \
"test doesn't work (yet) on ${build_cpu} CPUs."
return 0
fi
rootfs_path="rootfs.img"
if [ ! -f ${rootfs_path} ] ; then
resources/packages/roms/download
fi
run_qemu_x86_64 \
bin/qemu-pc_2mb/grub_qemu-pc_2mb_libgfxinit_corebootfb_usqwerty.rom \
"${rootfs_path}" \
"x86_64-linux" ; ret=$?
if [ ${ret} -eq 0 ] ; then
printf '[ PASS ] %s.\n' "${test_name}"
else
printf '[ FAIL ] %s.\n' "${test_name}"
exit "${ret}"
fi
}
if [ $# -eq 1 ] && { [ "$1" = "-h" ] || [ "$1" == "--help" ] ;} ; then
usage "${progname}"
exit 0
elif [ $# -eq 0 ] ; then
test_grub_cfg_with_lvm
else
usage "${progname}"
exit ${EX_USAGE}
fi