|
Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# File: UT_CBE_DarwinPPC.sh |
| 4 |
#-------------------------------------------------------------------------- |
| 5 |
# This script is used for running Common Base Event native implementation |
| 6 |
# unit/regression tests and the Sample. |
| 7 |
# |
| 8 |
# Usage: UT_CBE_DarwinPPC.sh [options] |
| 9 |
# Options: |
| 10 |
# -l full path to the location of the library file libcbe.so; if not |
| 11 |
# specified, the DYLD_LIBRARY_PATH and currently directory will be |
| 12 |
# used as searching path |
| 13 |
# -a full path to the locatin of the executables; if not specified, |
| 14 |
# environment variable PATH and current directory will be used |
| 15 |
# as the searching path |
| 16 |
# -o output file name; if not specified, the default file name |
| 17 |
# 'cbenative.uttest.out' will be used |
| 18 |
# -i input file name for Sample; if not specified, the default file |
| 19 |
# name sample.xml will be used |
| 20 |
# -s output file name for Sample serialize; if not specified, the |
| 21 |
# default file name serialized.xml will be used |
| 22 |
# -d output file name for Sample deserialize; if not specified, the |
| 23 |
# default file name deserialized.xml will be used |
| 24 |
#---------------------------------------------------------------------------- |
| 25 |
|
| 26 |
USAGE="Usage: $0 [-l] [library path] [-a] [application path] [-o] [output filename] [-i] [sample input filename] [-s] [sample serialize output filename] [-d] [sample deserialize output filename]"; |
| 27 |
|
| 28 |
LIB_FILE="libcbe.dylib" |
| 29 |
LIB_FILE_EXIST="false" |
| 30 |
|
| 31 |
|
| 32 |
#---------------------------------------------------------------------------- |
| 33 |
# Parse command line options |
| 34 |
#---------------------------------------------------------------------------- |
| 35 |
|
| 36 |
while getopts l:a:o:i:s:d: OPTION ; do |
| 37 |
case "$OPTION" in |
| 38 |
l) CBE_LIB_PATH="$OPTARG" ;; |
| 39 |
a) APP_PATH="$OPTARG" ;; |
| 40 |
o) OUTFILE="$OPTARG" ;; |
| 41 |
i) INFILE="$OPTARG" ;; |
| 42 |
s) SERIALIZE_FILE="$OPTARG" ;; |
| 43 |
d) DESERIALIZE_FILE="$OPTARG" ;; |
| 44 |
\?) echo "$USAGE" ; |
| 45 |
exit 1 |
| 46 |
;; |
| 47 |
esac |
| 48 |
done |
| 49 |
|
| 50 |
#---------------------------------------------------------------------------- |
| 51 |
# Setup library path |
| 52 |
#---------------------------------------------------------------------------- |
| 53 |
|
| 54 |
if [ -n "$CBE_LIB_PATH" -a -d "$CBE_LIB_PATH" ] ; |
| 55 |
then |
| 56 |
DYLD_LIBRARY_PATH="$CBE_LIB_PATH:$DYLD_LIBRARY_PATH" ; |
| 57 |
else |
| 58 |
DYLD_LIBRARY_PATH=".:$DYLD_LIBRARY_PATH" ; |
| 59 |
fi |
| 60 |
|
| 61 |
|
| 62 |
#---------------------------------------------------------------------------- |
| 63 |
# Setup unit/regression tests executable path |
| 64 |
#---------------------------------------------------------------------------- |
| 65 |
|
| 66 |
if [ -n "$APP_PATH" -a -d "$APP_PATH" ] ; |
| 67 |
then |
| 68 |
PATH="$APP_PATH:$PATH" ; |
| 69 |
else |
| 70 |
APP_PATH=. |
| 71 |
PATH="$APP_PATH:$PATH" ; |
| 72 |
fi |
| 73 |
|
| 74 |
|
| 75 |
#---------------------------------------------------------------------------- |
| 76 |
# Setup output file |
| 77 |
# |
| 78 |
# The default output file name is cbenative.uttest.out; if a file with this |
| 79 |
# name already exists, it will be renamed by attaching the timestamp to it |
| 80 |
#---------------------------------------------------------------------------- |
| 81 |
|
| 82 |
if [ -z "$OUTFILE" ] ; |
| 83 |
then |
| 84 |
OUTFILE=cbenative.uttest.out |
| 85 |
fi |
| 86 |
|
| 87 |
if [ -f "$OUTFILE" ] ; |
| 88 |
then |
| 89 |
mv "$OUTFILE" $OUTFILE.`date "+%Y%m%d.%H%M%S"` ; |
| 90 |
fi |
| 91 |
|
| 92 |
export PATH |
| 93 |
export DYLD_LIBRARY_PATH |
| 94 |
|
| 95 |
#---------------------------------------------------------------------------- |
| 96 |
# Check for existence of library file |
| 97 |
#---------------------------------------------------------------------------- |
| 98 |
|
| 99 |
OFS=${IFS} |
| 100 |
|
| 101 |
IFS=: |
| 102 |
|
| 103 |
for p in $DYLD_LIBRARY_PATH |
| 104 |
do |
| 105 |
if [ -f $p/$LIB_FILE ] |
| 106 |
then |
| 107 |
LIB_FILE_EXIST="true" ; |
| 108 |
break ; |
| 109 |
fi |
| 110 |
done |
| 111 |
|
| 112 |
|
| 113 |
if [ "$LIB_FILE_EXIST" = "false" ] |
| 114 |
then |
| 115 |
echo "Library file $LIB_FILE not found." |
| 116 |
exit 1 ; |
| 117 |
fi |
| 118 |
|
| 119 |
|
| 120 |
#--------------------------------------------------------------------------- |
| 121 |
# Check existence of test applications and run tests |
| 122 |
#--------------------------------------------------------------------------- |
| 123 |
echo |
| 124 |
echo "Working directory is: `pwd`" ; |
| 125 |
echo "Output file is: $OUTFILE" ; |
| 126 |
echo |
| 127 |
|
| 128 |
echo "Start Common Base Event Testing" >> $OUTFILE |
| 129 |
|
| 130 |
APP_EXISTS=false; |
| 131 |
|
| 132 |
|
| 133 |
IFS=${OFS} |
| 134 |
|
| 135 |
APPLICATIONS="UTAssociatedEvent |
| 136 |
UTAssociationEngine |
| 137 |
UTComponentIdentification |
| 138 |
UTContextDataElement |
| 139 |
UTTemplateContentHandler |
| 140 |
UTEventFactory |
| 141 |
UTExtendedDataElement |
| 142 |
UTMsgDataElement |
| 143 |
UTSituation |
| 144 |
UTSituationType |
| 145 |
UTXMLUtility |
| 146 |
UTCommonBaseEvent |
| 147 |
UTEventFormatter" |
| 148 |
|
| 149 |
|
| 150 |
for i in $APPLICATIONS |
| 151 |
do |
| 152 |
IFS=: ; |
| 153 |
for s in $PATH |
| 154 |
do |
| 155 |
if [ -x $s/$i ] |
| 156 |
then |
| 157 |
APP_EXISTS=true; |
| 158 |
APP=$s/$i ; |
| 159 |
break ; |
| 160 |
fi |
| 161 |
done |
| 162 |
|
| 163 |
if [ "$APP_EXISTS" = "true" ] |
| 164 |
then |
| 165 |
echo "Run $i:" ; |
| 166 |
$APP > tmp.out |
| 167 |
more tmp.out | grep Total |
| 168 |
more tmp.out >> $OUTFILE |
| 169 |
APP_EXISTS=false; |
| 170 |
else |
| 171 |
echo "File $i not found or not executable." ; |
| 172 |
fi |
| 173 |
done |
| 174 |
|
| 175 |
rm tmp.out |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
#-------------------------------------------------------------- |
| 180 |
# Run Sample |
| 181 |
#-------------------------------------------------------------- |
| 182 |
|
| 183 |
if [ -z "$INFILE" ] |
| 184 |
then |
| 185 |
INFILE=sample.xml |
| 186 |
fi |
| 187 |
|
| 188 |
if [ ! -f "$INFILE" ] |
| 189 |
then |
| 190 |
echo Sample input file $INFILE not found. |
| 191 |
exit 1 ; |
| 192 |
fi |
| 193 |
|
| 194 |
if [ -z "$SERIALIZE_FILE" ] |
| 195 |
then |
| 196 |
SERIALIZE_FILE=serialized.xml |
| 197 |
fi |
| 198 |
|
| 199 |
if [ -z "$DESERIALIZE_FILE" ] |
| 200 |
then |
| 201 |
DESERIALIZE_FILE=deserialized.xml |
| 202 |
fi |
| 203 |
|
| 204 |
SAMPLE_EXISTS=false |
| 205 |
|
| 206 |
for s in $PATH |
| 207 |
do |
| 208 |
if [ -x $s/Sample ] |
| 209 |
then |
| 210 |
SAMPLE_EXISTS=true ; |
| 211 |
fi |
| 212 |
done |
| 213 |
|
| 214 |
if [ "$SAMPLE_EXISTS" = "true" ] |
| 215 |
then |
| 216 |
echo "Run Sample:" ; |
| 217 |
Sample -i $INFILE -os $SERIALIZE_FILE -od $DESERIALIZE_FILE | grep Total |
| 218 |
else |
| 219 |
echo "File Sample not found or not executable." ; |
| 220 |
fi |
| 221 |
|
| 222 |
IFS=${OFS} |
| 223 |
|
| 224 |
echo |
| 225 |
echo "Done" ; |