Imported Upstream version 1.15.1
[platform/upstream/krb5.git] / src / kadmin / testing / scripts / env-setup.shin
1 #!/bin/sh
2 #
3 # The KADM5 unit tests were developed to work under gmake.  As a
4 # result, they expect to inherit a number of environment variables.
5 # Rather than rewrite the tests, we simply use this script as an
6 # execution wrapper that sets all the necessary environment variables
7 # before running the program specified on its command line.
8 #
9 # The variable settings all came from OV's config.mk.
10 #
11 # Usage: env-setup.sh <command line>
12 #
13
14 TOP=@RBUILD@/kadmin
15 STOP=@S_TOP@/kadmin
16 export TOP
17 export STOP
18 # These two may be needed in case $libdir references them.
19 prefix=@prefix@
20 exec_prefix=@exec_prefix@
21 libdir=@libdir@ ; eval "libdir=$libdir"; export libdir
22
23 # The shared library run time setup
24 TOPLIBD=@RBUILD@/lib
25 PROG_LIBPATH=-L@RBUILD@/lib
26 BUILDTOP=@RBUILD@
27 # XXX kludge!
28 PROG_RPATH=@RBUILD@/lib
29 # This converts $(TOPLIBD) to $TOPLIBD
30 cat > /tmp/env_setup$$ <<\EOF
31 @KRB5_RUN_ENV@
32 EOF
33
34 foo=`sed -e 's/(//g' -e 's/)//g' -e 's/\\\$\\\$/\$/g' /tmp/env_setup$$`
35 eval $foo
36 export @KRB5_RUN_VARS@
37
38 # This will get put in setup.csh for convenience
39 KRB5_RUN_ENV_CSH=`eval echo "$foo" | \
40         sed -e 's/\([^=]*\)=\(.*\)/setenv \1 \2/g'`
41 export KRB5_RUN_ENV_CSH
42 rm /tmp/env_setup$$
43
44 TESTDIR=$TOP/testing; export TESTDIR
45 STESTDIR=$STOP/testing; export STESTDIR
46 if [ "$K5ROOT" = "" ]; then
47         K5ROOT="`cd $TESTDIR; pwd`/krb5-test-root"
48         export K5ROOT
49 fi
50
51 # If $VERBOSE_TEST is non-null, enter verbose mode.  Set $VERBOSE to
52 # true or false so its exit status identifies the mode.
53 if test x$VERBOSE_TEST = x; then
54         VERBOSE=false
55 else
56         VERBOSE=true
57 fi
58 export VERBOSE
59
60 REALM=SECURE-TEST.OV.COM; export REALM
61
62 if test x$EXPECT = x; then
63     EXPECT=@EXPECT@; export EXPECT
64 fi
65
66 COMPARE_DUMP=$TESTDIR/scripts/compare_dump.pl; export COMPARE_DUMP
67 INITDB=$STESTDIR/scripts/init_db; export INITDB
68 MAKE_KEYTAB=$TESTDIR/scripts/make-host-keytab.pl; export MAKE_KEYTAB
69 LOCAL_MAKE_KEYTAB=$TESTDIR/scripts/make-host-keytab.pl
70 export LOCAL_MAKE_KEYTAB
71 SIMPLE_DUMP=$TESTDIR/scripts/simple_dump.pl; export SIMPLE_DUMP
72 QUALNAME=$TESTDIR/scripts/qualname.pl; export QUALNAME
73 TCLUTIL=$STESTDIR/tcl/util.t; export TCLUTIL
74 BSDDB_DUMP=$TESTDIR/util/bsddb_dump; export BSDDB_DUMP
75 CLNTTCL=$TESTDIR/util/kadm5_clnt_tcl; export CLNTTCL
76 SRVTCL=$TESTDIR/util/kadm5_srv_tcl; export SRVTCL
77
78 KRB5_CONFIG=$K5ROOT/krb5.conf; export KRB5_CONFIG
79 KRB5_KDC_PROFILE=$K5ROOT/kdc.conf; export KRB5_KDC_PROFILE
80 KRB5_KTNAME=$K5ROOT/ovsec_adm.srvtab; export KRB5_KTNAME
81 KRB5_CLIENT_KTNAME=$K5ROOT/client_keytab; export KRB5_CLIENT_KTNAME
82 KRB5CCNAME=$K5ROOT/krb5cc_unit-test; export KRB5CCNAME
83
84 # Make sure we don't get confused by translated messages
85 # or localized times.
86 LC_ALL=C; export LC_ALL
87
88 if [ "$TEST_SERVER" != "" ]; then
89         MAKE_KEYTAB="$MAKE_KEYTAB -server $TEST_SERVER"
90 fi
91 if [ "$TEST_PATH" != "" ]; then
92         MAKE_KEYTAB="$MAKE_KEYTAB -top $TEST_PATH"
93 fi
94
95 if [ "x$PS_ALL" = "x" ]; then
96         if ps auxww >/dev/null 2>&1; then
97                 PS_ALL="ps auxww"
98                 PS_PID="ps uwwp"
99         elif ps -ef >/dev/null 2>&1; then
100                 PS_ALL="ps -ef"
101                 PS_PID="ps -fp"
102         else
103                 PS_ALL="ps auxww"
104                 PS_PID="ps uwwp"
105                 echo "WARNING!  Cannot auto-detect ps type, assuming BSD."
106         fi
107
108         export PS_ALL PS_PID
109 fi
110
111 exec ${1+"$@"}