Home | History | Annotate | Line # | Download | only in tests
      1  1.1  christos #! /bin/sh
      2  1.1  christos 
      3  1.1  christos # Test recode-sr-latin on some input in UTF-8 encoding.
      4  1.1  christos 
      5  1.1  christos tmpfiles=""
      6  1.1  christos trap 'rm -fr $tmpfiles' 1 2 3 15
      7  1.1  christos 
      8  1.1  christos # Test whether a specific UTF-8 locale is installed.
      9  1.1  christos : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
     10  1.1  christos if test $LOCALE_FR_UTF8 != none; then
     11  1.1  christos   LC_ALL=$LOCALE_FR_UTF8 ./testlocale 2>/dev/null
     12  1.1  christos   case $? in
     13  1.1  christos     0) ;;
     14  1.1  christos     77) LOCALE_FR_UTF8=none;;
     15  1.1  christos     *) exit 1;;
     16  1.1  christos   esac
     17  1.1  christos fi
     18  1.1  christos if test $LOCALE_FR_UTF8 = none; then
     19  1.1  christos   if test -f /usr/bin/localedef; then
     20  1.1  christos     echo "Skipping test: no french UTF-8 locale is installed"
     21  1.1  christos   else
     22  1.1  christos     echo "Skipping test: no french UTF-8 locale is supported"
     23  1.1  christos   fi
     24  1.1  christos   rm -fr $tmpfiles; exit 77
     25  1.1  christos fi
     26  1.1  christos 
     27  1.1  christos tmpfiles="$tmpfiles rec-srl-1.in"
     28  1.1  christos cat <<\EOF > rec-srl-1.in
     29  1.1  christos   
     30  1.1  christos  
     31  1.1  christos EOF
     32  1.1  christos 
     33  1.1  christos tmpfiles="$tmpfiles rec-srl-1.out"
     34  1.1  christos : ${RECODE=recode}
     35  1.1  christos LC_ALL=$LOCALE_FR_UTF8 \
     36  1.1  christos ${RECODE}-sr-latin < rec-srl-1.in > rec-srl-1.out \
     37  1.1  christos   || { rm -fr $tmpfiles; exit 1; }
     38  1.1  christos 
     39  1.1  christos tmpfiles="$tmpfiles rec-srl-1.ok"
     40  1.1  christos cat <<\EOF > rec-srl-1.ok
     41  1.1  christos Ispravni argumenti su
     42  1.1  christos nejednoznaan argument
     43  1.1  christos EOF
     44  1.1  christos 
     45  1.1  christos : ${DIFF=diff}
     46  1.1  christos ${DIFF} rec-srl-1.ok rec-srl-1.out
     47  1.1  christos result=$?
     48  1.1  christos 
     49  1.1  christos rm -fr $tmpfiles
     50  1.1  christos 
     51  1.1  christos exit $result
     52