Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / gettext-6
1 #! /bin/sh
2
3 # Test that on glibc systems, gettext() in multithreaded applications works
4 # correctly if different threads operate in different locales with the same
5 # encoding.
6
7 tmpfiles=""
8 trap 'rm -fr $tmpfiles' 1 2 3 15
9
10 # This test works only on glibc and MacOS X systems.
11 : ${host_os=unknown}
12 : ${GLIBC2=no}
13 { case "$host_os" in
14     *-gnu*) test "$GLIBC2" = yes ;;
15     darwin*) true ;;
16     *) false ;;
17   esac
18 } || {
19   echo "Skipping test: not a glibc or Mac OS X system"
20   exit 77
21 }
22
23 # This test works only on systems that have a de_DE and fr_FR locale installed.
24 missing_locale=`./gettext-6-prg 1`
25 if test -n "$missing_locale"; then
26   if test -f /usr/bin/localedef; then
27     echo "Skipping test: locale ${missing_locale} not installed"
28   else
29     echo "Skipping test: locale ${missing_locale} not supported"
30   fi
31   exit 77
32 fi
33
34 tmpfiles="$tmpfiles de_DE fr_FR"
35 test -d de_DE || mkdir de_DE
36 test -d de_DE/LC_MESSAGES || mkdir de_DE/LC_MESSAGES
37 test -d fr_FR || mkdir fr_FR
38 test -d fr_FR/LC_MESSAGES || mkdir fr_FR/LC_MESSAGES
39
40 : ${MSGFMT=msgfmt}
41 ${MSGFMT} -o de_DE/LC_MESSAGES/tstthread.mo ${top_srcdir}/tests/gettext-6-1.po
42 ${MSGFMT} -o fr_FR/LC_MESSAGES/tstthread.mo ${top_srcdir}/tests/gettext-6-2.po
43
44 tmpfiles="$tmpfiles gt-6.ok"
45 cat <<EOF > gt-6.ok
46 Schönheit
47 beauté
48 Schönheit
49 beauté
50 EOF
51
52 tmpfiles="$tmpfiles gt-6.out"
53 ./gettext-6-prg > gt-6.out
54 case $? in
55   0) ;;
56   77)
57     echo "Skipping test: not a glibc >= 2.3 or MacOS X >= 10.5 system"
58     rm -fr $tmpfiles; exit 77
59     ;;
60 esac
61
62 : ${DIFF=diff}
63 ${DIFF} gt-6.ok gt-6.out || exit 1
64
65 rm -fr $tmpfiles
66
67 exit 0