File: 017_locale_iconv

package info (click to toggle)
fsvs 1.1.16-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,344 kB
  • ctags: 1,133
  • sloc: ansic: 14,472; sh: 6,793; perl: 631; makefile: 337
file content (101 lines) | stat: -rwxr-xr-x 2,199 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

set -e 
$PREPARE_CLEAN > /dev/null
$INCLUDE_FUNCS
cd $WC

log=$LOGDIR/017.log


function testfunc
{
	filename=$1

	touch file-$filename
	ln -s file-$filename link-$filename
	ln -s bad-$filename badlink-$filename
	$BINdflt ci -m "locale ci $filename"
	$WC2_UP_ST_COMPARE

# "svn ls" gives characters > \x80 as eg. "?\228".
# With --xml we get the raw string, but *always* in UTF-8 ... so try both ways.
	svn ls --xml $REPURL/ > $log.1
	svn ls $REPURL/ > $log.2
	if [[ `grep -F "$filename" < $log.1 | wc -l` -eq 3 ||
	      `grep -F "$filename" < $log.2 | wc -l` -eq 3 ]]
	then
		echo "Ok, found all 3 entries."
	else
		$ERROR_NB "Expected filename:"
	  echo $filename | od -Ax -tx1 -tc
		$ERROR "En/Decode problem - entries not found."
	fi

# TODO: test whether the entries are correct in the other locale.

	rm *
	$BINq ci -m "locale ci $filename cleanup"
	$WC2_UP_ST_COMPARE
}



# look for UTF8
utf8_locale=`locale -a | grep .utf8 | head -1`
if [[ "$utf8_locale" != "" ]]
then
  echo "Found UTF8-locale '$utf8_locale', using that for testing."
else
  echo "Found no utf8-locale, cannot test"
fi


# look for non-utf8
loc_locale=`locale -a | egrep -v "(POSIX|C|utf8$)" | head -1`
if [[ "$loc_locale" != "" ]]
then
  echo "Found non-UTF8-locale '$loc_locale', using that for testing, too."
else
  echo "Found no non-utf8-locale, cannot test"
fi


# Trivial test with current settings
# We must use only ASCII as we don't know in which locale 
# this script is parsed.
$INFO "testing default locale"
testfunc test12
$SUCCESS "default locale"
	
# Clear environment
unset LC_ALL LC_CTYPE

# Test UTF8
if [[ "$utf8_locale" != "" ]]
then
	$INFO "testing utf8 locale $utf8_locale"
	export LC_ALL=$utf8_locale
	# The bytes here must be \xc2\xa9; in utf8 that's 3 horizontal lines.
	# Use a hex editor.
	testfunc ©
	testfunc $STG_UTF8
	testfunc $STG_LOC
	$SUCCESS "utf8 locale"
fi

# Test non-UTF8
if [[ "$loc_locale" != "" ]]
then
	$INFO "testing non-utf8 locale $loc_locale"
	export LC_ALL=$loc_locale
	# The bytes here must be \xc2\x61, that is an invalid UTF8-sequence.
	# Use a hex editor.
	testfunc a
	testfunc $STG_UTF8
	testfunc $STG_LOC
	$SUCCESS "non-utf8 locale"
fi


# vi: binary