xref: /freebsd/contrib/libucl/tests/run_tests.sh (revision c99fb5f907eccde7b4c6d53e650e1a32a558f0d8)
1*c99fb5f9SBaptiste Daroussin#!/bin/sh
2*c99fb5f9SBaptiste Daroussin
3*c99fb5f9SBaptiste Daroussinif [ $# -lt 1 ] ; then
4*c99fb5f9SBaptiste Daroussin	echo 'Specify binary to run as the first argument'
5*c99fb5f9SBaptiste Daroussin	exit 1
6*c99fb5f9SBaptiste Daroussinfi
7*c99fb5f9SBaptiste Daroussin
8*c99fb5f9SBaptiste Daroussin
9*c99fb5f9SBaptiste Daroussinfor _tin in ${TEST_DIR}/*.in ; do
10*c99fb5f9SBaptiste Daroussin	_t=`echo $_tin | sed -e 's/.in$//'`
11*c99fb5f9SBaptiste Daroussin	$1 $_t.in $_t.out
12*c99fb5f9SBaptiste Daroussin	if [ $? -ne 0 ] ; then
13*c99fb5f9SBaptiste Daroussin		echo "Test: $_t failed, output:"
14*c99fb5f9SBaptiste Daroussin		cat $_t.out
15*c99fb5f9SBaptiste Daroussin		rm $_t.out
16*c99fb5f9SBaptiste Daroussin		exit 1
17*c99fb5f9SBaptiste Daroussin	fi
18*c99fb5f9SBaptiste Daroussin	if [ -f $_t.res ] ; then
19*c99fb5f9SBaptiste Daroussin	diff -s $_t.out $_t.res -u 2>/dev/null
20*c99fb5f9SBaptiste Daroussin		if [ $? -ne 0 ] ; then
21*c99fb5f9SBaptiste Daroussin			rm $_t.out
22*c99fb5f9SBaptiste Daroussin			echo "Test: $_t output missmatch"
23*c99fb5f9SBaptiste Daroussin			exit 1
24*c99fb5f9SBaptiste Daroussin		fi
25*c99fb5f9SBaptiste Daroussin	fi
26*c99fb5f9SBaptiste Daroussin	rm $_t.out
27*c99fb5f9SBaptiste Daroussindone
28*c99fb5f9SBaptiste Daroussin
29*c99fb5f9SBaptiste Daroussinif [ $# -gt 2 ] ; then
30*c99fb5f9SBaptiste Daroussin	$3 ${TEST_DIR}/generate.out
31*c99fb5f9SBaptiste Daroussin	diff -s ${TEST_DIR}/generate.out ${TEST_DIR}/generate.res -u 2>/dev/null
32*c99fb5f9SBaptiste Daroussin	if [ $? -ne 0 ] ; then
33*c99fb5f9SBaptiste Daroussin		rm ${TEST_DIR}/generate.out
34*c99fb5f9SBaptiste Daroussin		echo "Test: generate.res output missmatch"
35*c99fb5f9SBaptiste Daroussin    	exit 1
36*c99fb5f9SBaptiste Daroussin	fi
37*c99fb5f9SBaptiste Daroussin	rm ${TEST_DIR}/generate.out
38*c99fb5f9SBaptiste Daroussinfi
39*c99fb5f9SBaptiste Daroussin
40*c99fb5f9SBaptiste Daroussinsh -c "xz -c < /dev/null > /dev/null"
41*c99fb5f9SBaptiste Daroussinif [ $? -eq 0 -a $# -gt 1 ] ; then
42*c99fb5f9SBaptiste Daroussin	echo 'Running speed tests'
43*c99fb5f9SBaptiste Daroussin	for _tin in ${TEST_DIR}/*.xz ; do
44*c99fb5f9SBaptiste Daroussin		echo "Unpacking $_tin..."
45*c99fb5f9SBaptiste Daroussin		xz -cd < $_tin > ${TEST_DIR}/test_file
46*c99fb5f9SBaptiste Daroussin		# Preread file to cheat benchmark!
47*c99fb5f9SBaptiste Daroussin		cat ${TEST_DIR}/test_file > /dev/null
48*c99fb5f9SBaptiste Daroussin		echo "Starting benchmarking for $_tin..."
49*c99fb5f9SBaptiste Daroussin		$2 ${TEST_DIR}/test_file
50*c99fb5f9SBaptiste Daroussin		if [ $? -ne 0 ] ; then
51*c99fb5f9SBaptiste Daroussin			echo "Test: $_tin failed"
52*c99fb5f9SBaptiste Daroussin			rm ${TEST_DIR}/test_file
53*c99fb5f9SBaptiste Daroussin			exit 1
54*c99fb5f9SBaptiste Daroussin		fi
55*c99fb5f9SBaptiste Daroussin		rm ${TEST_DIR}/test_file
56*c99fb5f9SBaptiste Daroussin	done
57*c99fb5f9SBaptiste Daroussinfi
58*c99fb5f9SBaptiste Daroussin
59