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