1*de572d98SGarrett D'Amore#!/usr/bin/ksh
2*de572d98SGarrett D'Amore#
3*de572d98SGarrett D'Amore#
4*de572d98SGarrett D'Amore# This file and its contents are supplied under the terms of the
5*de572d98SGarrett D'Amore# Common Development and Distribution License ("CDDL"), version 1.0.
6*de572d98SGarrett D'Amore# You may only use this file in accordance with the terms of version
7*de572d98SGarrett D'Amore# 1.0 of the CDDL.
8*de572d98SGarrett D'Amore#
9*de572d98SGarrett D'Amore# A full copy of the text of the CDDL should have accompanied this
10*de572d98SGarrett D'Amore# source.  A copy of the CDDL is also available via the Internet at
11*de572d98SGarrett D'Amore# http://www.illumos.org/license/CDDL.
12*de572d98SGarrett D'Amore#
13*de572d98SGarrett D'Amore
14*de572d98SGarrett D'Amore#
15*de572d98SGarrett D'Amore# Copyright 2014 Garrett D'Amore <garrett@damore.org>
16*de572d98SGarrett D'Amore#
17*de572d98SGarrett D'Amore
18*de572d98SGarrett D'Amoreexport STF_SUITE=/opt/libc-tests
19*de572d98SGarrett D'Amore
20*de572d98SGarrett D'Amore# First we set $dir to dirname $0, using efficient ksh builtins.
21*de572d98SGarrett D'Amorecase $0 in
22*de572d98SGarrett D'Amore*/*)
23*de572d98SGarrett D'Amore	dir=${0%/*}
24*de572d98SGarrett D'Amore	prog=${0##*/}
25*de572d98SGarrett D'Amore	;;
26*de572d98SGarrett D'Amore*)
27*de572d98SGarrett D'Amore	dir=.
28*de572d98SGarrett D'Amore	prog=${0}
29*de572d98SGarrett D'Amore	;;
30*de572d98SGarrett D'Amoreesac
31*de572d98SGarrett D'Amore
32*de572d98SGarrett D'Amorecfg=symbols/${prog%.ksh}.cfg
33*de572d98SGarrett D'Amore
34*de572d98SGarrett D'Amoreif [[ ! -f ${cfg} && $cfg == symbols/setup.cfg ]]
35*de572d98SGarrett D'Amorethen
36*de572d98SGarrett D'Amore	# compiler check only
37*de572d98SGarrett D'Amore	cfg=-C
38*de572d98SGarrett D'Amorefi
39*de572d98SGarrett D'Amore
40*de572d98SGarrett D'Amoreprog=symbols_test
41*de572d98SGarrett D'Amore
42*de572d98SGarrett D'Amorefor a in $*
43*de572d98SGarrett D'Amoredo
44*de572d98SGarrett D'Amore	if [[ $a == "-d" ]]
45*de572d98SGarrett D'Amore	then
46*de572d98SGarrett D'Amore		debug=yes
47*de572d98SGarrett D'Amore	fi
48*de572d98SGarrett D'Amoredone
49*de572d98SGarrett D'Amore
50*de572d98SGarrett D'Amore# We look for architecture specific versions of the program,
51*de572d98SGarrett D'Amore# searching in several candidate directories.  We run each one as
52*de572d98SGarrett D'Amore# we find it.
53*de572d98SGarrett D'Amorefor f in $(/usr/bin/isainfo)
54*de572d98SGarrett D'Amoredo
55*de572d98SGarrett D'Amore	found=
56*de572d98SGarrett D'Amore	[[ -n $debug ]] && print "Checking for arch $f:"
57*de572d98SGarrett D'Amore	for p in \
58*de572d98SGarrett D'Amore		${dir}/${prog}.${f} \
59*de572d98SGarrett D'Amore		${dir}/${f}/${prog}.${f} \
60*de572d98SGarrett D'Amore		${dir}/${f}/${prog}
61*de572d98SGarrett D'Amore	do
62*de572d98SGarrett D'Amore		[[ -n $found ]] && continue
63*de572d98SGarrett D'Amore		[[ -n $debug ]] && print -n "     $p"
64*de572d98SGarrett D'Amore		if [[ -f $p ]]; then
65*de572d98SGarrett D'Amore			[[ -n $debug ]] && print " FOUND"
66*de572d98SGarrett D'Amore			[[ -n $debug ]] && print "Executing $p $* ${cfg}"
67*de572d98SGarrett D'Amore			found=yes
68*de572d98SGarrett D'Amore			$p $* ${cfg} || exit 1
69*de572d98SGarrett D'Amore		else
70*de572d98SGarrett D'Amore			[[ -n $debug ]] && print
71*de572d98SGarrett D'Amore		fi
72*de572d98SGarrett D'Amore	done
73*de572d98SGarrett D'Amore	[[ -z $found ]] && [[ -n $debug ]] && print "NOT PRESENT"
74*de572d98SGarrett D'Amoredone
75*de572d98SGarrett D'Amoreexit 0
76