#!/bin/bash
|
#!/bin/bash
|
|
|
|
servers=( 'mn3' 'mn2' 'mn1' )
|
|
#servers' shorthand name. They should be defined in ~/.ssh/config :
|
|
#
|
|
# Host your_short_name
|
|
# HostName server.on.the.web
|
|
# User user_to_user
|
|
|
|
|
|
|
|
|
|
|
#the max server load that is permited for runing the parallel test
|
#the max server load that is permited for runing the parallel test
|
max_allowed_server_load=26
|
max_allowed_server_load=24
|
source "my_password.sh" # define servers and passwords
|
|
|
|
SCRPT_FULL_PATH=$(realpath ${BASH_SOURCE[0]})
|
SCRPT_FULL_PATH=$(realpath ${BASH_SOURCE[0]})
|
SCRPT_DIR_PATH=$(dirname $SCRPT_FULL_PATH)
|
SCRPT_DIR_PATH=$(dirname $SCRPT_FULL_PATH)
|
|
|
|
|
|
|
|
|
|
|
#servers=( $server1 $server2 $server3 ) # an array which define the list of servers
|
#servers=( $server1 $server2 $server3 ) # an array which define the list of servers
|
my_server="to be selected"
|
my_server="to be selected"
|
SERVER_ROOT_DIR="~/pronoc_verify"
|
SERVER_ROOT_DIR="~/pronoc_verify"
|
|
|
ProNoC="$SCRPT_DIR_PATH/../../.."
|
ProNoC="$SCRPT_DIR_PATH/../../.."
|
|
|
my_srcs=( "rtl"
|
my_srcs=( "rtl"
|
"Integration_test"
|
"Integration_test"
|
"src_verilator"
|
"src_verilator"
|
"src_c/netrace-1.0"
|
"src_c/netrace-1.0"
|
"src_c/synfull"
|
"src_c/synfull"
|
"script"
|
"script"
|
"/perl_gui/lib/perl" )
|
"/perl_gui/lib/perl" )
|
|
|
|
|
|
|
# A POSIX variable
|
# A POSIX variable
|
OPTIND=1 # Reset in case getopts has been used previously in the shell.
|
OPTIND=1 # Reset in case getopts has been used previously in the shell.
|
|
|
# Initialize our own variables:
|
# Initialize our own variables:
|
paralel_run=20
|
paralel_run=20
|
MIN=2
|
MIN=2
|
MAX=80
|
MAX=80
|
STEP=4
|
STEP=4
|
dir="models"
|
dir="models"
|
|
|
|
|
|
|
models_path=$(realpath $ProNoC/Integration_test/synthetic_sim)
|
models_path=$(realpath $ProNoC/Integration_test/synthetic_sim)
|
|
|
|
|
|
|
|
|
while getopts "h?p:u:l:s:d:m:" opt; do
|
while getopts "h?p:u:l:s:d:m:" opt; do
|
case "$opt" in
|
case "$opt" in
|
h|\?)
|
h|\?)
|
echo "./run [options]
|
echo "./run [options]
|
|
|
[options]
|
[options]
|
-h show this help
|
-h show this help
|
-p <int number> : Enter the number of parallel simulations or
|
-p <int number> : Enter the number of parallel simulations or
|
compilations. The default value is 4.
|
compilations. The default value is 4.
|
-u <int number> : Enter the maximum injection ratio in %. Default is 80
|
-u <int number> : Enter the maximum injection ratio in %. Default is 80
|
-l <int number> : Enter the minimum injection ratio in %. Default is 5
|
-l <int number> : Enter the minimum injection ratio in %. Default is 5
|
-s <int number> : Enter the injection step increase ratio in %.
|
-s <int number> : Enter the injection step increase ratio in %.
|
Default value is 25.
|
Default value is 25.
|
-d <dir name> : The dir name where the simulation models configuration
|
-d <dir name> : The dir name where the simulation models configuration
|
files are located in. The default dir is \"models\"
|
files are located in. The default dir is \"models\"
|
-m <simulation model name1,simulation model name2,...> : Enter the
|
-m <simulation model name1,simulation model name2,...> : Enter the
|
simulation model name in simulation dir. If the
|
simulation model name in simulation dir. If the
|
simulation model name is not provided, it runs the
|
simulation model name is not provided, it runs the
|
simulation for all existing models in model dir.
|
simulation for all existing models in model dir.
|
"
|
"
|
|
|
declare -a dirs
|
declare -a dirs
|
i=1
|
i=1
|
for d in $models_path/*/
|
for d in $models_path/*/
|
do
|
do
|
m=$(basename "${d%/}")
|
m=$(basename "${d%/}")
|
if [ $m != "src" ]; then
|
if [ $m != "src" ] && [ $m != "perl_lib" ]; then
|
dirs[i++]="$m"
|
dirs[i++]="$m"
|
fi
|
fi
|
done
|
done
|
echo " For -d option, there are ${#dirs[@]} dir names available:"
|
echo " For -d option, there are ${#dirs[@]} dir names available:"
|
for((i=1;i<=${#dirs[@]};i++))
|
for((i=1;i<=${#dirs[@]};i++))
|
do
|
do
|
echo " $i ${dirs[i]}"
|
echo " $i ${dirs[i]}"
|
done
|
done
|
|
|
|
|
|
|
exit 0
|
exit 0
|
;;
|
;;
|
p) paralel_run=$OPTARG
|
p) paralel_run=$OPTARG
|
;;
|
;;
|
u) MAX=$OPTARG
|
u) MAX=$OPTARG
|
;;
|
;;
|
l) MIN=$OPTARG
|
l) MIN=$OPTARG
|
;;
|
;;
|
s) STEP=$OPTARG
|
s) STEP=$OPTARG
|
;;
|
;;
|
d) dir=$OPTARG
|
d) dir=$OPTARG
|
;;
|
;;
|
m) model="-m $OPTARG"
|
m) model="-m $OPTARG"
|
;;
|
;;
|
esac
|
esac
|
done
|
done
|
|
|
shift $((OPTIND-1))
|
shift $((OPTIND-1))
|
|
|
[ "${1:-}" = "--" ] && shift
|
[ "${1:-}" = "--" ] && shift
|
|
|
echo "paralel_run=$paralel_run, MAX=$MAX, MIN=$MIN, STEP=$STEP, dir=$dir models=$model Leftovers: $@"
|
echo "paralel_run=$paralel_run, MAX=$MAX, MIN=$MIN, STEP=$STEP, dir=$dir models=$model Leftovers: $@"
|
|
|
|
|
|
|
args="-p $paralel_run -u $MAX -l $MIN -s $STEP -d $dir $model"
|
args="-p $paralel_run -u $MAX -l $MIN -s $STEP -d $dir $model"
|
|
|
|
|
|
|
report="${SCRPT_DIR_PATH}/reports/${dir}_report"
|
report="${SCRPT_DIR_PATH}/reports/${dir}_report"
|
|
|
|
|
rm $report
|
rm $report
|
|
|
|
|
|
|
|
|
#copy_sources
|
#copy_sources
|
#login_in_server
|
#login_in_server
|
|
|
#step one login in tje server and read the load
|
#step one login in tje server and read the load
|
function get_server_avg_load {
|
function get_server_avg_load {
|
out=$(ssh -t -o "StrictHostKeyChecking no" $1 "uptime")
|
out=$(ssh -t -o "StrictHostKeyChecking no" $1 "uptime")
|
load_avg=$(grep -oP '(?<=load average: )[0-9]+' <<< $out)
|
load_avg=$(grep -oP '(?<=load average: )[0-9]+' <<< $out)
|
}
|
}
|
|
|
|
|
function select_a_server {
|
function select_a_server {
|
min_load="100"
|
min_load="100"
|
|
|
for i in "${servers[@]}"; do
|
for i in "${servers[@]}"; do
|
echo "get load average on $i server"
|
echo "get load average on $i server"
|
get_server_avg_load $i
|
get_server_avg_load $i
|
echo $load_avg
|
echo $load_avg
|
if [ $min_load -gt $load_avg ]
|
if [ $min_load -gt $load_avg ]
|
then
|
then
|
min_load=$load_avg
|
min_load=$load_avg
|
my_server=$i
|
my_server=$i
|
fi
|
fi
|
done
|
done
|
if [ $min_load -gt $max_allowed_server_load ]
|
if [ $min_load -gt $max_allowed_server_load ]
|
then
|
then
|
echo "All servers are busy. Cannot continue"
|
echo "All servers are busy. Cannot continue"
|
exit
|
exit
|
fi
|
fi
|
echo "server $my_server is selected for running the test"
|
echo "server $my_server is selected for running the test"
|
}
|
}
|
|
|
|
|
function copy_sources {
|
function copy_sources {
|
ssh -o "StrictHostKeyChecking no" $my_server rm -rf ${SERVER_ROOT_DIR}
|
ssh -o "StrictHostKeyChecking no" $my_server rm -rf ${SERVER_ROOT_DIR}
|
ssh -o "StrictHostKeyChecking no" $my_server mkdir -p "${SERVER_ROOT_DIR}/mpsoc/perl_gui/lib/"
|
ssh -o "StrictHostKeyChecking no" $my_server mkdir -p "${SERVER_ROOT_DIR}/mpsoc/perl_gui/lib/"
|
ssh -o "StrictHostKeyChecking no" $my_server mkdir -p "${SERVER_ROOT_DIR}/mpsoc/src_c/"
|
ssh -o "StrictHostKeyChecking no" $my_server mkdir -p "${SERVER_ROOT_DIR}/mpsoc/src_c/"
|
ssh -o "StrictHostKeyChecking no" $my_server mkdir -p "${SERVER_ROOT_DIR}/mpsoc_work"
|
ssh -o "StrictHostKeyChecking no" $my_server mkdir -p "${SERVER_ROOT_DIR}/mpsoc_work"
|
for i in "${my_srcs[@]}"; do
|
for i in "${my_srcs[@]}"; do
|
echo "Copy $i on the server"
|
echo "Copy $i on the server"
|
scp -o "StrictHostKeyChecking no" -r "$ProNoC/$i" "$my_server:${SERVER_ROOT_DIR}/mpsoc/$i"
|
scp -o "StrictHostKeyChecking no" -r "$ProNoC/$i" "$my_server:${SERVER_ROOT_DIR}/mpsoc/$i"
|
done
|
done
|
scp -o "StrictHostKeyChecking no" -r "$SCRPT_DIR_PATH/server_run.sh" "$my_server:${SERVER_ROOT_DIR}/mpsoc/Integration_test/synthetic_sim/server_run.sh"
|
scp -o "StrictHostKeyChecking no" -r "$SCRPT_DIR_PATH/server_run.sh" "$my_server:${SERVER_ROOT_DIR}/mpsoc/Integration_test/synthetic_sim/server_run.sh"
|
}
|
}
|
|
|
|
|
function run_test {
|
function run_test {
|
cmd="export PRONOC_WORK=${SERVER_ROOT_DIR}/mpsoc_work;"
|
cmd="export PRONOC_WORK=${SERVER_ROOT_DIR}/mpsoc_work;"
|
ssh -t -o "StrictHostKeyChecking no" $my_server $cmd
|
ssh -t -o "StrictHostKeyChecking no" $my_server $cmd
|
|
|
}
|
}
|
|
|
#setps to run the verrification
|
#setps to run the verrification
|
|
|
#1
|
#1
|
select_a_server
|
select_a_server
|
#2
|
#2
|
copy_sources
|
copy_sources
|
#3 run the test
|
#3 run the test
|
|
|
ssh -o "StrictHostKeyChecking no" $my_server "cd ${SERVER_ROOT_DIR}/mpsoc/Integration_test/synthetic_sim; source \"/etc/profile\"; bash server_run.sh $args;"
|
ssh -o "StrictHostKeyChecking no" $my_server "cd ${SERVER_ROOT_DIR}/mpsoc/Integration_test/synthetic_sim; source \"/etc/profile\"; bash server_run.sh $args;"
|
|
|
#collect the report
|
#collect the report
|
rm "$report"
|
rm "$report"
|
scp -o "StrictHostKeyChecking no" -r "$my_server:${SERVER_ROOT_DIR}/mpsoc/Integration_test/synthetic_sim/report" "$report"
|
scp -o "StrictHostKeyChecking no" -r "$my_server:${SERVER_ROOT_DIR}/mpsoc/Integration_test/synthetic_sim/report" "$report"
|
wait
|
wait
|
meld "$report" "${report}_old" &
|
meld "$report" "${report}_old" &
|
|
|
|
|