echo
# Background jobs:
- #remaining_jobs=$(jobs -p)
(kill -9 $(jobs -p) 2>&1) >/dev/null
# Cleanup:
echo " Currently, 4 variables are supported to be replaced:"
echo
echo " * __TESTID__ : sequence number. For example if you provide 1 to 20 for this script, it will be 1 .. 20"
+ echo " * __SEQ7__ : 7-digit number corresponding to the sequence number (0000001 for 1, and so on)"
echo " * __SEQ8__ : 8-digit number corresponding to the sequence number (00000001 for 1, and so on)"
echo " * __IPV4HEX__ : hexadecimal IPv4 address, for example: 00000001"
echo " * __IPV4__ : IPv4 address, for example: 0.0.0.1"
_exit
}
-children () {
- bash_pid=$$
- children=`ps -eo ppid | grep -w $bash_pid`
- echo $children | wc -w
-}
-
# $1: sequence number; $2: file to parse(will be updated); $3: result file
parse_file() {
local vars=$(egrep -o '__((_*[A-Z]*[0-9]*)*)__' $2 | cut -d: -f2 | sort -u)
mkdir -p $wkdir
############################################# VARIABLES SECTION #############################################
- testid=$sequence
- seq8=$(printf "%08d" $testid)
- ipv4hex=$seq8
+ local testid=$sequence
+ local seq7=$(printf "%07d" $testid)
+ local seq8=$(printf "%08d" $testid)
+ local ipv4hex=$seq8
# Numbers beginning with "0" are treated as octal (i.e. base-8): we would have 'invalid octal number with 08 and 09'
# Solution: convert to base-10 in this way: $((10#$i))
- ipv4=$(for i in $(echo $seq8 | sed 's/\(..\)/ \1 /g'); do printf "%d." $((10#$i)); done | sed 's/\.$/\n/')
+ local ipv4=$(for i in $(echo $seq8 | sed 's/\(..\)/ \1 /g'); do printf "%d." $((10#$i)); done | sed 's/\.$/\n/')
- __TESTID__=$testid
- __SEQ8__=$seq8
- __IPV4HEX__=$ipv4hex
- __IPV4__=$ipv4
+ local __TESTID__=$testid
+ local __SEQ7__=$seq7
+ local __SEQ8__=$seq8
+ local __IPV4HEX__=$ipv4hex
+ local __IPV4__=$ipv4
[ -n "$extra_vars" ] && source $CLONE_EXTRA_VARS_SCR_FILE $sequence
######################################### END VARIABLES SECTION #########################################
# Parse template files:
parse_file $sequence $TESTCASE_TEMPLATE $wkdir/testcase.txt.$sequence
+ local xml=
+ local new_file=
for file in $(grep sendxml $TESTCASE_TEMPLATE | cut -d\| -f4 | sed 's/\.xml$/.xml.msk/')
do
xml=`basename $file .msk`
for i in `seq $2 $3`
do
clone $i $CLONE_WKDIR/$1
- sleep 0.01
done
+ echo " - Completed range [$2,$3] for $(basename $ADML_DIR)"
}
#############
# Start cloning:
timestamp_begin=$(echo "scale=3 ; $(date '+%s') + $(date '+%N') / 1000000000" | bc)
-children_before=$(children)
offset=0
-$OPERATION "test|clear"
+$OPERATION "test|clear" >/dev/null
[ $? -ne 0 ] && _exit "Clone aborted: failed to clean tests !"
-echo "Please be patient, this may take a while ..."
+#echo "Please be patient, this may take a while ..."
#echo "Temporary directory: $CLONE_WKDIR"
for group in `seq 1 $((N_GROUPS+1))`
do
[ $n_end -gt $CLONE_SEQ_END ] && n_end=$CLONE_SEQ_END
[ $n_end -lt $n_begin ] && break
clone_group $group $n_begin $n_end &
+ sleep 0.05
offset=$((group * GROUPS_SIZE))
done
-# Wait background jobs to finish:
-while true
-do
- sleep 1
- [ $(children) -eq $children_before ] && break
-done
+wait $(jobs -p)
# Programming:
echo -n "Programming .."