summaryrefslogtreecommitdiff
path: root/xts5/bin/xts-run.in
blob: 2a6c992c959f985b305c8c3c3073aac60aae9352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh

bindir="%bindir%"
DEFAULT_TET_ROOT="%DEFAULT_TET_ROOT%"
PACKAGE_VERSION="%PACKAGE_VERSION%"

TCC="${TCC-${bindir}/tcc}"
PERL=${PERL-perl}
XTS_CONFIG="${XTS_CONFIG-${bindir}/xts-config}"
XTS_REPORT="${XTS_REPORT-${bindir}/xts-report}"

prog=$0
config=
config_in="${TET_ROOT-$DEFAULT_TET_ROOT}/xts5/tetexec.cfg.in"
basedir=xts-results
scenario=

help()
{
	cat << EOF
Usage: $prog [OPTION]... [SCENARIO]
Execute the XTS tests in SCENARIO (all by default).

  -c, --config CONFIG		use the tet config file CONFIG
  -h, --help			display this help text and exit
  -o, --output DIRECTORY	output results in DIRECTORY
				  (default: $basedir)
  -V, --version			display the version and exit
EOF
}

while [ -n "$1" ]; do
	case "$1" in
	-c|--config)
		config=$2
		shift
		;;
	-o|--output)
		basedir=$2
		shift
		;;
	-h|--help)
		help
		exit 0
		;;
	-V|--version)
		echo $PACKAGE_VERSION
		exit 0
		;;
	-*)
		echo "error: unrecognized option \"$1\"" >&2
		echo "See \"$prog --help\" for more information" >&2
		exit 1
		;;
	*)
		if [ -n "$scenario" ]; then
			echo "error: only one scenario allowed" >&2
			exit 1
		fi
		scenario=$1
	esac
	shift
done

# Create the config file if necessary
if [ -z "$config" ]; then
	config=`mktemp tetexec.cfg.XXXXXXXXXX`
	trap 'rm -f "$config"' 0 1 2 3 15
	if ! "$PERL" "$XTS_CONFIG" < "$config_in" > "$config"; then
		echo "error: failed to create config file $config" >&2
		exit 1
	fi		
else
	if [ ! -r "$config" ]; then
		echo "error: cannot read config file $config" >&2
		exit 1
	fi
fi

# Create the output directory
outdir="$basedir/`date +%F-%T`"
if [ ! -d "$outdir" ] && ! mkdir -p "$outdir"; then
	echo "error: failed to create output directory $outdir" >&2
	exit 1
fi

# run the tests
"$TCC" -e -i "$outdir" -x "$config" xts5 $scenario
ret=$?

# generate a short report
"$XTS_REPORT" -d2 -f "$outdir/journal" > "$outdir/summary"

# return the tcc exit code
exit $ret