#!/bin/sh # Detect number of cores with Python >= 2.6. # For Python 2.5, you'll have to hard-code the value (or sed /proc/cpuinfo ;). CORES=$(python -c 'from multiprocessing import cpu_count; print cpu_count()' \ || exit 1) #CORES=1 NOSE="nosetests --with-doctest --doctest-tests --processes $CORES" HAS_MPD=$(which mpdallexit 2>/dev/null) if [ -n "$HAS_MPD" ]; then echo "Running nosetests with $CORES processes via MPI." LOCAL_MPD='' mpdtrace >/dev/null 2>&1 if [ "$?" -ne 0 ]; then LOCAL_MPD='1' mpd & # start an mpd instance sleep 1 # give mpd some time to start up fi # otherwise there is an mpd instance already running mpiexec -n 1 $NOSE pysawsim RESULT="$?" if [ -n "$LOCAL_MPD" ]; then mpdallexit fi if [ "$RESULT" -ne 0 ]; then exit 1; fi else # no MPD echo "Running nosetests with $CORES processes without MPI." $NOSE pysawsim || exit 1 fi