Skip to content

Instantly share code, notes, and snippets.

@karolherbst
Last active May 2, 2018 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karolherbst/1373fa96baa1e1045573dbb91d125290 to your computer and use it in GitHub Desktop.
Save karolherbst/1373fa96baa1e1045573dbb91d125290 to your computer and use it in GitHub Desktop.
#!/bin/bash
# some env vars
export CL_TEST_SINGLE_THREADED=1
export CLOVER_PLATFORM_VERSION_OVERRIDE="1.2"
export CLOVER_DEVICE_VERSION_OVERRIDE="1.2"
export CLOVER_DEVICE_CLC_VERSION_OVERRIDE="1.2"
declare -A testcases=(
["api"]="./api/test_api"
["allocations"]="./allocations/test_allocations"
["atomics"]="./atomics/test_atomics"
["basic"]="./basic/test_basic"
["buffers"]="./buffers/test_buffers"
["commonfns"]="./commonfns/test_commonfns"
["compiler"]="./compiler/test_compiler"
["computeinfo"]="./computeinfo/test_computeinfo"
["contractions"]="./contractions/test_contractions"
["conversions"]="./conversions/test_conversions -w"
["device_partition"]="./device_partition/test_device_partition"
["events"]="./events/test_events"
["geometrics"]="./geometrics/test_geometrics"
["half"]="./half/test_half"
["image_info"]="./images/clGetInfo/test_cl_get_info "
["image_methods"]="./images/kernel_image_methods/test_kernel_image_methods"
["integer_ops"]="./integer_ops/test_integer_ops"
["math_brute_force"]="./math_brute_force/test_bruteforce"
["mem_host_flags"]="./mem_host_flags/test_mem_host_flags"
["multiple_device_context"]="./multiple_device_context/test_multiples"
["profiling"]="./profiling/test_profiling"
["printf"]="./printf/test_printf"
["relationals"]="./relationals/test_relationals"
["select"]="./select/test_select -w"
["thread_dimensions"]="./thread_dimensions/test_thread_dimensions"
["vec_align"]="./vec_align/test_vecalign"
["vec_step"]="./vec_step/test_vecstep"
)
multitestcases=(
"api"
"atomics"
"basic"
"buffers"
"commonfns"
"compiler"
"device_partition"
"events"
"geometrics"
"mem_host_flags"
"multiple_device_context"
"profiling"
"relationals"
"thread_dimensions"
"vec_align"
"vec_step"
)
singletestcases=(
"computeinfo"
"contractions"
"half"
"image_info"
"image_methods"
"printf"
)
# some hardcoded tests
tests=(
"allocations" "single@5@buffer"
"allocations" "single@5@image2d_read"
"allocations" "single@5@image2d_write"
"allocations" "single@5@buffer_non_blocking"
"allocations" "single@5@image2d_read_non_blocking"
"allocations" "single@5@image2d_write_non_blocking"
"allocations" "multiple@5@buffer"
"allocations" "multiple@5@image2d_read"
"allocations" "multiple@5@image2d_write"
"allocations" "multiple@5@buffer_non_blocking"
"allocations" "multiple@5@image2d_read_non_blocking"
"allocations" "multiple@5@image2d_write_non_blocking"
)
# generate some other test lists
for src in uchar char ushort short uint int float double ulong long ; do
for dst in uchar char ushort short uint int float double ulong long ; do
tests+=( "conversions" "${dst}_${src}" )
if [ "$dst" != "float" ] && [ "$dst" != "double" ] ; then
tests+=( "conversions" "${dst}_sat_${src}" )
fi
# only interesting if floats are involved
if [ "$dst" == "float" ] || [ "$dst" == "double" ] || [ "$src" == "float" ] || [ "$src" == "double" ]; then
for round in rte rtp rtn rtz ; do
tests+=( "conversions" "${dst}_${round}_${src}" )
if [ "$dst" != "float" ] && [ "$dst" != "double" ] ; then
tests+=( "conversions" "${dst}_sat_${round}_${src}" )
fi
done
fi
done
done
for src in char short int long ; do
tests+=(
"select" "select_${src}_${src}"
"select" "select_u${src}_${src}"
"select" "select_${src}_u${src}"
"select" "select_u${src}_u${src}"
)
done
logd=$(mktemp -d)
nfailed=0
passed=()
failed=()
# generate interger_ops test list
for type in long ulong int uint short ushort char uchar ; do
for op in math logic shift compare ; do
tests+=( "integer_ops" "quick_${type}_${op}" )
done
done
for test in $(${testcases["integer_ops"]} -h | grep -A99999 '^Usage:' | grep -v \< | sed "s/^[ \t]*//" | grep -e ^integer_ -e ^unary_ops_ -e popcount); do
tests+=( "integer_ops" "$test" )
done
# tests with only a single test
for key in ${singletestcases[@]}; do
tests+=( "$key __internal__fake__test__" )
done
# tests with multiple tests
for key in ${multitestcases[@]}; do
for test in $(${testcases[$key]} -h | grep -A99999 '^Usage:' | grep -v \< | sed "s/^[ \t]*//"); do
tests+=( "$key $test" )
done
done
# math bruteforce is stupid
for test in $(${testcases["math_brute_force"]} -p | grep '^Math function names:' -A9999999 | grep -v '^Math function names:' | grep -v \< | sed "s/^[ \t]*//"); do
tests+=( "math_brute_force $test" )
done
export timeout_dur='25m'
handler() {
source "$logd/__testcases.sh"
exe=${testcases[$1]}
arg=${2/__internal__fake__test__/}
filename="$1"
[ -n "$arg" ] && filename+="_$arg"
if ! ( timeout $timeout_dur $exe ${arg//@/ } || false ) > "${logd}/$filename.log" 2>&1; then
echo "$1 $arg" >> "${logd}"/__failed_tests.tmp
else
echo "$1 $arg" >> "${logd}"/__passed_tests.tmp
fi
}
export -f handler
export logd
declare -p testcases > $logd/__testcases.sh
echo "logs stored inside $logd"
printf "%s %s\n" ${tests[@]} | parallel --bar --colsep ' ' handler {} {}
cat "${logd}"/__failed_tests.tmp | sort > "${logd}"/__failed_tests
cat "${logd}"/__passed_tests.tmp | sort > "${logd}"/__passed_tests
echo "Outputing process outputs:"
echo ""
cat "${logd}"/__*_tests | sort | while read line; do echo "$line" ; cat "${logd}"/${line// /_}.log; echo ""; done
fails=$(cat "${logd}"/__failed_tests | wc -l)
passes=$(cat "${logd}"/__passed_tests | wc -l)
echo "Failed tests ($fails):"
cat "${logd}"/__failed_tests
echo ""
echo "Passed tests ($passes):"
cat "${logd}"/__passed_tests
rm -rf "$logd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment