sun_solaris_getconf.sh revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# sun_solaris_getconf.sh - test the ksh93 getconf builtin for compatibility
#
# test setup
function err_exit
{
print -u2 -n "\t"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
integer Errors=0
# setup
integer mismatch # counts mismatches between builtin and external command
integer getconf_keys # counts tests (paranoid check to make sure the test loop works)
# prechecks
function compare_normal
{
mismach=0 getconf_keys=0
while read i ; do
let getconf_keys++
t="${i%:*}"
if [ "$a" != "$b" ] ; then
let mismatch++
fi
done
}
function compare_path
{
mismach=0 getconf_keys=0
while read i ; do
let getconf_keys++
t="${i%:*}"
if [ "$a" != "$b" ] ; then
let mismatch++
fi
done
}
# future versions of this test should test the following ${PATH}s, too:
for i in \
do
export PATH="${i}"
## test whether the getconf builtin is available
fi
## compare "getconf -a" output
err_exit 'getconf -a output mismatch.'
fi
## check for a key which is only supported by the AST builtin version of getconf:
err_exit 'getconf LIBPREFIX did not return "lib".'
fi
## run normal test
[ ${mismatch} -gt 0 ] && err_exit "getconf/normal test found ${mismatch} differences (PATH=${PATH})."
# run the same test in a seperate shell
${SHELL} -c "integer mismatch ; \
integer getconf_keys ; \
compare_normal ;
[ \${mismatch} -gt 0 ] && err_exit \"getconf/normal test found \${mismatch} differences (PATH=\${PATH}).\" ; \
let Errors+=$?
## run test with path argument
# run the same test in a seperate shell
# (see comment above)
${SHELL} -c "integer mismatch ; \
integer getconf_keys ; \
compare_path ;
[ \${mismatch} -gt 0 ] && err_exit \"getconf/normal test found \${mismatch} differences (PATH=\${PATH}).\" ; \
let Errors+=$?
done
# test done