From: Frantisek Sumsal Date: Fri, 19 May 2023 17:53:55 +0000 (+0200) Subject: test: check if we correctly handle locales with leading spaces X-Git-Tag: v254-rc1~432^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9ec30ab7e494aef2a998545dd316a122c5cc65a;p=thirdparty%2Fsystemd.git test: check if we correctly handle locales with leading spaces Provides coverage for #27179. --- diff --git a/test/units/testsuite-73.sh b/test/units/testsuite-73.sh index 8e2bca10052..523acd8d06f 100755 --- a/test/units/testsuite-73.sh +++ b/test/units/testsuite-73.sh @@ -648,6 +648,38 @@ EOF assert_in "XKBLAYOUT=us" "$output" } +locale_gen_cleanup() { + # Some running apps might keep the mount point busy, hence the lazy unmount + mountpoint -q /usr/lib/locale && umount --lazy /usr/lib/locale + [[ -e /tmp/locale.gen.bak ]] && mv -f /tmp/locale.gen.bak /etc/locale.gen + + return 0 +} + +# Issue: https://github.com/systemd/systemd/pull/27179 +testcase_locale_gen_leading_space() { + if ! command -v locale-gen >/dev/null; then + echo "No locale-gen support, skipping test." + return 0 + fi + + [[ -e /etc/locale.gen ]] && cp -f /etc/locale.gen /tmp/locale.gen.bak + trap locale_gen_cleanup RETURN + # Overmount the existing locale-gen database with an empty directory + # to force it to regenerate locales + mount -t tmpfs tmpfs /usr/lib/locale + + { + echo -e "en_US.UTF-8 UTF-8" + echo -e " en_US.UTF-8 UTF-8" + echo -e "\ten_US.UTF-8 UTF-8" + echo -e " \t en_US.UTF-8 UTF-8 \t" + } >/etc/locale.gen + + localectl set-locale de_DE.UTF-8 + localectl set-locale en_US.UTF-8 +} + : >/failed # Make sure the content of kbd-model-map is the one that the tests expect