Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | #!/bin/sh |
michael@0 | 2 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 5 | |
michael@0 | 6 | ECHO=/bin/echo |
michael@0 | 7 | MAKE=gmake |
michael@0 | 8 | |
michael@0 | 9 | $ECHO "\n** Running unit tests for MPI library\n" |
michael@0 | 10 | |
michael@0 | 11 | # Build the mpi-test program, which comprises all the unit tests for |
michael@0 | 12 | # the MPI library... |
michael@0 | 13 | |
michael@0 | 14 | $ECHO "Bringing mpi-test up to date ... " |
michael@0 | 15 | if $MAKE mpi-test ; then |
michael@0 | 16 | : |
michael@0 | 17 | else |
michael@0 | 18 | $ECHO " " |
michael@0 | 19 | $ECHO "Make failed to build mpi-test." |
michael@0 | 20 | $ECHO " " |
michael@0 | 21 | exit 1 |
michael@0 | 22 | fi |
michael@0 | 23 | |
michael@0 | 24 | if [ ! -x mpi-test ] ; then |
michael@0 | 25 | $ECHO " " |
michael@0 | 26 | $ECHO "Cannot find 'mpi-test' program, testing cannot continue." |
michael@0 | 27 | $ECHO " " |
michael@0 | 28 | exit 1 |
michael@0 | 29 | fi |
michael@0 | 30 | |
michael@0 | 31 | # Get the list of available test suites... |
michael@0 | 32 | tests=`./mpi-test list | awk '{print $1}'` |
michael@0 | 33 | errs=0 |
michael@0 | 34 | |
michael@0 | 35 | # Run each test suite and check the result code of mpi-test |
michael@0 | 36 | for test in $tests ; do |
michael@0 | 37 | $ECHO "$test ... \c" |
michael@0 | 38 | if ./mpi-test $test ; then |
michael@0 | 39 | $ECHO "passed" |
michael@0 | 40 | else |
michael@0 | 41 | $ECHO "FAILED" |
michael@0 | 42 | errs=1 |
michael@0 | 43 | fi |
michael@0 | 44 | done |
michael@0 | 45 | |
michael@0 | 46 | # If any tests failed, we'll stop at this point |
michael@0 | 47 | if [ "$errs" = "0" ] ; then |
michael@0 | 48 | $ECHO "All unit tests passed" |
michael@0 | 49 | else |
michael@0 | 50 | $ECHO "One or more tests failed" |
michael@0 | 51 | exit 1 |
michael@0 | 52 | fi |
michael@0 | 53 | |
michael@0 | 54 | # Now try to build the 'pi' program, and see if it can compute the |
michael@0 | 55 | # first thousand digits of pi correctly |
michael@0 | 56 | $ECHO "\n** Running other tests\n" |
michael@0 | 57 | |
michael@0 | 58 | $ECHO "Bringing 'pi' up to date ... " |
michael@0 | 59 | if $MAKE pi ; then |
michael@0 | 60 | : |
michael@0 | 61 | else |
michael@0 | 62 | $ECHO "\nMake failed to build pi.\n" |
michael@0 | 63 | exit 1 |
michael@0 | 64 | fi |
michael@0 | 65 | |
michael@0 | 66 | if [ ! -x pi ] ; then |
michael@0 | 67 | $ECHO "\nCannot find 'pi' program; testing cannot continue.\n" |
michael@0 | 68 | exit 1 |
michael@0 | 69 | fi |
michael@0 | 70 | |
michael@0 | 71 | ./pi 2000 > /tmp/pi.tmp.$$ |
michael@0 | 72 | if cmp tests/pi2k.txt /tmp/pi.tmp.$$ ; then |
michael@0 | 73 | $ECHO "Okay! The pi test passes." |
michael@0 | 74 | else |
michael@0 | 75 | $ECHO "Oops! The pi test failed. :(" |
michael@0 | 76 | exit 1 |
michael@0 | 77 | fi |
michael@0 | 78 | |
michael@0 | 79 | rm -f /tmp/pi.tmp.$$ |
michael@0 | 80 | |
michael@0 | 81 | exit 0 |
michael@0 | 82 | |
michael@0 | 83 | # Here there be dragons |