Tests: test-no-initramfs: Test both legacy and new kernel locations
Closes: #1401 Approved by: cgwalters
This commit is contained in:
parent
3724692d9e
commit
3318db548e
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
. $(dirname $0)/libtest.sh
|
. $(dirname $0)/libtest.sh
|
||||||
|
|
||||||
echo "1..3"
|
echo "1..7"
|
||||||
|
|
||||||
setup_os_repository "archive-z2" "uboot"
|
setup_os_repository "archive-z2" "uboot"
|
||||||
|
|
||||||
|
|
@ -17,36 +17,62 @@ assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'in
|
||||||
|
|
||||||
echo "ok deployment with initramfs"
|
echo "ok deployment with initramfs"
|
||||||
|
|
||||||
cd ${test_tmpdir}/osdata/boot
|
pull_test_tree() {
|
||||||
rm -f initramfs* vmlinuz*
|
kernel_contents=$1
|
||||||
echo "the kernel only" > vmlinuz-3.6.0
|
initramfs_contents=$2
|
||||||
bootcsum=$(cat vmlinuz-3.6.0 | sha256sum | cut -f 1 -d ' ')
|
|
||||||
mv vmlinuz-3.6.0 vmlinuz-3.6.0-${bootcsum}
|
|
||||||
cd -
|
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=osdata/ -b testos/buildmaster/x86_64-runtime
|
|
||||||
${CMD_PREFIX} ostree pull testos:testos/buildmaster/x86_64-runtime
|
|
||||||
${CMD_PREFIX} ostree admin deploy --os=testos --karg=root=/dev/sda2 --karg=rootwait testos:testos/buildmaster/x86_64-runtime
|
|
||||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'rootwait'
|
|
||||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init='
|
|
||||||
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'initrd'
|
|
||||||
|
|
||||||
echo "ok switching to bootdir with no initramfs"
|
printf "TEST SETUP:\n kernel: %s\n initramfs: %s\n layout: %s\n" \
|
||||||
|
"$kernel_contents" "$initramfs_contents" "$layout"
|
||||||
|
|
||||||
cd ${test_tmpdir}/osdata/boot
|
rm -rf ${test_tmpdir}/osdata/usr/lib/modules/3.6.0/{initramfs.img,vmlinuz} \
|
||||||
rm -f initramfs* vmlinuz*
|
${test_tmpdir}/osdata/usr/lib/ostree-boot \
|
||||||
echo "the kernel" > vmlinuz-3.6.0
|
${test_tmpdir}/osdata/boot
|
||||||
echo "initramfs to assist the kernel" > initramfs-3.6.0
|
if [ "$layout" = "/usr/lib/modules" ]; then
|
||||||
bootcsum=$(cat vmlinuz-3.6.0 initramfs-3.6.0 | sha256sum | cut -f 1 -d ' ')
|
# Fedora compatible layout
|
||||||
mv vmlinuz-3.6.0 vmlinuz-3.6.0-${bootcsum}
|
cd ${test_tmpdir}/osdata/usr/lib/modules/3.6.0
|
||||||
mv initramfs-3.6.0 initramfs-3.6.0-${bootcsum}
|
echo -n "$kernel_contents" > vmlinuz
|
||||||
cd -
|
[ -n "$initramfs_contents" ] && echo -n "$initramfs_contents" > initramfs.img
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=osdata/ -b testos/buildmaster/x86_64-runtime
|
elif [ "$layout" = "/usr/lib/ostree-boot" ] || [ "$layout" = "/boot" ]; then
|
||||||
${CMD_PREFIX} ostree pull testos:testos/buildmaster/x86_64-runtime
|
# "Legacy" layout
|
||||||
${CMD_PREFIX} ostree admin deploy --os=testos --karg-none --karg=root=LABEL=rootfs testos:testos/buildmaster/x86_64-runtime
|
mkdir -p "${test_tmpdir}/osdata/$layout"
|
||||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'initrd'
|
cd "${test_tmpdir}/osdata/$layout"
|
||||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'root=LABEL=rootfs'
|
bootcsum=$(echo -n "$kernel_contents$initramfs_contents" \
|
||||||
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'rootwait'
|
| sha256sum | cut -f 1 -d ' ')
|
||||||
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init='
|
echo -n "$kernel_contents" > vmlinuz-${bootcsum}
|
||||||
|
[ -n "$initramfs_contents" ] && echo -n "$initramfs_contents" > initramfs-${bootcsum}
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cd -
|
||||||
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=osdata/ -b testos/buildmaster/x86_64-runtime
|
||||||
|
${CMD_PREFIX} ostree pull testos:testos/buildmaster/x86_64-runtime
|
||||||
|
}
|
||||||
|
|
||||||
echo "ok switching from no initramfs to initramfs enabled sysroot"
|
get_key_from_bootloader_conf() {
|
||||||
|
conffile=$1
|
||||||
|
key=$2
|
||||||
|
|
||||||
|
assert_file_has_content "$conffile" "^$key"
|
||||||
|
awk "/^$key/ { print \$2 }" "$conffile"
|
||||||
|
}
|
||||||
|
|
||||||
|
for layout in /usr/lib/modules /usr/lib/ostree-boot /boot;
|
||||||
|
do
|
||||||
|
pull_test_tree "the kernel only"
|
||||||
|
${CMD_PREFIX} ostree admin deploy --os=testos --karg=root=/dev/sda2 --karg=rootwait testos:testos/buildmaster/x86_64-runtime
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'rootwait'
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init='
|
||||||
|
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'initrd'
|
||||||
|
|
||||||
|
echo "ok switching to bootdir with no initramfs layout=$layout"
|
||||||
|
|
||||||
|
pull_test_tree "the kernel" "initramfs to assist the kernel"
|
||||||
|
${CMD_PREFIX} ostree admin deploy --os=testos --karg-none --karg=root=LABEL=rootfs testos:testos/buildmaster/x86_64-runtime
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'initrd'
|
||||||
|
assert_file_has_content sysroot/boot/$(get_key_from_bootloader_conf sysroot/boot/loader/entries/ostree-testos-0.conf "initrd") "initramfs to assist the kernel"
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'root=LABEL=rootfs'
|
||||||
|
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'rootwait'
|
||||||
|
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init='
|
||||||
|
|
||||||
|
echo "ok switching from no initramfs to initramfs enabled sysroot layout=$layout"
|
||||||
|
done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue