File: 017_locale_iconv

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (126 lines) | stat: -rwxr-xr-x 3,036 bytes parent folder | download | duplicates (3)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/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
	# These must be the bytes c3 b6, which is an ö
	mkdir -p dir-$filename/dir-ö/f-$filename
	echo $filename | od -Ax -tc -tx1 > $log
	$BINdflt ci -m "locale ci $filename" >> $log
	$WC2_UP_ST_COMPARE > /dev/null

# "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 -R --xml $REPURL/ > $log.1
	svn ls -R $REPURL/ > $log.2
	if [[ `grep -F "$filename" < $log.1 | wc -l` -eq 6 ||
	      `grep -F "$filename" < $log.2 | wc -l` -eq 6 ]]
	then
		echo "Ok, found all 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.
	if [[ "$other" != "" ]]
	then
		# Remove all entries
		$BINq up -r1 $WC2 > /dev/null
		# Checkout
		LC_ALL=$other $BINq up $WC2  > /dev/null
		if $BINdflt st $WC2 | grep .
		then
			$ERROR "Didn't expect any output after update"
		fi
		LC_ALL=$other $BINq sync $WC2 > /dev/null
		if $BINdflt st $WC2 | grep .
		then
			$ERROR "Didn't expect any output after sync"
		fi
	fi

	echo "Cleaning up"
	rm -rf *
	$BINdflt ci -m "locale ci $filename cleanup" > $log
	LC_ALL=$other $WC2_UP_ST_COMPARE > $log
}



# 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
	export other=$loc_locale
	# The bytes here must be c3 a4; in utf8 that's an &auml;
	# Use a hex editor.
	testfunc ä
	testfunc $STG_UTF8
	# This sequence of bytes in $STG_LOC is in latin1 or something similar, which 
	# is not a valid UTF-8 sequence, so we can't use that.
	$SUCCESS "utf8 locale"
fi

# Test non-UTF8
if [[ "$loc_locale" != "" ]]
then
	$INFO "testing non-utf8 locale $loc_locale"
	export LC_ALL=$loc_locale
	export other=$utf8_locale
	# The bytes here must be \xc2\x61, that is an invalid UTF8-sequence.
	# Use a hex editor.
	testfunc �a
	# In non-UTF8 locales all byte sequences are valid - they have no 
	# interdependencies.
	testfunc $STG_UTF8
	testfunc $STG_LOC
	$SUCCESS "non-utf8 locale"
fi


# vi: binary