diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test-functions | 48 | ||||
-rwxr-xr-x | test/units/testsuite-74.firstboot.sh | 30 |
2 files changed, 58 insertions, 20 deletions
diff --git a/test/test-functions b/test/test-functions index 16d9da637b..194cd682bb 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1988,21 +1988,27 @@ install_locales() { inst /usr/share/i18n/SUPPORTED || : inst_recursive /usr/share/i18n/charmaps inst_recursive /usr/share/i18n/locales - inst_recursive /usr/share/locale/en - inst_recursive /usr/share/locale/en_* + inst_recursive /usr/share/locale/en* + inst_recursive /usr/share/locale/de* + image_install /usr/share/locale/locale.alias + # locale-gen might either generate each locale separately or merge them + # into a single archive + if ! (inst_recursive /usr/lib/locale/C.*8 /usr/lib/locale/en_*8 || + image_install /usr/lib/locale/locale-archive); then + dfatal "Failed to install required locales" + exit 1 + fi + else + inst_recursive /usr/lib/locale/C.*8 /usr/lib/locale/en_*8 fi - - inst_recursive /usr/lib/locale/C.utf8 - inst_recursive /usr/lib/locale/C.UTF-8 - inst_recursive /usr/lib/locale/en_*.utf8 - inst_recursive /usr/lib/locale/en_*.UTF-8 } # shellcheck disable=SC2120 install_keymaps() { local i p local -a prefix=( - "/usr" + "/usr/lib" + "/usr/share" ) dinfo "Install console keymaps" @@ -2011,7 +2017,7 @@ install_keymaps() { && [[ "$(meson configure "${BUILD_DIR:?}" | grep 'split-usr' | awk '{ print $2 }')" == "true" ]] \ || [[ ! -L /lib ]]; then prefix+=( - "" + "/lib" ) fi @@ -2020,12 +2026,12 @@ install_keymaps() { # The first three paths may be deprecated. # It seems now the last three paths are used by many distributions. for i in \ - "$p"/lib/kbd/keymaps/include/* \ - "$p"/lib/kbd/keymaps/i386/include/* \ - "$p"/lib/kbd/keymaps/i386/qwerty/us.* \ - "$p"/lib/kbd/keymaps/legacy/include/* \ - "$p"/lib/kbd/keymaps/legacy/i386/qwerty/us.* \ - "$p"/lib/kbd/keymaps/xkb/us*; do + "$p"/kbd/keymaps/include/* \ + "$p"/kbd/keymaps/i386/include/* \ + "$p"/kbd/keymaps/i386/qwerty/us.* \ + "$p"/kbd/keymaps/legacy/include/* \ + "$p"/kbd/keymaps/legacy/i386/qwerty/us.* \ + "$p"/kbd/keymaps/xkb/us*; do [[ -f "$i" ]] || continue inst "$i" done @@ -2034,10 +2040,10 @@ install_keymaps() { # When it takes any argument, then install more keymaps. for p in "${prefix[@]}"; do for i in \ - "$p"/lib/kbd/keymaps/include/* \ - "$p"/lib/kbd/keymaps/i386/*/* \ - "$p"/lib/kbd/keymaps/legacy/i386/*/* \ - "$p"/lib/kbd/keymaps/xkb/*; do + "$p"/kbd/keymaps/include/* \ + "$p"/kbd/keymaps/i386/*/* \ + "$p"/kbd/keymaps/legacy/i386/*/* \ + "$p"/kbd/keymaps/xkb/*; do [[ -f "$i" ]] || continue inst "$i" done @@ -2773,6 +2779,10 @@ inst_recursive() { local p item for p in "$@"; do + # Make sure the source exists, as the process substitution below + # suppresses errors + stat "$p" >/dev/null || return 1 + while read -r item; do if [[ -d "$item" ]]; then inst_dir "$item" 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) |