xref: /illumos-gate/usr/src/test/libmlrpc-tests/cmd/libmlrpctest.ksh (revision 3cac7b0d73edf3f2674ad0f64d1fff3d2e59ae8c)
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 2020 Tintri by DDN, Inc. All rights reserved.
17#
18
19export MLRPC_TESTS="/opt/libmlrpc-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 [[ -f $MLRPC_TESTS/runfiles/default.run ]]; then
32		distro=default
33	fi
34
35	[[ -n $distro ]] && echo $MLRPC_TESTS/runfiles/$distro.run
36}
37
38while getopts c: c; do
39	case $c in
40	'c')
41		runfile=$OPTARG
42		[[ -f $runfile ]] || fail "Cannot read file: $runfile"
43		;;
44	esac
45done
46shift $((OPTIND - 1))
47
48[[ -z $runfile ]] && runfile=$(find_runfile)
49[[ -z $runfile ]] && fail "Couldn't determine distro"
50
51$runner -c $runfile
52
53exit $?
54