
#!/bin/bash

set -x

. buildsys/functions

ProcessArgs $*
Assert LoadConfigs
Assert SetupLogDir
Assert SetupResFile

BASE=`/bin/pwd`
cd ../../..

CURRENT_PL_LINUX=`uname | grep Linux`
CURRENT_PL_CYGWIN=`uname | grep CYGWIN`
CURRENT_PL_AIX=`uname | grep AIX`
CURRENT_PL_SUNOS=`uname | grep SunOS`
CURRENT_PL_DARWIN=`uname | grep Darwin`
AWK=""

EXRUNTYPE_UPPER=`echo $EXRUNTYPE | tr "[:lower:]" "[:upper:]"`

if [ "$CURRENT_PL_SUNOS" != "" ] ;then
   AWK="/usr/xpg4/bin/awk"
else
   AWK="awk"
fi

IS_64_BIT=` $AWK -v a=$SETUP_TYPE 'BEGIN { print index(a, "x86_64") }'`

IS_STUDIO12=` $AWK -v a=$SETUP_TYPE 'BEGIN { print index(a, "studio12") }'`

check_platform()
{
   if [ "$CURRENT_PL_LINUX" != "" -o "$CURRENT_PL_AIX" != "" -o "$CURRENT_PL_SUNOS" != "" -o "$CURRENT_PL_DARWIN" != "" ] ;
   then
     return 0
   elif [ "$CURRENT_PL_CYGWIN" != "" ];
   then
     return 1
   else
    echo UNKNOWN Platform:
    echo Current platform: `uname`
    exit
   fi
}

add_example()
{
   if check_platform
   then
      # The protobuf example is not built with MPC so there is no
      # Makefile and the example should be added as we check it has
      # been built before we add it anyway.
      if [ "$1" != "protobuf/isocpp2/standalone" ]
      then
         if test -f "$1/Makefile"
         then
            EXAMPLES="$EXAMPLES $1 "
         fi
      else
         EXAMPLES="$EXAMPLES $1 "
      fi
   else
      EXAMPLES="$EXAMPLES $1 "
   fi
}

SetState TestingExamples
ArchiveLogs
if [ "$SETUP_TYPE" = "pcx86.int509-dev" -o "$SETUP_TYPE" = "pcx86.int509-release" ]
then
    if [ "$DEP" != "none" ]
    then
       OSPL_HOME=$DEPWORKDIR
       export OSPL_HOME
    fi

    SPLICE_PLATFORM=$SETUP_TYPE
    export SPLICE_PLATFORM
    . ./configure -full

    if [ "$CONFIGURATION" != "OK" ]
    then
        echo  "ERROR: configuration - dcps_run_examples"
        exit 1
    fi

    echo "RUN_EXAMPLES/$EXRUNTYPE_UPPER=RUNNING" >> $RESFILE
    ArchiveLogs

    mkdir $LOGDIR/examples/run_$EXRUNTYPE
    cd $LOGDIR/examples/run_$EXRUNTYPE

    faketerm $OSPL_OUTER_HOME/testsuite/bin/run_examples_pcx86_integrity509
    $OSPL_OUTER_HOME/testsuite/bin/analyse_examples_pcx86_integrity509 > summary.txt

cat <<EOF > summary.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>

    <H2><a HREF=run_results.txt>Overview log</a></H2>
    <TABLE>
    <TBODY>
    <TABLE border=1>
EOF

    awk '$0~/^./{ if ( NR % 2 == 0 ) { bgc="white" } else { bgc="E0E0E0" } ; if ( $2 == "PASS" ) { cr="<FONT COLOR=\"green\">" } else { cr="<FONT COLOR=\"red\">" } ; print "<TR  bgcolor="bgc"><TD>"$1"</a></TD><TD>""<a HREF="$1">"cr $2"</FONT><br></TR>" }' < summary.txt >> summary.html

cat <<EOF >> summary.html
    </TBODY>
    </TABLE>
    </HTML>
EOF


    grep -v PASS summary.txt
    if [ $? = 0 ]
    then
        exit 1
    else
        exit 0
    fi
