Blame SOURCES/0001-tests-Try-several-UTF8-locales.patch

003ee8
From e73c27f435017e22a68383255f15ebaa562dd414 Mon Sep 17 00:00:00 2001
003ee8
From: "Brian C. Lane" <bcl@redhat.com>
003ee8
Date: Wed, 13 Aug 2014 13:40:28 -0700
003ee8
Subject: [PATCH] tests: Try several UTF8 locales
003ee8
003ee8
Not all distributions (Fedora) have C.UTF-8 so try several (en_US, de_DE,
003ee8
fr_FR, es_ES). This may still fail if none exist.
003ee8
003ee8
* tests/t0251-gpt-unicode.sh: Test for en_US de_DE fr_FR es_ES
003ee8
---
003ee8
 tests/t0251-gpt-unicode.sh | 18 +++++++++++++++++-
003ee8
 1 file changed, 17 insertions(+), 1 deletion(-)
003ee8
003ee8
diff --git a/tests/t0251-gpt-unicode.sh b/tests/t0251-gpt-unicode.sh
003ee8
index c845950..537aaa1 100755
003ee8
--- a/tests/t0251-gpt-unicode.sh
003ee8
+++ b/tests/t0251-gpt-unicode.sh
003ee8
@@ -22,7 +22,23 @@ dev=loop-file
003ee8
 # create zeroed device
003ee8
 truncate -s 10m $dev || fail=1
003ee8
 
003ee8
-export LC_ALL=C.UTF-8
003ee8
+found_locale=no
003ee8
+for locale in en_US de_DE fr_FR es_ES
003ee8
+do
003ee8
+  LC_ALL="$locale.utf8"
003ee8
+
003ee8
+  # In a UTF-8 locale, the string below prints as 4 characters.
003ee8
+  if [ `printf 'foo\341\264\244' | wc -m` -eq 4 ]; then
003ee8
+    found_locale=yes
003ee8
+    break
003ee8
+  fi
003ee8
+done
003ee8
+
003ee8
+if [ "$found_locale" != "yes" ]; then
003ee8
+  echo "no valid UTF-8 locale found; skipping" >&2
003ee8
+  exit 77
003ee8
+fi
003ee8
+
003ee8
 # create gpt label with named partition
003ee8
 part_name=$(printf 'foo\341\264\244')
003ee8
 parted -s $dev mklabel gpt mkpart primary ext2 1MiB 2MiB name 1 $part_name > empty 2>&1 || fail=1
003ee8
-- 
003ee8
1.9.3
003ee8