summary refs log tree commit diff
path: root/pkgs/tools/misc/parted/gpt-unicode-test-fix.patch
blob: 3070a2e4666d2a33d5ec0575d282c5ccf0244831 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From Ludo's suggestion at:

  http://debbugs.gnu.org/cgi/bugreport.cgi?msg=8;bug=18258

diff --git a/tests/t0251-gpt-unicode.sh b/tests/t0251-gpt-unicode.sh
index c845950..fa63a72 100755
--- a/tests/t0251-gpt-unicode.sh
+++ b/tests/t0251-gpt-unicode.sh
@@ -22,7 +22,24 @@ dev=loop-file
 # create zeroed device
 truncate -s 10m $dev || fail=1
 
-export LC_ALL=C.UTF-8
+found_locale=no
+for locale in en_US de_DE fr_FR es_ES
+do
+  LC_ALL="$locale.UTF-8"
+  export LC_ALL
+
+  # In a UTF-8 locale, the string below prints as 4 characters.
+  if [ `printf 'foo\341\264\244' | wc -m` -eq 4 ]; then
+    found_locale=yes
+    break
+  fi
+done
+
+if [ "$found_locale" != "yes" ]; then
+  echo "no valid UTF-8 locale found; skipping" >&2
+  exit 77
+fi
+
 # create gpt label with named partition
 part_name=$(printf 'foo\341\264\244')
 parted -s $dev mklabel gpt mkpart primary ext2 1MiB 2MiB name 1 $part_name > empty 2>&1 || fail=1