xref: /illumos-gate/usr/src/test/libc-tests/tests/common/run_arch_tests.ksh (revision 08855964b9970604433f7b19dcd71cf5af5e5f14)
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
18# First we set $dir to dirname $0, and $prog to basename $0 .ksh,
19# using efficient ksh builtins.
20case $0 in
21*/*)
22	dir=${0%/*}
23	prog=${0##*/}
24	;;
25*)
26	dir=.
27	prog=${0}
28	;;
29esac
30prog=${prog%.ksh}
31
32for a in $*
33do
34	if [[ $a == "-d" ]]
35	then
36		debug=yes
37	fi
38done
39
40# We look for architecture specific versions of the program,
41# searching in several candidate directories.  We run each one as
42# we find it.
43for f in $(/usr/bin/isainfo)
44do
45	found=
46	[[ -n $debug ]] && print "Checking for arch $f:"
47	for p in \
48		${dir}/${prog}.${f} \
49		${dir}/${f}/${prog}.${f} \
50		${dir}/${f}/${prog}
51	do
52		[[ -n $found ]] && continue
53		[[ -n $debug ]] && print -n "     $p"
54		if [[ -f $p ]]; then
55			[[ -n $debug ]] && print " FOUND"
56			[[ -n $debug ]] && print "Executing $p $*"
57			found=yes
58			$p $* || exit 1
59		else
60			[[ -n $debug ]] && print
61		fi
62	done
63	[[ -z $found ]] && [[ -n $debug ]] && print "NOT PRESENT"
64done
65exit 0
66