michael@0: #!/bin/sh michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ECHO=/bin/echo michael@0: MAKE=gmake michael@0: michael@0: $ECHO "\n** Running unit tests for MPI library\n" michael@0: michael@0: # Build the mpi-test program, which comprises all the unit tests for michael@0: # the MPI library... michael@0: michael@0: $ECHO "Bringing mpi-test up to date ... " michael@0: if $MAKE mpi-test ; then michael@0: : michael@0: else michael@0: $ECHO " " michael@0: $ECHO "Make failed to build mpi-test." michael@0: $ECHO " " michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -x mpi-test ] ; then michael@0: $ECHO " " michael@0: $ECHO "Cannot find 'mpi-test' program, testing cannot continue." michael@0: $ECHO " " michael@0: exit 1 michael@0: fi michael@0: michael@0: # Get the list of available test suites... michael@0: tests=`./mpi-test list | awk '{print $1}'` michael@0: errs=0 michael@0: michael@0: # Run each test suite and check the result code of mpi-test michael@0: for test in $tests ; do michael@0: $ECHO "$test ... \c" michael@0: if ./mpi-test $test ; then michael@0: $ECHO "passed" michael@0: else michael@0: $ECHO "FAILED" michael@0: errs=1 michael@0: fi michael@0: done michael@0: michael@0: # If any tests failed, we'll stop at this point michael@0: if [ "$errs" = "0" ] ; then michael@0: $ECHO "All unit tests passed" michael@0: else michael@0: $ECHO "One or more tests failed" michael@0: exit 1 michael@0: fi michael@0: michael@0: # Now try to build the 'pi' program, and see if it can compute the michael@0: # first thousand digits of pi correctly michael@0: $ECHO "\n** Running other tests\n" michael@0: michael@0: $ECHO "Bringing 'pi' up to date ... " michael@0: if $MAKE pi ; then michael@0: : michael@0: else michael@0: $ECHO "\nMake failed to build pi.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -x pi ] ; then michael@0: $ECHO "\nCannot find 'pi' program; testing cannot continue.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: ./pi 2000 > /tmp/pi.tmp.$$ michael@0: if cmp tests/pi2k.txt /tmp/pi.tmp.$$ ; then michael@0: $ECHO "Okay! The pi test passes." michael@0: else michael@0: $ECHO "Oops! The pi test failed. :(" michael@0: exit 1 michael@0: fi michael@0: michael@0: rm -f /tmp/pi.tmp.$$ michael@0: michael@0: exit 0 michael@0: michael@0: # Here there be dragons