#!/bin/bash
# Copyright 2006-2017, Matthew Welland.
#
# This file is part of Megatest.
#
# Megatest is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Megatest is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Megatest. If not, see <http://www.gnu.org/licenses/>.
runname=$1
pass=no
alldone=no
while [[ $alldone == no ]];do
sleep 5
$MTRUNNER $MTTESTDIR/fdktestqa/testqa $MTPATH megatest -list-runs $runname > list-runs.log
bigrun_running=$(cat list-runs.log | egrep 'bigrun\(.*RUNNING'|wc -l)
bigrun2_pass=$(cat list-runs.log | egrep 'bigrun2.*COMPLETED.*PASS'|wc -l)
echo "bigrun_running=$bigrun_running, bigrun2_pass=$bigrun2_pass"
if [[ $bigrun_running -gt 0 ]] && [[ $bigrun2_pass -gt 0 ]];then
pass=yes
alldone=yes
fi
if [[ $bigrun_running -eq 0 ]];then
echo "bigrun all done and no bigrun2 found with PASS."
alldone=yes
fi
done
if [[ $pass == yes ]];then
echo PASS
exit 0
else
echo FAIL
exit 1
fi