Back to home page

Enduro/X

 
 

    


0001 #!/bin/bash
0002 ##
0003 ## @brief Support functions for tmsrv scripting
0004 ##
0005 ## @file run_funcs.sh
0006 ##
0007 ## -----------------------------------------------------------------------------
0008 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0009 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0010 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0011 ## This software is released under one of the following licenses:
0012 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0013 ## See LICENSE file for full text.
0014 ## -----------------------------------------------------------------------------
0015 ## AGPL license:
0016 ## 
0017 ## This program is free software; you can redistribute it and/or modify it under
0018 ## the terms of the GNU Affero General Public License, version 3 as published
0019 ## by the Free Software Foundation;
0020 ##
0021 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0022 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0023 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0024 ## for more details.
0025 ##
0026 ## You should have received a copy of the GNU Affero General Public License along 
0027 ## with this program; if not, write to the Free Software Foundation, Inc., 
0028 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0029 ##
0030 ## -----------------------------------------------------------------------------
0031 ## A commercial use license is available from Mavimax, Ltd
0032 ## contact@mavimax.com
0033 ## -----------------------------------------------------------------------------
0034 ##
0035 
0036 
0037 . ../testenv.sh
0038 
0039 export TESTDIR="$NDRX_APPHOME/atmitest/$TESTNAME"
0040 export PATH=$PATH:$TESTDIR
0041 export NDRX_ULOG=$TESTDIR
0042 export NDRX_TOUT=10
0043 export NDRX_CCONFIG=$TESTDIR/test.ini
0044 export NDRX_SILENT=Y
0045 NDRX_EXT=so
0046 if [ "$(uname)" == "Darwin" ]; then
0047     NDRX_EXT=dylib
0048 fi
0049 export NDRX_XA_DRIVERLIB=../../xadrv/tms/libndrxxatmsx.$NDRX_EXT
0050 
0051 
0052 UNAME=`uname`
0053 
0054 #
0055 # Get the crash lib...
0056 #
0057 case $UNAME in
0058 
0059   Darwin)
0060     export NDRX_PLUGINS=libt86_lcf.dylib
0061     export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$TESTDIR/../test086_tmqlimit
0062     ;;
0063 
0064   AIX)
0065     export NDRX_PLUGINS=libt86_lcf.so
0066     export LIBPATH=$LIBPATH:$TESTDIR/../test086_tmqlimit
0067     ;;
0068 
0069   *)
0070     export NDRX_PLUGINS=libt86_lcf.so
0071     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TESTDIR/../test086_tmqlimit
0072     ;;
0073 esac
0074 
0075 #
0076 # Domain 1 - here client will live
0077 #
0078 set_dom1() {
0079     echo "Setting domain 1"
0080     . ../dom1.sh
0081     export NDRX_CONFIG=$TESTDIR/ndrxconfig-dom1.xml
0082     export NDRX_DMNLOG=$TESTDIR/ndrxd-dom1.log
0083     export NDRX_LOG=$TESTDIR/ndrx-dom1.log
0084     export NDRX_DEBUG_CONF=$TESTDIR/debug-dom1.conf
0085 }
0086 
0087 #
0088 # Generic exit function
0089 #
0090 function go_out {
0091     echo "Test exiting with: $1"
0092     
0093     set_dom1;
0094     xadmin stop -y
0095     xadmin down -y 2>/dev/null
0096 
0097     popd 2>/dev/null
0098     exit $1
0099 }
0100 
0101 #
0102 #  cleanup tmsrv logfiles
0103 #
0104 function clean_logs {
0105     #
0106     # Cleanup test logs...
0107     #
0108     rm -rf ./log1 2>/dev/null; mkdir ./log1
0109     rm -rf ./log2 2>/dev/null; mkdir ./log2
0110 }
0111 
0112 #
0113 # Prior test, clean ulog
0114 #
0115 function clean_ulog {
0116 
0117     rm ULOG*
0118     > tmsrv_lib1.log
0119     > tmsrv_lib2.log
0120 }
0121 
0122 #
0123 # Verify ULOG ops
0124 #
0125 function verify_ulog {
0126 
0127     rmid=$1
0128     operation=$2
0129     count=$3
0130 
0131     cnt=`grep "$rmid: $operation" ULOG* | wc -l|  awk '{print $1}'`
0132 
0133     if [ "X$cnt" != "X$count" ]; then
0134         echo "$rmid expected $operation $count times, got $cnt"
0135         go_out -1
0136     fi
0137 }
0138 
0139 #
0140 # Verify number of log files
0141 #
0142 function verify_logfiles {
0143 
0144     rmlog=$1
0145     count=$2
0146 
0147     cnt=`ls -1 ./$rmlog/TRN* 2>/dev/null | wc -l | awk '{print $1}'`
0148 
0149     if [[ "X$cnt" != "X$count" ]]; then
0150         echo "Expected $rmlog to have $count logs but got $cnt"
0151         go_out -1
0152     fi
0153 }
0154 
0155 #
0156 # Verify that debug log contains 
0157 #
0158 function have_output {
0159 
0160     cmd=$1
0161     cmd="$cmd | wc -l | awk '{print \$1}'"
0162     cnt=`eval $cmd`
0163     
0164     if [ "X$cnt" == "X0" ]; then
0165         echo "Expected >0 lines of output from [$cmd] got [$cnt]"
0166         go_out -1
0167     fi
0168 }
0169 
0170 #
0171 # Build programs
0172 #
0173 function buildprograms {
0174 
0175     LIBMODE=$1
0176 
0177     ################################################################################
0178     echo "Building programs..."
0179     ################################################################################
0180 
0181     echo ""
0182     echo "************************************************************************"
0183     echo "Building tmsrv libl87_1$LIBMODE ..."
0184     echo "************************************************************************"
0185     buildtms -o tmsrv_lib1 -rlibl87_1$LIBMODE -v
0186 
0187     RET=$?
0188 
0189     if [ "X$RET" != "X0" ]; then
0190         echo "Failed to build tmstest: $RET"
0191         go_out 1
0192     fi
0193 
0194     echo ""
0195     echo "************************************************************************"
0196     echo "Building tmsrv libl87_2$LIBMODE ..."
0197     echo "************************************************************************"
0198     buildtms -o tmsrv_lib2 -rlibl87_2$LIBMODE -v
0199 
0200     RET=$?
0201 
0202     if [ "X$RET" != "X0" ]; then
0203         echo "Failed to build tmstest: $RET"
0204         go_out 1
0205     fi
0206 
0207     echo ""
0208     echo "************************************************************************"
0209     echo "Building atmiclt87 NULL ..."
0210     echo "************************************************************************"
0211     buildclient -o atmiclt87 -rlibl87_1$LIBMODE -l atmiclt87.c -v
0212     RET=$?
0213 
0214     if [ "X$RET" != "X0" ]; then
0215         echo "Build atmiclt87 failed"
0216         go_out 1
0217     fi
0218 
0219     echo ""
0220     echo "************************************************************************"
0221     echo "Building atmisv87 NULL ..."
0222     echo "************************************************************************"
0223     buildserver -o atmisv87_1 -rlibl87_1$LIBMODE -l atmisv87_1.c \
0224         -sTESTSV1 -sTESTSVE1 -sTESTSVE1_RET \
0225         -sTESTSVE1_NORET -sTEST1_PART -v \
0226         -sTESTSVE1_TRANRET -sTESTSVE1_TRANFWD
0227     RET=$?
0228 
0229     if [ "X$RET" != "X0" ]; then
0230         echo "Build atmiclt87 failed"
0231         go_out 1
0232     fi
0233 
0234     echo ""
0235     echo "************************************************************************"
0236     echo "Building atmisv87 NULL ..."
0237     echo "************************************************************************"
0238     buildserver -o atmisv87_2 -rlibl87_2$LIBMODE -l atmisv87_2.c -sTESTSV2 -sTESTSVE2 -v
0239     RET=$?
0240 
0241     if [ "X$RET" != "X0" ]; then
0242         echo "Build atmiclt87 failed"
0243         go_out 1
0244     fi
0245 
0246 }
0247 
0248 #
0249 # We will work only in dom1
0250 #
0251 set_dom1;
0252 
0253 ################################################################################
0254 echo "Configure build environment..."
0255 ################################################################################
0256 
0257 # Additional, application specific
0258 COMPFLAGS=""
0259 #
0260 # export the library path.
0261 #
0262 case $UNAME in
0263 
0264   AIX)
0265     # check compiler, we have a set of things required for each compiler to actually build the binary
0266     $CC -qversion 2>/dev/null
0267     RET=$?
0268     export OBJECT_MODE=64
0269 
0270     if [ "X$RET" == "X0" ]; then
0271         echo "Xlc compiler..."
0272         COMPFLAGS="-brtl -qtls -q64"
0273     else
0274         echo "Default to gcc..."
0275         COMPFLAGS="-Wl,-brtl -maix64"
0276     fi
0277 
0278     ;;
0279   SunOS)
0280         COMPFLAGS="-m64"
0281     ;;
0282 
0283   *)
0284     # default..
0285     ;;
0286 esac
0287 
0288 # Support sanitizer
0289 if [ "X`xadmin pmode 2>/dev/null | grep '#define NDRX_SANITIZE'`" != "X" ]; then
0290     COMPFLAGS="$COMPFLAGS -fsanitize=address"
0291 fi
0292 
0293 export NDRX_HOME=.
0294 export PATH=$PATH:$PWD/../../buildtools
0295 export CFLAGS="-I../../include -L../../libatmi -L../../libatmiclt -L../../libubf -L../../tmsrv -L../../libatmisrv -L../../libexthpool -L../../libnstd $COMPFLAGS"
0296 
0297 clean_logs;
0298 rm *.log
0299 rm ULOG*
0300 
0301 
0302 # vim: set ts=4 sw=4 et smartindent:
0303