1
2export DEST="127.0.0.1"
3
4ts_log()
5{
6	echo "$@"
7}
8
9ts_err()
10{
11	ts_log "$@" | tee >> $ERRF
12}
13
14ts_cat()
15{
16	cat "$@"
17}
18
19ts_err_cat()
20{
21	ts_cat "$@" | tee >> $ERRF
22}
23
24ts_tc()
25{
26	SCRIPT=$1; shift
27	DESC=$1; shift
28	TMP_ERR=`mktemp /tmp/tc_testsuite.XXXXXX` || exit
29	TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX` || exit
30
31	$TC $@ 2> $TMP_ERR > $TMP_OUT
32
33	if [ -s $TMP_ERR ]; then
34		ts_err "${SCRIPT}: ${DESC} failed:"
35		ts_err "command: $TC $@"
36		ts_err "stderr output:"
37		ts_err_cat $TMP_ERR
38		if [ -s $TMP_OUT ]; then
39			ts_err "stdout output:"
40			ts_err_cat $TMP_OUT
41		fi
42	elif [ -s $TMP_OUT ]; then
43		echo "${SCRIPT}: ${DESC} succeeded with output:"
44		cat $TMP_OUT
45	else
46		echo "${SCRIPT}: ${DESC} succeeded"
47	fi
48
49	rm $TMP_ERR $TMP_OUT
50}
51
52ts_ip()
53{
54	SCRIPT=$1; shift
55	DESC=$1; shift
56	TMP_ERR=`mktemp /tmp/tc_testsuite.XXXXXX` || exit
57	TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX` || exit
58
59	$IP $@ 2> $TMP_ERR > $TMP_OUT
60
61	if [ -s $TMP_ERR ]; then
62		ts_err "${SCRIPT}: ${DESC} failed:"
63		ts_err "command: $IP $@"
64		ts_err "stderr output:"
65		ts_err_cat $TMP_ERR
66		if [ -s $TMP_OUT ]; then
67			ts_err "stdout output:"
68			ts_err_cat $TMP_OUT
69		fi
70	elif [ -s $TMP_OUT ]; then
71		echo "${SCRIPT}: ${DESC} succeeded with output:"
72		cat $TMP_OUT
73	else
74		echo "${SCRIPT}: ${DESC} succeeded"
75	fi
76
77	rm $TMP_ERR $TMP_OUT
78}
79
80ts_qdisc_available()
81{
82	HELPOUT=`$TC qdisc add $1 help 2>&1`
83	if [ "`echo $HELPOUT | grep \"^Unknown qdisc\"`" ]; then
84		return 0;
85	else
86		return 1;
87	fi
88}
89