]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: add test for locale decimal processing
authorPádraig Brady <P@draigBrady.com>
Mon, 28 Jan 2019 05:34:52 +0000 (21:34 -0800)
committerPádraig Brady <P@draigBrady.com>
Thu, 31 Jan 2019 01:49:05 +0000 (17:49 -0800)
* tests/misc/sleep.sh: Check locale processing of printf, sleep,
and timeout, when the french locale data is available.

tests/misc/sleep.sh

index c20ce011fd5607b637033da70228f399ef7594eb..b5934d80608c94a2f914aec75b79bcbe54074803 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ sleep
+print_ver_ sleep printf
 getlimits_
 
 # invalid timeouts
@@ -39,4 +39,17 @@ returns_ 124 timeout 0.1 sleep 1d 2h 3m 4s || fail=1
 returns_ 124 timeout 0.1 sleep inf || fail=1
 returns_ 124 timeout 0.1 sleep $LDBL_MAX || fail=1
 
+# Test locale decimal handling for printf, sleep, timeout
+: ${LOCALE_FR_UTF8=none}
+if test "$LOCALE_FR_UTF8" != "none"; then
+  f=$LOCALE_FR_UTF8
+  locale_decimal=$(LC_ALL=$f env printf '%0.3f' 0.001) || fail=1
+  locale_decimal=$(LC_ALL=$f env printf '%0.3f' "$locale_decimal") || fail=1
+  case "$locale_decimal" in
+    0?001)
+      LC_ALL=$f timeout 1$locale_decimal sleep "$locale_decimal" || fail=1 ;;
+    *) fail=1 ;;
+  esac
+fi
+
 Exit $fail