Home | History | Annotate | Line # | Download | only in tests
      1  1.1  christos #! /bin/sh
      2  1.1  christos 
      3  1.1  christos # Test catching of division by zero in plural expression.
      4  1.1  christos 
      5  1.1  christos # Note: On AIX 3 with xlc, this test fails. To make it work, add "-qcheck"
      6  1.1  christos # to the CFLAGS, or use gcc.
      7  1.1  christos 
      8  1.1  christos tmpfiles=""
      9  1.1  christos trap 'rm -fr $tmpfiles' 1 2 3 15
     10  1.1  christos 
     11  1.1  christos tmpfiles="$tmpfiles mf-6.po"
     12  1.1  christos cat <<EOF > mf-6.po
     13  1.1  christos msgid ""
     14  1.1  christos msgstr ""
     15  1.1  christos "Project-Id-Version: msgfmt test 4\n"
     16  1.1  christos "PO-Revision-Date: 2001-09-23 15:03+0200\n"
     17  1.1  christos "Last-Translator: Bruno Haible <haible (at] clisp.cons.org>\n"
     18  1.1  christos "Language-Team: test <test (at] li.org>\n"
     19  1.1  christos "MIME-Version: 1.0\n"
     20  1.1  christos "Content-Type: text/plain; charset=ASCII\n"
     21  1.1  christos "Content-Transfer-Encoding: 8bit\n"
     22  1.1  christos "Plural-Forms: nplurals=3; plural=(1 + (1 / (n - 257)));\n"
     23  1.1  christos EOF
     24  1.1  christos 
     25  1.1  christos tmpfiles="$tmpfiles mf-6.mo core *.core"
     26  1.1  christos : ${MSGFMT=msgfmt}
     27  1.1  christos ${MSGFMT} --check -o mf-6.mo mf-6.po 2>/dev/null
     28  1.1  christos # Exit code must be 1.
     29  1.1  christos # If the division by zero didn't get noticed, it would be 0.
     30  1.1  christos # If it produced a core dump, it would be 136 (= 128 + SIGFPE).
     31  1.1  christos test $? = 1
     32  1.1  christos result=$?
     33  1.1  christos 
     34  1.1  christos rm -fr $tmpfiles
     35  1.1  christos 
     36  1.1  christos exit $result
     37