#!/bin/bash
set -ex
ncpu="$(grep 'processor' /proc/cpuinfo | wc -l)"
echo "begin dump"
cat /proc/cpuinfo
echo "end dump"
echo variable "ncpu" is ${ncpu}
cd examples
cmake -Bbuild .
cd build
make -j${ncpu}
testbins=( $(find . -type f -executable | grep -v CMake) )
echo The testbins are: ${testbins[@]}
for bin in ${testbins[@]}; do
	echo running ${bin} ...
	if (echo ${bin} | grep -o fgbzip2); then
		./${bin} -b=9 -async ${bin}
	elif test tachyon = $(basename ${bin}); then
		echo skipped.
	elif (echo ${bin} | grep -o fractal); then
		./${bin} auto
	else
		./${bin}
	fi
done
cd ..
rm -rf build
