xref: /illumos-gate/usr/src/test/libc-tests/tests/symbols/setup.ksh (revision dc5e7685b131559c0b7c622baee25a9a0ae50ada)
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 2014 Garrett D'Amore <garrett@damore.org>
16#
17
18export STF_SUITE=/opt/libc-tests
19
20# First we set $dir to dirname $0, using efficient ksh builtins.
21case $0 in
22*/*)
23	dir=${0%/*}
24	prog=${0##*/}
25	;;
26*)
27	dir=.
28	prog=${0}
29	;;
30esac
31
32cfg=symbols/${prog%.ksh}.cfg
33
34if [[ ! -f ${cfg} && $cfg == symbols/setup.cfg ]]
35then
36	# compiler check only
37	cfg=-C
38fi
39
40prog=symbols_test
41
42for a in $*
43do
44	if [[ $a == "-d" ]]
45	then
46		debug=yes
47	fi
48done
49
50# We look for architecture specific versions of the program,
51# searching in several candidate directories.  We run each one as
52# we find it.
53for f in $(/usr/bin/isainfo)
54do
55	found=
56	[[ -n $debug ]] && print "Checking for arch $f:"
57	for p in \
58		${dir}/${prog}.${f} \
59		${dir}/${f}/${prog}.${f} \
60		${dir}/${f}/${prog}
61	do
62		[[ -n $found ]] && continue
63		[[ -n $debug ]] && print -n "     $p"
64		if [[ -f $p ]]; then
65			[[ -n $debug ]] && print " FOUND"
66			[[ -n $debug ]] && print "Executing $p $* ${cfg}"
67			found=yes
68			$p $* ${cfg} || exit 1
69		else
70			[[ -n $debug ]] && print
71		fi
72	done
73	[[ -z $found ]] && [[ -n $debug ]] && print "NOT PRESENT"
74done
75exit 0
76