#!/bin/sh -x

#
# Random Test (run on both CPU)
# $1 cache config
# $2 regression log file
# $3 test log path
# $4 how long to run
# $5 $6 random seed for cpu0 and cpu1 
# $7 trc value
# $8 optional use -q  

../../example/rst -c cpu0 -a "-r 0" -E n -L $2 -l ${3}/rand.log > ${3}/rand.st 2>&1
./rand -w 1 -c cpu1 -n "RAND on cpu1 cfg=$1" -C $1 -E n -L $2 -l ${3}/rand_cpu1 -s $6 -a "$4 n $7" > ${3}/rand_log1.st 2>&1 &
sleep 3
./rand -w 2 -c cpu0 -n "RAND on cpu0 cfg=$1" -C $1 -E n -L $2 -l ${3}/rand_cpu0 -s $5 -a "$4 m $7" > ${3}/rand_log0.st 2>&1 $8

#### Report detail into regression log ####
echo "#### RANDOM tests on cpu0's result ###" >> $2
grep "run.*fail" ${3}/rand_cpu0.out >> $2
echo "#### RANDOM tests on cpu1's result ###" >> $2
grep "run.*fail" ${3}/rand_cpu1.out >> $2
