Path: blob/main/contrib/libucl/tests/run_tests.sh
104874 views
#!/bin/sh12if [ $# -lt 1 ] ; then3echo 'Specify binary to run as the first argument'4exit 15fi678for _tin in ${TEST_DIR}/*.in ; do9_t=`echo $_tin | sed -e 's/.in$//'`10$1 $_t.in $_t.out11if [ $? -ne 0 ] ; then12echo "Test: $_t failed, output:"13cat $_t.out14rm $_t.out15exit 116fi17if [ -f $_t.res ] ; then18diff -s $_t.out $_t.res -u 2>/dev/null19if [ $? -ne 0 ] ; then20rm $_t.out21echo "Test: $_t output mismatch"22exit 123fi24fi25rm $_t.out26done2728if [ $# -gt 2 ] ; then29$3 ${TEST_DIR}/generate.out30diff -s ${TEST_DIR}/generate.out ${TEST_DIR}/generate.res -u 2>/dev/null31if [ $? -ne 0 ] ; then32rm ${TEST_DIR}/generate.out33echo "Test: generate.res output mismatch"34exit 135fi36rm ${TEST_DIR}/generate.out37fi3839if [ $# -gt 3 ] ; then40rm /tmp/_ucl_test_schema.out ||true41for i in ${TEST_DIR}/schema/*.json ; do42_name=`basename $i`43printf "running schema test suite $_name... "44cat $i | $4 >> /tmp/_ucl_test_schema.out && ( echo "OK" ) || ( echo "Fail" )45done46fi4748sh -c "xz -c < /dev/null > /dev/null"49if [ $? -eq 0 -a $# -gt 1 ] ; then50echo 'Running speed tests'51for _tin in ${TEST_DIR}/*.xz ; do52echo "Unpacking $_tin..."53xz -cd < $_tin > ${TEST_DIR}/test_file54# Preread file to cheat benchmark!55cat ${TEST_DIR}/test_file > /dev/null56echo "Starting benchmarking for $_tin..."57$2 ${TEST_DIR}/test_file58if [ $? -ne 0 ] ; then59echo "Test: $_tin failed"60rm ${TEST_DIR}/test_file61exit 162fi63rm ${TEST_DIR}/test_file64done65fi66676869