1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
# common preamble for lots of parts of the PCP QA environment ...
# set $PATH, config-driven setup, etc
#
# Copyright (c) 1997-2002 Silicon Graphics, Inc. All Rights Reserved.
#
#
# From pcpintro(1) man page ...
#
unset PCP_STDERR PCP_SECURE_SOCKETS
unset PMCD_CONNECT_TIMEOUT PMCD_RECONNECT_TIMEOUT
unset PMCD_REQUEST_TIMEOUT PMCD_WAIT_TIMEOUT
unset PMNS_DEFAULT PCP_COUNTER_WRAP
unset PMDA_PATH PMCD_PORT PMLOGGER_PORT
unset PMDA_LOCAL_PROC PMDA_LOCAL_SAMPLE PMIECONF_PATH
unset PMPROXY_PORT PMPROXY_HOST
# source the PCP configuration environment variables
if [ -r $PCP_DIR/etc/pcp.env ]
then
. $PCP_DIR/etc/pcp.env
else
echo "Error: unable to read $PCP_DIR/etc/pcp.env!" >&2
exit 1
fi
# augment $PATH for QA specific dirs
#
for __dir in /sbin /usr/sbin
do
[ -d "$__dir" ] && PATH="$PATH:$__dir"
done
export PATH
# QA default environment variables
PCP_PMCD_PROG=$PCP_BINADM_DIR/pmcd
PCP_PMCDLOG_PATH=$PCP_LOG_DIR/pmcd/pmcd.log
export PCP_PMCD_PROG PCP_PMCDLOG_PATH
# In openSUSE 12.1, /etc/rc.status intercepts our rc script and passes
# control to systemctl which uses systemd ... the result is that messages
# from our rc scripts are sent to syslog by default, and there is no
# apparent way to revert to the classical behaviour, so this "hack" allows
# PCP QA to set $PCPQA_NO_RC_STATUS and continue to see stdout and stderr
# from our rc scripts
# - Ken 1 Dec 2011
#
PCPQA_NO_RC_STATUS=
export PCPQA_NO_RC_STATUS
case $PCP_PLATFORM
in
darwin)
DSO_SUFFIX=dylib
;;
mingw*)
DSO_SUFFIX=dll
;;
*)
DSO_SUFFIX=so
;;
esac
# does sudo support -E?
#
# sudo usage in two forms ...
# sudo ... [-AbEHknPS] ...
# or
# -E, --preserve-env
#
sudo=`which sudo`
if $sudo -h 2>&1 | grep -E '(\[-[a-zA-DF-Z]*E[a-zA-Z]*\])|(.-E[, ])' >/dev/null 2>&1
then
# sudo has -E to preserve the environment
#
sudo="$sudo -E"
fi
# $sudo_local_ctx maybe $sudo if PM_CONTEXT_LOCAL needs to run as root,
# e.g. for /dev/kmem readers
#
case $PCP_PLATFORM
in
netbsd|openbsd|solaris)
sudo_local_ctx="$sudo"
;;
*)
sudo_local_ctx=''
;;
esac
# running with PCP_DIR set, probably don't want to do most things as
# root ... leave $sudo alone just in case
# However, if $PCP_DIR exists and is owned by someone other than ourselves,
# real sudo is guessed necessary.
if [ -n "$PCP_DIR" ]
then
__pcp_dir_owner=`ls -ld $PCP_DIR | awk '{print $3}'`
__whoami=`whoami`
if [ "$__pcp_dir_owner" = "$__whoami" ]; then
sudo=''
fi
fi
# where the tests are run from
#
here=`pwd`
# full path to .full file ... make sure it is empty at this point
# to avoid doing it in the scripts and potentially miss output
# from common.* or _notrun tests
#
seq_full=$here/$seq.full
rm -f $seq_full
# On OpenBSd in particular, /var/tmp is a symbolic link to /tmp
# which leads to some confusion, especially in pmlogger_check and
# friends when /tmp/foo and /var/tmp/foo are different paths to the
# _same_ file or directory ... so go with the canonical name without
# symbolic links
#
if which realpath >/dev/null 2>&1
then
_tmp_dir=`realpath /var/tmp`
else
_tmp_dir=/var/tmp
fi
if [ -z "$tmp" ]
then
# $tmp not already set, do it here ...
#
if [ -z "$seq" ]
then
tmp=$_tmp_dir/$$
else
tmp=$_tmp_dir/$seq-$$
fi
fi
# make sure nothing remains from earlier runs (with the same PID)
# ... unlikely, but doing it here means we don't have to do it
# in each script
#
$sudo rm -rf $tmp $tmp.*
# We depend on [A-Za-z] and similar patterns all over ... for some
# platforms this demands LC_COLLATE to be POSIX to avoid case
# insensitive matching
#
LC_COLLATE=POSIX; export LC_COLLATE
# take care of the umask ... we expect 022, and warn if this is
# not the prevailing umask before forcing it to be so
#
case `umask`
in
*022) ;;
*) echo >&2 "Warning: changing umask from `umask` to 0022"
umask 0022
;;
esac
# If we're using timeout(1) -s ABRT from check, it helps to trap the
# SIGABRT (signal 6), explain why you're quitting, then kill yourself
# with SIGTERM
#
trap 'echo "!!!"; echo "!!! Killed from check by timeout ..."; echo "!!!"; pmsignal -s TERM '$$ 6
# Hardened malloc() if available ...
#
case $PCP_PLATFORM
in
openbsd)
# C => canaries added after allocated area
# F => more extensive double free and write after free checks
# G => guard pages after page size or larger allocations
#
MALLOC_OPTIONS="CFG"; export MALLOC_OPTIONS
;;
esac
|