#!/bin/bash
run_test() {
local test_py_file=$1
local test_name=${test_py_file##*/}
echo "[INFO] Running model test: ${test_name}"
if python3 "$test_py_file"; then
echo "[INFO] ${test_name} example passed!"
return 0
else
echo "[ERROR] ${test_name} example failed!"
return 1
fi
}
test_examples=(
"./python/test/kernels/test_vadd.py"
"./python/test/kernels/test_matmul.py"
)
passed_examples=()
failed_examples=()
export LD_PRELOAD=libruntime_camodel.so
for example in "${test_examples[@]}"; do
if run_test "$example"; then
passed_examples+=("$example")
else
failed_examples+=("$example")
fi
done
unset LD_PRELOAD
echo "[INFO] Passed tests list:"
for test in "${passed_examples[@]}"; do
echo " ${test##*/}"
done
if [ ${#failed_examples[@]} -eq 0 ]; then
echo "[INFO] All ${#test_examples[@]} tests passed!"
exit 0
else
echo "[ERROR] ${#failed_examples[@]} / ${#test_examples[@]} tests failed!"
echo "[INFO] Failed tests list:"
for test in "${failed_examples[@]}"; do
echo " ${test##*/}"
done
exit 1
fi