#!/bin/bash

dir=${1:-build}

rm -rf $dir/h5
mkdir $dir/h5

cd $dir
OK=0

function testSerial()
{
    if [ -e "$1" ]; then
        echo -e "\n$2\n"
        $1
        OK=$(( OK + $? ))
    fi
}
function testMPI()
{
    if [ -e "$1" ]; then
        echo -e "\n$3\n"
        mpirun -n $2 $1
        OK=$(( OK + $? ))
    fi
}

testSerial ./SimpleDataTest.cpp.out "Testing simple data read/write..."

testSerial ./AttributesTest.cpp.out "Testing reading/writing attributes..."

testSerial ./AppendTest.cpp.out "Testing append data..."

testSerial ./FileAccessTest.cpp.out "Testing file accesses..."

testSerial ./StridingTest.cpp.out "Testing striding access..."

testSerial ./RemoveTest.cpp.out "Testing removing datasets..."

testSerial ./ReferencesTest.cpp.out "Testing references..."

testMPI ./DomainsTest.cpp.out 8 "Testing domains..."

cd ..

exit $OK