else
    SUM=0
    SUCC=0
    FAIL=0

    export SUM SUCC FAIL

    echo "RUN_EXAMPLES/$EXRUNTYPE_UPPER=RUNNING" >> $RESFILE
    ArchiveLogs

    #If its an inner build then its $WORKDIR/build as the $DEPWORKDIR
    #already has /build on the end and thats what this vatiable is used like
    OSPL_BUILD_HOME=$WORKDIR/build
    if [ "$DEP" != "none" ]
    then
        BASE=$DEPWORKDIR/build/scripts/overnight
        OSPL_BUILD_HOME=$DEPWORKDIR
    fi

    if [ -f "${DEPWORKDIR}/setup/environment/${SETUP_TYPE}" ]
    then
        CHECK_FILE=${DEPWORKDIR}/setup/environment/${SETUP_TYPE}
    else
        if [ -f "${WORKDIR}/build/setup/environment/${SETUP_TYPE}" ]
        then
            CHECK_FILE=${WORKDIR}/build/setup/environment/${SETUP_TYPE}
        fi
    fi
    LONGSETUP=`grep "^SPLICE_TARGET=" $CHECK_FILE | tail -1 | cut -f 2 -d =`
    SHORTSETUP=`echo $LONGSETUP | sed 's/-release//'`

    OUTER_BASE_DIR=`pwd`

    if [ -f "${DEPWORKDIR}/release_info/RELEASE" ]
    then
        . "${DEPWORKDIR}/release_info/RELEASE"
    elif [ -f "${OSPL_BUILD_HOME}/release_info/RELEASE" ]
    then
        . "${OSPL_BUILD_HOME}/release_info/RELEASE"
    else
        echo "ERROR: release info not found"
    fi

    EDITION=

    if [ -d "$WORKDIR/$EXAMPLE_INSTALL_DIR/Vortex$VORTEX_VERSION/Device/VortexOpenSpliceRTE" ]
    then
       EDITION=RTE
    fi

# Due to issues with long file names a new TEST installer is generated for windows overnight tests
# and it is installed into a shorter directory name
    if [ "$CURRENT_PL_CYGWIN" != "" ]
    then
        VORTEX_INSTALL_DIR=$PACKAGE_VERSION
        if [ "$DEP" = "none" ]
        then
            INSTALLERDIR=${WORKDIR}/build/install
        else
            INSTALLERDIR=${DEPWORKDIR}/install
        fi
# Using same check for TEST installer as is used in the dcps_build_examples script
        INSTALLER_FILENAME_TMP=`echo ${INSTALLERDIR}/VC/P*OpenSplice*TEST*installer.*`
        if [ -f ${INSTALLER_FILENAME_TMP} ]
        then
            INSTTYPE=TEST
        else
