#!/bin/bash

# Run ispc tests using the test suite
cd /usr/lib/ispc/ptest

# Run the test suite with minimal and fast tests
python3 run_tests.py --target=sse2-i32x4 --verbose --compiler=g++ 2>&1 | \
while IFS= read -r line; do
    case "$line" in
        *"PASSED"*|*passed*)
            echo "PASS: ${line}"
            ;;
        *"FAILED"*|*failed*|*ERROR*)
            echo "FAIL: ${line}"
            ;;
        *)
            echo "$line"
            ;;
    esac
done

# Check exit status
exit_code=${PIPESTATUS[0]}
if [ $exit_code -eq 0 ]; then
    echo "PASS: ispc test suite completed"
else
    echo "FAIL: ispc test suite failed with exit code $exit_code"
fi

exit $exit_code
