mirror of
https://github.com/systemd/systemd.git
synced 2025-02-24 17:57:34 +03:00
test-kernel-install: add a simple test that kernel-install copies the files
I opted to tweaking kernel-install to allow overriding config (with $KERNEL_INSTALL_CONF_ROOT, $KERNEL_INSTALL_PLUGINS). An alternative would be to build a test environment in test/. We can still do that, but I think it's nice to have a simple test that is very quick and easy to debug. Invocation as installkernel is for #23681.
This commit is contained in:
parent
c90cb977a1
commit
f875e6bc39
@ -3751,7 +3751,7 @@ executable(
|
||||
install : true,
|
||||
install_dir : rootlibexecdir)
|
||||
|
||||
public_programs += custom_target(
|
||||
exe = custom_target(
|
||||
'kernel-install',
|
||||
input : kernel_install_in,
|
||||
output : 'kernel-install',
|
||||
@ -3759,6 +3759,13 @@ public_programs += custom_target(
|
||||
install : want_kernel_install,
|
||||
install_mode : 'rwxr-xr-x',
|
||||
install_dir : bindir)
|
||||
public_programs += exe
|
||||
|
||||
if want_tests != 'false'
|
||||
test('test-kernel-install',
|
||||
test_kernel_install_sh,
|
||||
args : [exe.full_path(), loaderentry_install])
|
||||
endif
|
||||
|
||||
############################################################
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
kernel_install_in = files('kernel-install.in')
|
||||
loaderentry_install = files('90-loaderentry.install')
|
||||
|
||||
if want_kernel_install
|
||||
install_data('50-depmod.install',
|
||||
'90-loaderentry.install',
|
||||
loaderentry_install,
|
||||
install_mode : 'rwxr-xr-x',
|
||||
install_dir : kernelinstalldir)
|
||||
|
||||
@ -16,4 +17,5 @@ if want_kernel_install
|
||||
mkdir_p.format(sysconfdir / 'kernel/install.d'))
|
||||
endif
|
||||
|
||||
test_kernel_install_sh = find_program('test-kernel-install.sh')
|
||||
endif
|
||||
|
83
src/kernel-install/test-kernel-install.sh
Executable file
83
src/kernel-install/test-kernel-install.sh
Executable file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
kernel_install="${1:?}"
|
||||
plugin="${2:?}"
|
||||
|
||||
D="$(mktemp --tmpdir --directory "test-kernel-install.XXXXXXXXXX")"
|
||||
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$D'" EXIT INT QUIT PIPE
|
||||
mkdir -p "$D/boot"
|
||||
mkdir -p "$D/efi"
|
||||
mkdir -p "$D/sources"
|
||||
|
||||
echo 'buzy image' >"$D/sources/linux"
|
||||
echo 'the initrd' >"$D/sources/initrd"
|
||||
echo 'the-token' >"$D/sources/entry-token"
|
||||
echo 'opt1 opt2' >"$D/sources/cmdline"
|
||||
|
||||
cat >"$D/sources/install.conf" <<EOF
|
||||
layout=bls
|
||||
initrd_generator=none
|
||||
# those are overriden by envvars
|
||||
BOOT_ROOT="$D/badboot"
|
||||
MACHINE_ID=badbadbadbadbadbad6abadbadbadbad
|
||||
EOF
|
||||
|
||||
export KERNEL_INSTALL_CONF_ROOT="$D/sources"
|
||||
export KERNEL_INSTALL_PLUGINS="$plugin"
|
||||
export BOOT_ROOT="$D/boot"
|
||||
export MACHINE_ID='3e0484f3634a418b8e6a39e8828b03e3'
|
||||
|
||||
"$kernel_install" -v add 1.1.1 "$D/sources/linux" "$D/sources/initrd"
|
||||
|
||||
entry="$BOOT_ROOT/loader/entries/the-token-1.1.1.conf"
|
||||
test -f "$entry"
|
||||
grep -qE '^title ' "$entry"
|
||||
grep -qE '^version +1.1.1' "$entry"
|
||||
grep -qE '^options +opt1 opt2' "$entry"
|
||||
grep -qE '^linux .*/the-token/1.1.1/linux' "$entry"
|
||||
grep -qE '^initrd .*/the-token/1.1.1/initrd' "$entry"
|
||||
|
||||
grep -qE 'image' "$BOOT_ROOT/the-token/1.1.1/linux"
|
||||
grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd"
|
||||
|
||||
"$kernel_install" inspect
|
||||
|
||||
"$kernel_install" -v remove 1.1.1
|
||||
test ! -f "$entry"
|
||||
test ! -f "$BOOT_ROOT/the-token/1.1.1/linux"
|
||||
test ! -f "$BOOT_ROOT/the-token/1.1.1/initrd"
|
||||
|
||||
# Invoke kernel-install as installkernel
|
||||
ln -s --relative -v "$kernel_install" "$D/sources/installkernel"
|
||||
"$D/sources/installkernel" -v 1.1.2 "$D/sources/linux" System.map /somedirignored
|
||||
|
||||
entry="$BOOT_ROOT/loader/entries/the-token-1.1.2.conf"
|
||||
test -f "$entry"
|
||||
grep -qE '^title ' "$entry"
|
||||
grep -qE '^version +1.1.2' "$entry"
|
||||
grep -qE '^options +opt1 opt2' "$entry"
|
||||
grep -qE '^linux .*/the-token/1.1.2/linux' "$entry"
|
||||
( ! grep -qE '^initrd' "$entry" )
|
||||
|
||||
grep -qE 'image' "$BOOT_ROOT/the-token/1.1.2/linux"
|
||||
test ! -e "$BOOT_ROOT/the-token/1.1.2/initrd"
|
||||
|
||||
# Check installation with boot counting
|
||||
echo '56' >"$D/sources/tries"
|
||||
|
||||
"$kernel_install" -v add 1.1.1 "$D/sources/linux" "$D/sources/initrd"
|
||||
entry="$BOOT_ROOT/loader/entries/the-token-1.1.1+56.conf"
|
||||
test -f "$entry"
|
||||
grep -qE '^title ' "$entry"
|
||||
grep -qE '^version +1.1.1' "$entry"
|
||||
grep -qE '^options +opt1 opt2' "$entry"
|
||||
grep -qE '^linux .*/the-token/1.1.1/linux' "$entry"
|
||||
grep -qE '^initrd .*/the-token/1.1.1/initrd' "$entry"
|
||||
|
||||
grep -qE 'image' "$BOOT_ROOT/the-token/1.1.1/linux"
|
||||
grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd"
|
Loading…
x
Reference in New Issue
Block a user