# It is possible that the TEST installer did not exist and the HDE installer is used as fallback
            INSTTYPE=HDE
        fi
    else
        VORTEX_INSTALL_DIR=Vortex$VORTEX_VERSION/Device/VortexOpenSplice$EDITION/$PACKAGE_VERSION
        INSTTYPE=HDE
    fi

    if [ -d "$WORKDIR/$EXAMPLE_INSTALL_DIR/$VORTEX_INSTALL_DIR/$INSTTYPE/$SHORTSETUP/" ]
    then
        cd "$WORKDIR/$EXAMPLE_INSTALL_DIR/$VORTEX_INSTALL_DIR/$INSTTYPE/$SHORTSETUP/"
        INSTALLDIRUP="$WORKDIR/$EXAMPLE_INSTALL_DIR/Vortex$VORTEX_VERSION/Device/VortexOpenSplice$EDITION"
        INSTALLDIR="$WORKDIR/$EXAMPLE_INSTALL_DIR/$VORTEX_INSTALL_DIR"
        EXAMPLESDIR="$WORKDIR/$EXAMPLE_INSTALL_DIR/$VORTEX_INSTALL_DIR/$INSTTYPE/$SHORTSETUP/examples"
    else
        cd $DEPWORKDIR/install/HDE/$SHORTSETUP/
        INSTALLDIRUP="$DEPWORKDIR"
        INSTALLDIR="$DEPWORKDIR/install/$VORTEX_INSTALL_DIR"
        EXAMPLESDIR="$DEPWORKDIR/install/$VORTEX_INSTALL_DIR/HDE/$SHORTSETUP/examples"
    fi

    if [ -d "$WORKDIR/$RTS_INSTALL_DIR" ]
    then
        OSPL_RTS_HOME="$WORKDIR/$RTS_INSTALL_DIR/$VORTEX_INSTALL_DIR/RTS/$SHORTSETUP"
    else
        OSPL_RTS_HOME="$DEPWORKDIR/install/$VORTEX_INSTALL_DIR/RTS/$SHORTSETUP"
    fi
    export OSPL_RTS_HOME

    #Copy license in place for the ospldcg
    if [ -f "$OSPL_OUTER_HOME/etc/license.lic" ]
    then
        echo "Copying License in for tools to work"
        cp $OSPL_OUTER_HOME/etc/license.lic etc/.
    fi

    if [ -f "$OSPL_BUILD_HOME/exec/$LONGSETUP/ospl_unique_domainID" ]
    then
        echo "Copying ospl_unique_domainID in for domain id generation"
        cp $OSPL_BUILD_HOME/exec/$LONGSETUP/ospl_unique_domainID bin/
    fi

    if [ -f "$OSPL_BUILD_HOME/exec/$LONGSETUP/ospl_unique_domainID.exe" ]
    then
        echo "Copying ospl_unique_domainID.exe in for domain id generation"
        cp $OSPL_BUILD_HOME/exec/$LONGSETUP/ospl_unique_domainID.exe bin/
    fi

    if check_platform
    then
       if [ -n "$PERC_HOME" ]
       then
          . $PERC_HOME/bin/percenv.sh
       fi
       unset OSPL_HOME_NORMALIZED
       more release.com
       . ./release.com
    fi

    cd examples

    add_example dcps/PingPong/c/standalone
    add_example dcps/PingPong/cpp/corba
    add_example dcps/PingPong/cpp/standalone
    add_example dcps/PingPong/java/corba
    add_example dcps/PingPong/java/standalone
    add_example dcps/Tutorial/c/standalone
    add_example dcps/Tutorial/cpp/corba
    add_example dcps/Tutorial/cpp/standalone
    add_example dcps/Tutorial/java/corba
    add_example dcps/Tutorial/java/standalone
    add_example dcps/ContentFilteredTopic/c/standalone
    add_example dcps/ContentFilteredTopic/cpp/standalone
    add_example dcps/HelloWorld/c/standalone
    add_example dcps/HelloWorld/cpp/standalone
    add_example dcps/Lifecycle/c/standalone
    add_example dcps/Lifecycle/cpp/standalone
    add_example dcps/Listener/c/standalone
    add_example dcps/Listener/cpp/standalone
    add_example dcps/Ownership/c/standalone
    add_example dcps/Ownership/cpp/standalone
    add_example dcps/QueryCondition/c/standalone
    add_example dcps/QueryCondition/cpp/standalone
    add_example dcps/WaitSet/c/standalone
    add_example dcps/WaitSet/cpp/standalone
    add_example dcps/BuiltInTopics/c/standalone
    add_example dcps/BuiltInTopics/cpp/standalone
    add_example dcps/RoundTrip/c/
    add_example dcps/RoundTrip/cpp/
    add_example dcps/Throughput/c/
    add_example dcps/Throughput/cpp/

    # c99 examples. Only newer compilers are able to build these
    if [ -f "$EXAMPLESDIR/dcps/RoundTrip/c99/RoundTrip.mpc" ]
    then
        add_example dcps/RoundTrip/c99/
        add_example dcps/Throughput/c99/
    fi

    # isocpp2 - need to check for more than a directory because the
    # run scripts are copied in as a whole so there will always be
    # an isocpp2 directory
    if [ -f "$EXAMPLESDIR/dcps/HelloWorld/isocpp2/HelloWorld.mpc" ]
    then
        add_example dcps/BuiltInTopics/isocpp2
        add_example dcps/ContentFilteredTopic/isocpp2
        add_example dcps/HelloWorld/isocpp2
        add_example dcps/Lifecycle/isocpp2
        add_example dcps/Listener/isocpp2
        add_example dcps/Ownership/isocpp2
        add_example dcps/QueryCondition/isocpp2
        add_example dcps/RoundTrip/isocpp2
        add_example dcps/Throughput/isocpp2
        add_example dcps/Tutorial/isocpp2
        add_example dcps/WaitSet/isocpp2
    fi

    # cpp corba
    add_example dcps/HelloWorld/cpp/corba

    #  java standalone
    add_example dcps/ContentFilteredTopic/java/standalone
    add_example dcps/HelloWorld/java/standalone
    add_example dcps/HelloWorld/java5
    add_example dcps/Lifecycle/java/standalone
    add_example dcps/Listener/java/standalone
    add_example dcps/Ownership/java/standalone
    add_example dcps/QueryCondition/java/standalone
    add_example dcps/WaitSet/java/standalone
    add_example dcps/BuiltInTopics/java/standalone
    add_example dcps/RoundTrip/java
    add_example dcps/Throughput/java
    add_example dcps/RoundTrip/java5
    add_example dcps/Throughput/java5
    add_example dcps/Tutorial/java5
    add_example dcps/PingPong/java5
    add_example dcps/BuiltInTopics/java5
    add_example dcps/ContentFilteredTopic/java5
    add_example dcps/Lifecycle/java5
    add_example dcps/Listener/java5
    add_example dcps/Ownership/java5
    add_example dcps/QueryCondition/java5
    add_example dcps/WaitSet/java5


    # Java Corba
    add_example dcps/HelloWorld/java/corba

    # Check for the existence of the ClientServer idl directory.
    # If 1 of the RMI examples is there they all should be.
    if [ -d "$EXAMPLESDIR/rmi/ClientServer/idl" ]
    then
        add_example rmi/ClientServer/cpp
        add_example rmi/ClientServer/java
        add_example rmi/Printer/cpp
        add_example rmi/Printer/java
        add_example rmi/HelloWorld/cpp
        add_example rmi/HelloWorld/java
    fi

    if [ -d "$EXAMPLESDIR/streams/Throughput/idl" ]
    then
        add_example streams/Throughput/cpp/
    fi

    if [ -d "$EXAMPLESDIR/face/HelloWorld/idl" ]
    then
        add_example face/HelloWorld/cpp
        add_example face/HelloWorld/java
    fi

    # C#
    if [ "$CURRENT_PL_CYGWIN" != "" ]
    then
        add_example dcps/PingPong/cs/standalone
        add_example dcps/Tutorial/cs/standalone
        add_example dcps/ContentFilteredTopic/cs/standalone
        add_example dcps/HelloWorld/cs/standalone
        add_example dcps/Lifecycle/cs/standalone
        add_example dcps/Listener/cs/standalone
        add_example dcps/Ownership/cs/standalone
        add_example dcps/QueryCondition/cs/standalone
        add_example dcps/WaitSet/cs/standalone
        add_example dcps/BuiltInTopics/cs/standalone
        # Do not include Durability cs example as it doesn't work and
        # hangs - it should always be last in this list as it has it's
        # own config files
        #add_example dcps/Durability/cs/standalone
    fi

    #Add the protobuf example if it has built successfully - just check for the publishers
    if [ -f "$EXAMPLESDIR/protobuf/java5/pub/java5_protobuf_pub.jar" ]
    then
        add_example protobuf/java5
    fi
    if [ -f "$EXAMPLESDIR/protobuf/isocpp2/standalone/publisher" ]
    then
        add_example protobuf/isocpp2/standalone
    else
        if [ -f "$EXAMPLESDIR/protobuf/isocpp2/standalone/publisher.exe" ]
        then
            add_example protobuf/isocpp2/standalone
        fi
    fi

    # The Durability and DBMS connect examples have their own config files
    # so run them last
    add_example dcps/Durability/c/standalone
    add_example dcps/Durability/cpp/standalone
    add_example dcps/Durability/java/standalone

    # Always need to check for more than the isocpp2 directory as
    # the run scripts are copied in regardless so there will always
    # be an isocpp2 directory.  run the durability example last as
    # it has a it's own config file.
    if [ -f "$EXAMPLESDIR/dcps/Durability/isocpp2/Durability.mpc" ]
    then
        add_example dcps/Durability/isocpp2
    fi


    if [ "$DEP" != "none" ]
    then
        add_example services/dbmsconnect/SQL/C++/ODBC
    fi

    export EXAMPLES

    echo "Running Examples:"

    if [ "$SETUP_TYPE" = "PPC5plus.AIX5.3-dev" -o "$SETUP_TYPE" = "PPC5plus.AIX5.3-release" ]
    then
       PATH="/usr/vac/bin:/usr/vacpp/bin:$PATH"
    fi

    LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TAO_ROOT/lib"
    export LD_LIBRARY_PATH
    SUMMARY_HTML="$LOGDIR/examples/run_$EXRUNTYPE/summary.html"

    if [ -z "$SPLICE_TARGET_HOST" ]
    then
        if [ "$CURRENT_PL_CYGWIN" != "" ]
        then
            PATH="/cygdrive/c/WINDOWS/system32:$PATH"
            export PATH

            XPATH="$(cygpath -w $BASE)";

            echo "Running examples "
            cmd.exe /C $XPATH/run_python_examples.bat  >> $LOGDIR/examples/run_$EXRUNTYPE/run_results.txt 2>&1
            grep "Examples Failed = 0" $SUMMARY_HTML
            RESULT=$?
        else
            if [ -z `echo $SETUP_TYPE | grep vxworks` ]
            then
                export BASE

                #some platforms have HOSTNAME set but not exported for some reason
                #so export it here as a precaution
                export HOSTNAME

                # If it's a valgrind run then use the old run script as the valgrind commands aren't
                # currently catered for in the python scripts..
                if [ "$VALGRIND" = "yes" ]
                then
                    sh $BASE/run_examples.sh >> $LOGDIR/examples/run_$EXRUNTYPE/run_results.txt
                else
                    sh $BASE/run_python_examples.sh >> $LOGDIR/examples/run_$EXRUNTYPE/run_results.txt
                fi
                grep "Examples Failed = 0" $SUMMARY_HTML
                RESULT=$?
            else
                echo "Running VxWorks examples"
                cd ..
                PYTHONUNBUFFERED=yes export PYTHONUNBUFFERED
                SPLICE_TARGET=$SHORTSETUP $AUTOMATION_DIR/examples.py
                SPLICE_TARGET=$SHORTSETUP $AUTOMATION_DIR/parse_vxworks_examples
                RESULT=$?
                cd examples
            fi
        fi
    else
        RRSCRIPT=$INSTALLDIR/HDE/$SHORTSETUP/remoterun.sh
        echo '#!/bin/sh' > $RRSCRIPT
        #echo 'set -x' > $RRSCRIPT
        if [ -n "$UNIQUE_MC_ADDRESS" ]
        then
            echo UNIQUE_MC_ADDRESS=$UNIQE_MC_ADDRESS export UNIQE_MC_ADDRESS >> $RRSCRIPT
        fi
        cat $WORKDIR/build/build/scripts/overnight/configs/$SPLICE_TARGET_HOST/runtime.$SHORTSETUP >> $RRSCRIPT
	echo >> $RRSCRIPT
        echo LOGDIR=$LOGDIR export LOGDIR >> $RRSCRIPT
        echo EXRUNTYPE=$EXRUNTYPE export EXRUNTYPE >> $RRSCRIPT
        echo EXAMPLES=\"$EXAMPLES\" export EXAMPLES >> $RRSCRIPT
        echo EXCLUDED_TESTS=\"$EXCLUDED_TESTS\" export EXCLUDED_TESTS >> $RRSCRIPT
	echo PROTOBUF_LIB_HOME=\"$PROTOBUF_LIB_HOME\" export PROTOBUF_LIB_HOME >> $RRSCRIPT
        echo mkdir -p $LOGDIR/examples/run_$EXRUNTYPE >> $RRSCRIPT
        sed -e s#/host/lib#/lib:.# $INSTALLDIR/HDE/$SHORTSETUP/release.com >> $RRSCRIPT
        echo cd $EXAMPLESDIR >> $RRSCRIPT
        echo BASE=$EXAMPLESDIR export BASE >> $RRSCRIPT
        echo WORKAROUND_PATH=$WORKAROUND_PATH >> $RRSCRIPT
        echo export WORKAROUND_PATH >> $RRSCRIPT
        echo LD_LIBRARY_PATH='$PROTOBUF_LIB_HOME:$LD_LIBRARY_PATH' >> $RRSCRIPT
        echo export LD_LIBRARY_PATH >> $RRSCRIPT
        echo OVERRIDE_LD_LIBRARY_PATH='$LD_LIBRARY_PATH' >> $RRSCRIPT
        echo export OVERRIDE_LD_LIBRARY_PATH >> $RRSCRIPT
        echo export SPLICE_TARGET_HOST=$SPLICE_TARGET_HOST >> $RRSCRIPT
        echo sh ./run_examples.sh >> $RRSCRIPT
        chmod +x $RRSCRIPT
        cp $BASE/run_examples.sh $EXAMPLESDIR
        cp $BASE/example_results_fns $EXAMPLESDIR

        if [ -z "$SPLICE_SSH" ] ; then SPLICE_SSH=ssh ; fi
        if [ -z "$SPLICE_SCP" ] ; then SPLICE_SCP="scp -q" ; fi

        if [ -z "$SPLICE_TARGET_HOST_SHAREDFS" ]
        then
            $SPLICE_SSH $SPLICE_TARGET_HOST rm -rf $INSTALLDIRUP $LOGDIR
            $SPLICE_SSH $SPLICE_TARGET_HOST mkdir -p $INSTALLDIRUP
            $SPLICE_SCP -r $INSTALLDIR $SPLICE_TARGET_HOST:$INSTALLDIRUP
        fi
        $SPLICE_SSH $SPLICE_TARGET_HOST $RRSCRIPT
        RESULT=$?
        if [ "$SPLICE_SSH" = "rsh" ]
        then
            # rsh doesn't pass return codes back
            tail -1 "$LOGDIR/examples/run_$EXRUNTYPE/totals.log" | grep -q "Examples Failed = 0"
            RESULT=$?
        fi
        if [ -z "$SPLICE_TARGET_HOST_SHAREDFS" ]
        then
            $SPLICE_SCP -r $SPLICE_TARGET_HOST:$LOGDIR/examples $LOGDIR
        fi
    fi

    RUN_SUMMARY_LOG="$LOGDIR/examples/run_$EXRUNTYPE/run_results_summary.txt"
    SUMMARY_LOG="$LOGDIR/examples/run_$EXRUNTYPE/examples.log"
    TOTALS_LOG="$LOGDIR/examples/run_$EXRUNTYPE/totals.log"

    if [ -f  "$OSPL_HOME/etc/BUILDINFO" ]
    then
        OSPLI_REV=`grep -n REV $OSPL_HOME/etc/BUILDINFO`
        OSPLI_SHA=${OSPLI_REV#*=}
    fi

    if [ -f  "$OSPL_OUTER_HOME/etc/BUILDINFO" ]
    then
        OSPLO_REV=`grep -n REV $OSPL_OUTER_HOME/etc/BUILDINFO | grep -v PARENT`
        OSPLO_SHA=${OSPLO_REV#*=}
    fi

    # Only do the next bit if we don't already have a summary.html file - one of which
    # will be generated if the run_python_examples script is run
    if [ ! -f $SUMMARY_HTML ]
    then
        cat $RUN_SUMMARY_LOG  >> $SUMMARY_LOG
        sleep 10

        rm $RUN_SUMMARY_LOG
        sleep 5

cat <<EOF > summary.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>

    <H2><a HREF=run_results.txt>Overview log</a></H2>
    <TABLE>
    <TBODY>
    <TABLE border=1>
    <TR><a HREF=examples.log>Results summary (examples.log)</a><br></TR>
    <TR><a HREF=examples.log.gz>Results summary (examples.log.gz)</a><br></TR>
EOF

    awk '$0~/^./ {print "<TR  bgcolor="white"><TD>"$1" "$2" "$3" "$4"</TD><br></TR>" }' < $TOTALS_LOG >> summary.html

    awk '$0~/^./{ if ( NR % 2 == 0 ) { bgc="white" } else { bgc="E0E0E0" } ; if ( $2 == "PASSED" ) { cr="<FONT COLOR=\"green\">" } else { cr="<FONT COLOR=\"red\">" } ; print "<TR  bgcolor="bgc"><TD>"$1"</a></TD><TD>""<a HREF="$1">"cr $2"</FONT><br></TR>" }' < $SUMMARY_LOG >> summary.html

cat <<EOF >> summary.html

    </TBODY>
    </TABLE>
    </HTML>
EOF
    fi

    # Add the version and sha details after the html is generated
    echo "VortexOpenSplice version : ${PACKAGE_VERSION}" >> $SUMMARY_LOG
    echo "ospli revision : $OSPLI_SHA" >> $SUMMARY_LOG
    echo "osplo revision : $OSPLO_SHA" >> $SUMMARY_LOG

    sleep 10

    mv summary.html $LOGDIR/examples/run_$EXRUNTYPE/

    exit $RESULT
fi
