lorax/tests/scripts/run_tests.sh

169 lines
3.8 KiB
Bash
Raw Normal View History

2021-05-03 22:39:00 +00:00
#!/bin/bash
set -eux
2021-06-25 19:47:38 +00:00
FAILANY=0
BOOTISO=/var/tmp/lorax-fedora-iso/images/boot.iso
KSNAME=fedora-minimal.ks
KS="/usr/share/doc/lorax/$KSNAME"
OUTISO=/var/tmp/out.iso
ISODIR=/var/tmp/iso
## Functions for testing mkkiso
function fail {
echo -e "\n\n#### ERROR: $1\n"
FAIL=1
FAILANY=1
}
function status {
if [ "$FAIL" -eq 0 ]; then
echo -e "\n\n#### PASS: $1\n"
else
echo -e "\n\n#### FAIL: $1\n"
fi
}
function running {
FAIL=0
echo -e "\n\n#### RUN: $1\n"
}
2021-11-11 18:18:50 +00:00
# unmount the dirs lazily because sometimes some outside thing is still touching them
function umount_dirs {
umount --lazy "$ISODIR"
rm -f "$OUTISO"
2021-11-11 18:18:50 +00:00
}
2021-06-25 19:47:38 +00:00
[ -e "$ISODIR" ] || mkdir "$ISODIR"
# Only add kickstart
function ks_only {
running "Add kickstart to iso"
mkksiso $KS $BOOTISO $OUTISO || exit 1
mount $OUTISO $ISODIR || exit 1
test_ks
status "Add kickstart"
2021-11-11 18:18:50 +00:00
umount_dirs
2021-06-25 19:47:38 +00:00
}
function test_ks {
## This all needs to be another function
# Is there a kickstart in / of the iso?
[ -e "$ISODIR/$KSNAME" ] || fail "Missing kickstart"
# Is the kickstart in the BIOS config?
grep "inst.ks=.*$KSNAME" "$ISODIR/isolinux/isolinux.cfg" || fail "Missing isolinux.cfg kickstart entry"
# Is the kickstart in the UEFI config?
grep "inst.ks=.*$KSNAME" "$ISODIR/EFI/BOOT/grub.cfg" || fail "Missing UEFI grub.cfg kickstart entry"
2021-06-25 19:47:38 +00:00
}
# Add ks and cmdline
function ks_serial {
running "Add kickstart and serial cmdline"
mkksiso -c "console=ttyS0,115200n8" $KS $BOOTISO $OUTISO || exit 1
mount $OUTISO $ISODIR || exit 1
test_ks
test_ks_serial
status "Add kickstart and serial cmdline"
2021-11-11 18:18:50 +00:00
umount_dirs
2021-06-25 19:47:38 +00:00
}
function test_ks_serial {
# Is the serial in the BIOS config?
grep "console=ttyS0,115200n8" "$ISODIR/isolinux/isolinux.cfg" || fail "Missing isolinux.cfg cmdline entry"
# Is the serial in the UEFI config?
grep "console=ttyS0,115200n8" "$ISODIR/EFI/BOOT/grub.cfg" || fail "Missing UEFI grub.cfg cmdline entry"
2021-06-25 19:47:38 +00:00
}
# New VOLID
function new_volid {
running "Use a new VOLID"
mkksiso -V "mkksiso-test" $KS $BOOTISO $OUTISO || exit 1
mount $OUTISO $ISODIR || exit 1
test_ks
test_volid
status "Use a new VOLID"
2021-11-11 18:18:50 +00:00
umount_dirs
2021-06-25 19:47:38 +00:00
}
function test_volid {
# Is the VOLID in the BIOS config?
grep "hd:LABEL=mkksiso-test" "$ISODIR/isolinux/isolinux.cfg" || fail "Missing isolinux.cfg kickstart entry"
# Is the VOLID in the UEFI config?
grep "hd:LABEL=mkksiso-test" "$ISODIR/EFI/BOOT/grub.cfg" || fail "Missing UEFI grub.cfg kickstart entry"
2021-06-25 19:47:38 +00:00
}
# Add extra files
function add_files {
running "Add files"
mkksiso -a /etc/services $KS $BOOTISO $OUTISO || exit 1
mount $OUTISO $ISODIR || exit 1
test_ks
test_files
status "Add files"
2021-11-11 18:18:50 +00:00
umount_dirs
2021-06-25 19:47:38 +00:00
}
function test_files {
[ -e "$ISODIR/services" ] || fail "Missing file from iso"
}
# All of the changes
function run_all {
running "Use all the options"
mkksiso -a /etc/services -V "mkksiso-test" -c "console=ttyS0,115200n8" $KS $BOOTISO $OUTISO || exit 1
mount $OUTISO $ISODIR || exit 1
test_ks
test_ks_serial
test_volid
test_files
status "Use all the options"
2021-11-11 18:18:50 +00:00
umount_dirs
2021-06-25 19:47:38 +00:00
}
2021-05-03 22:39:00 +00:00
# Gather up the list of system repo files and use them for lorax
REPOS=$(for f in /etc/yum.repos.d/*repo; do echo -n "--repo $f "; done)
if [ -z "$REPOS" ]; then
echo "No system repos found"
exit 1
fi
# NOTE: We must use --nomacboot because the test system doesn't have the hfsplus fs available
# Run lorax using the host's repository configuration file
if [ ! -e "$BOOTISO" ]; then
running "Build boot.iso with lorax"
lorax --product="Fedora" --version=rawhide --release=rawhide --volid="Fedora-rawhide-test" \
$REPOS --isfinal --nomacboot /var/tmp/lorax-fedora-iso/ || exit 1
fi
2021-06-25 19:47:38 +00:00
# Test mkksiso on the new boot.iso
ks_only
ks_serial
new_volid
add_files
run_all
exit $FAILANY