598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore#!/usr/bin/ksh
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore#
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# This file and its contents are supplied under the terms of the
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# Common Development and Distribution License ("CDDL"), version 1.0.
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# You may only use this file in accordance with the terms of version
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# 1.0 of the CDDL.
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore#
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# A full copy of the text of the CDDL should have accompanied this
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# source. A copy of the CDDL is also available via the Internet at
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# http://www.illumos.org/license/CDDL.
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore#
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore#
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# Copyright (c) 2012 by Delphix. All rights reserved.
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore# Copyright 2014 Garrett D'Amore <garrett@damore.org>
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore#
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amoreexport MY_TESTS="/opt/util-tests"
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amorerunner="/opt/test-runner/bin/run"
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amorefunction fail
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore{
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore echo $1
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore exit ${2:-1}
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore}
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amorefunction find_runfile
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore{
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore typeset distro=
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore if [[ -d /opt/delphix && -h /etc/delphix/version ]]; then
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore distro=delphix
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore elif [[ 0 -ne $(grep -c OpenIndiana /etc/release 2>/dev/null) ]]; then
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore distro=openindiana
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore elif [[ 0 -ne $(grep -c OmniOS /etc/release 2>/dev/null) ]]; then
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore distro=omnios
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore elif [[ -f $MY_TESTS/runfiles/default.run ]]; then
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore # optional catch-all
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore distro=default
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore fi
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore [[ -n $distro ]] && echo $MY_TESTS/runfiles/$distro.run
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore}
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amorewhile getopts c: c; do
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore case $c in
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore 'c')
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore runfile=$OPTARG
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore [[ -f $runfile ]] || fail "Cannot read file: $runfile"
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore ;;
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore esac
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amoredone
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amoreshift $((OPTIND - 1))
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore[[ -z $runfile ]] && runfile=$(find_runfile)
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore[[ -z $runfile ]] && fail "Couldn't determine distro"
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore$runner -c $runfile
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amore
598f4ceed9327d2d6c2325dd67cae3aa06f7fea6Garrett D'Amoreexit $?