diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-11-07 19:41:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 19:41:44 +0100 |
commit | 5c1a5ac17243f1863ab59c514aaebc33dbeadcc6 (patch) | |
tree | 516220a6e5eba904ec88188107d8e2b3c8c77001 /test/units | |
parent | mkosi: use the new mkosi.conf suffix (diff) | |
parent | test: cover some interactive/error paths in firstboot (diff) | |
download | systemd-5c1a5ac17243f1863ab59c514aaebc33dbeadcc6.tar.xz systemd-5c1a5ac17243f1863ab59c514aaebc33dbeadcc6.zip |
Merge pull request #25279 from mrc0mmand/firstboot-test-fixes
test: cover some interactive/error paths in firstboot
Diffstat (limited to 'test/units')
-rwxr-xr-x | test/units/testsuite-74.firstboot.sh | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/units/testsuite-74.firstboot.sh b/test/units/testsuite-74.firstboot.sh index f17b35e672..fdea34b5c8 100755 --- a/test/units/testsuite-74.firstboot.sh +++ b/test/units/testsuite-74.firstboot.sh @@ -9,7 +9,7 @@ if ! command -v systemd-firstboot >/dev/null; then fi at_exit() { - if [[ -v ROOT && -n "$ROOT" ]]; then + if [[ -n "${ROOT:-}" ]]; then ls -lR "$ROOT" rm -fr "$ROOT" fi @@ -133,6 +133,30 @@ diff <(awk -F: '/^root/ { print $2; }' /etc/shadow) <(awk -F: '/^root/ { print $ [[ -e /etc/vconsole.conf ]] && diff /etc/vconsole.conf "$ROOT/etc/vconsole.conf" [[ -e /etc/localtime ]] && diff <(readlink /etc/localtime) <(readlink "$ROOT/etc/localtime") +# --prompt-* options +rm -fr "$ROOT" +mkdir -p "$ROOT/bin" +touch "$ROOT/bin/fooshell" "$ROOT/bin/barshell" +# We can do only limited testing here, since it's all an interactive stuff, +# so --prompt and --prompt-root-password are skipped on purpose +echo -ne "\nfoo\nbar\n" | systemd-firstboot --root="$ROOT" --prompt-locale +grep -q "LANG=foo" "$ROOT/etc/locale.conf" +grep -q "LC_MESSAGES=bar" "$ROOT/etc/locale.conf" +echo -ne "\nfoo\n" | systemd-firstboot --root="$ROOT" --prompt-keymap +grep -q "KEYMAP=foo" "$ROOT/etc/vconsole.conf" +echo -ne "\nEurope/Berlin\n" | systemd-firstboot --root="$ROOT" --prompt-timezone +readlink "$ROOT/etc/localtime" | grep -q "Europe/Berlin$" +echo -ne "\nfoobar\n" | systemd-firstboot --root="$ROOT" --prompt-hostname +grep -q "foobar" "$ROOT/etc/hostname" +echo -ne "\n/bin/fooshell\n" | systemd-firstboot --root="$ROOT" --prompt-root-shell +grep -q "^root:.*:0:0:.*:/bin/fooshell$" "$ROOT/etc/passwd" +# Existing files should not get overwritten +echo -ne "\n/bin/barshell\n" | systemd-firstboot --root="$ROOT" --prompt-root-shell +grep -q "^root:.*:0:0:.*:/bin/fooshell$" "$ROOT/etc/passwd" +# Now without the welcome screen but with force +echo -ne "/bin/barshell\n" | systemd-firstboot --root="$ROOT" --force --prompt-root-shell --welcome=no +grep -q "^root:.*:0:0:.*:/bin/barshell$" "$ROOT/etc/passwd" + # Assorted tests rm -fr "$ROOT" mkdir "$ROOT" @@ -142,3 +166,7 @@ grep -E "[a-z0-9]{32}" "$ROOT/etc/machine-id" systemd-firstboot --root="$ROOT" --delete-root-password diff <(echo) <(awk -F: '/^root/ { print $2; }' "$ROOT/etc/shadow") + +(! systemd-firstboot --root="$ROOT" --root-shell=/bin/nonexistentshell) +(! systemd-firstboot --root="$ROOT" --machine-id=invalidmachineid) +(! systemd-firstboot --root="$ROOT" --timezone=Foo/Bar) |