xref: /titanic_44/usr/src/test/os-tests/cmd/ostest.ksh (revision 5fd03bc0f2e00e7ba02316c2e08f45d52aab15db)
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) 2012 by Delphix. All rights reserved.
16# Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
17#
18
19export OS_TESTS="/opt/os-tests"
20runner="/opt/test-runner/bin/run"
21
22function fail
23{
24	echo $1
25	exit ${2:-1}
26}
27
28function find_runfile
29{
30	typeset distro=
31	if [[ -d /opt/delphix && -h /etc/delphix/version ]]; then
32		distro=delphix
33	elif [[ 0 -ne $(grep -c OpenIndiana /etc/release 2>/dev/null) ]]; then
34		distro=openindiana
35	elif [[ 0 -ne $(grep -c OmniOS /etc/release 2>/dev/null) ]]; then
36		distro=omnios
37	fi
38
39	[[ -n $distro ]] && echo $OS_TESTS/runfiles/$distro.run
40}
41
42while getopts c: c; do
43	case $c in
44	'c')
45		runfile=$OPTARG
46		[[ -f $runfile ]] || fail "Cannot read file: $runfile"
47		;;
48	esac
49done
50shift $((OPTIND - 1))
51
52[[ -z $runfile ]] && runfile=$(find_runfile)
53[[ -z $runfile ]] && fail "Couldn't determine distro"
54
55$runner -c $runfile
56
57exit $?
58