xref: /titanic_50/usr/src/test/util-tests/tests/libsff/libsff.ksh (revision 59596c01ca1b980a016d25670874f53e64c27ec0)
1#! /usr/bin/ksh
2#
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright (c) 2017, Joyent, Inc.
16#
17
18#
19# Run all of the various libsff tests.
20#
21
22unalias -a
23sff_arg0=$(basename $0)
24sff_origwd=
25sff_root=
26sff_tests="8472 br compliance conn enc ident lengths opts strings wave"
27sff_tests="$sff_tests 8636_diag 8636_extspec 8636_tech 8636_temp einval efault"
28sff_outfile="/tmp/$sff_arg0.out.$$"
29
30fatal()
31{
32	typeset msg="$*"
33	[[ -z "$msg" ]] && msg="failed"
34	echo "TEST FAILED: $sff_arg0: $msg" >&2
35	rm -f $sff_outfile
36	exit 1
37}
38
39sff_origwd=$PWD
40cd $(dirname $0) || fatal "failed to cd to test root"
41sff_root=$PWD
42cd $dt_origwd || fatal "failed to return to original dir"
43
44for t in $sff_tests; do
45	difffile=
46	testfile=$sff_root/libsff_$t
47
48	if ! $testfile > $sff_outfile; then
49		fatal "failed to run $testfile"
50	fi
51
52	if [[ -f $testfile.out ]]; then
53		if ! diff $testfile.out $sff_outfile >/dev/null; then
54			fatal "$t results differ from expected values"
55		fi
56	fi
57	printf "TEST PASSED: libsff_%s\n" $t
58done
59
60rm -f $sff_outfile || fatal "failed to remove output file"
61exit 0
62