#!/bin/bash

. buildsys/functions

ProcessArgs $*
Assert LoadConfigs
Assert SetupLogDir
Assert SetupResFile

cd ../../..

SetState Testing
ArchiveLogs

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_perform_dbt_tests"
   exit 1
fi

echo "RUN/DBT=RUNNING" >> $RESFILE
ArchiveLogs

BUILD_TYPE=`echo $SETUP_TYPE | awk -F'-' '{ print$NF }'`

bash $OSPL_OUTER_HOME/bin/management_dbt_run run collect $BUILD_TYPE full

(
    cd $OSPL_OUTER_HOME/Results
    for i in `ls *`
    do
        echo $i | grep "\." 2>&1 > /dev/null
        if [ $? != 0 ]
        then
            mv $i $i.txt
        fi
    done
)

cp -rp $OSPL_OUTER_HOME/Results $LOGDIR/DBT-Results ||
{
    echo "ERROR: could not copy to DBT Results - dcps_perform_dbt_tests";
    exit 2;
}
exit 0
