+ # Advice for idle cpu:
+ advice_to_squeeze_idle_cpu
+
+ # Wait background jobs to finish:
+ sleep 5
+ echo "Waiting for clone completion ..."
+ echo "(please be patient, this may take a while)"
+ echo
+ echo "Background Jobs: $(jobs -p | wc -l)"
+ wait $(jobs -p)
+
+ echo
+ echo "Programming has finished !"
+ echo
+
+ echo "Configuring repeat cycles ..."
+ ./operation.sh "test|repeats|$REPEATS"
+
+ if [ -n "$specific" ]
+ then
+ echo "A new file '$TESTCASE_DIR/specific.all' has been created."
+ echo "Probably you need to apply it before starting traffic."
+ echo
+ echo "Press ENTER to continue, CTRL-C to abort ..."
+ read dummy
+ fi
+
+# dynamic programming #################################################################
+else
+ TESTCASE_DIR=$(readlink -f dynlibs/libanna_dynamicLauncherProcedure.so | xargs dirname)
+ DYNAMIC_SUFFIX_FILE=$TESTCASE_DIR/dynamic.suffix
+
+ [ ! -f $DYNAMIC_SUFFIX_FILE ] && _exit "Missing '$DYNAMIC_SUFFIX_FILE' file.\nUse 'dynlibs/select.sh' to change the dynamic procedure and restart the ADML instances."
+ dynamic_suffix=( $(grep -v ^# $DYNAMIC_SUFFIX_FILE) )
+
+ # Multiple scenarios:
+ suffixes=${#dynamic_suffix[@]}
+ if [ $suffixes -gt 1 ]
+ then
+ echo
+ echo "----------------------------------------------------------------"
+ cat $DYNAMIC_SUFFIX_FILE
+ echo "----------------------------------------------------------------"
+ echo
+ echo "Detected $suffixes scenarios:"
+ echo
+ tmpfile=$(mktemp)
+ opt=1
+ for line in $(grep -v ^# $DYNAMIC_SUFFIX_FILE)
+ do
+ echo "${opt}) $line"
+ opt=$((opt+1))
+ done > $tmpfile
+ cat $tmpfile
+ echo
+ echo "Select the desired option (0 to input a user defined one):"
+ read option
+ while [ -z "$option" ]; do read option ; done
+ if [ "$option" != "0" ]
+ then
+ dynamic_suffix=$(grep "^${option}) " $tmpfile | cut -d" " -f2-)
+ [ -z "$dynamic_suffix" ] && _exit "Invalid option !"
+ else
+ echo "Input specific program arguments:"
+ echo " (be sure that are supported by the dynamic procedure)"
+ echo
+ read dynamic_suffix
+ while [ -z "$dynamic_suffix" ]; do read dynamic_suffix ; done
+ fi
+ fi
+
+ # Modify xml files path:
+ xmls=( $(echo $dynamic_suffix | sed 's/'\|'/ /g') )
+ dynamic_suffix=$(for xml in ${xmls[@]}
+ do
+ echo $xml | grep -q "\.xml$"
+ [ $? -eq 0 ] && echo -n "$TESTCASE_DIR/"
+ echo -n "${xml}|"
+ done | sed 's/'\|'$//')
+
+ # If still idle CPU, you could increase chunks number of background jobs
+ echo "Dynamic programming ..."
+ echo
+ while read -r line
+ do
+ instance=$(echo $line | awk '{ print $1 }')
+ ini_seq=$(echo $line | awk '{ print $2 }')
+ fin_seq=$(echo $line | awk '{ print $3 }')
+ ADML_DIR=`readlink -f ADMLS/ADML-$instance`
+
+ cd $ADML_DIR
+ ./operation.sh -t 60 "dynamic|$ini_seq|$fin_seq|$dynamic_suffix" &
+ sleep 0.1
+ count=$((count+1))
+ if [ $count -eq $ADML_CONCURRENT_PROVISION_JOBS ]
+ then
+ wait $(jobs -p)
+ count=1
+ fi
+ cd - >/dev/null
+
+ done < $PROGRAM_LAYOUT_FILE
+
+ # Advice for idle cpu:
+ advice_to_squeeze_idle_cpu
+
+fi
+
+echo
+echo