c version of runtests.sh