#!/bin/bash
#set -v
#Get the Test dir from the build Plan Name or from command line

TOP_DIR=`pwd`

# The first argument is the build plan name which contains
# plan/branch information. We are only interested in the
# last part of this name which is the test name.
TEST=`echo $1 | sed -r 's/.*Build and Test - ([0-9\.]+ - ){0,1}//' | awk '{ print $1; }'`
shift

cd test/core/$TEST

echo "TEST is $TEST"
pwd

#Launch the test

. ./run-bamboo-test "$@"

STATUS=$?
if [ $STATUS != 0 ]; then
   echo "Workflow submission failed"
   exit $STATUS
fi

#Get RUNDIR from the planning output
echo "RUNDIR is $RUN_DIR"

# Change in to the rundir
cd $RUN_DIR

# REPORT LAST FEW LINES OF JOBSTATE.log

tail -10 jobstate.log

exit
