#!/bin/sh

failed=0
all=0

for f in *.run *.sh; do
    [ -f "$f" ] || continue
    case "$f" in
        *.run) ./run "$f" ;;
        *.sh) sh "$f" ;;
    esac
    case "$?" in
        0)
            echo "PASS: $f"
            all=$((all + 1))
            ;;
        77)
            echo "SKIP: $f"
            ;;
        *)
            echo "FAIL: $f"
            failed=$((failed + 1))
            all=$((all + 1))
            ;;
    esac
done

if [ "$failed" -eq 0 ] ; then
    echo "All $all tests passed"
    exit 0
else
    echo "$failed of $all tests failed"
    exit 1
fi
