I wrote a test script in bash, to test my server. The test progress percentage is updated and replaced by the test status, either OK, or KO.
The following output is expected :
Test 1/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 2/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 3/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 4/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 5/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 6/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 7/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 8/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
But for some reasons, the text does not update correctly, and I get the following output :
Test 1/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 2/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 3/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 4/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 5/8 : 10 channel(s) and 100 stream(s) : OK (3000/3000)
Test 6/8 : 10 channel(s) and 100 stream(s) : Processing...
0%
10.00%
20.00%
30.00%
40.00%
50.00%
60.00%
70.00%
80.00%
90.00%
OK (3000/3000)
Test 7/8 : 10 channel(s) and 100 stream(s) : Processing...
0%
10.00%
20.00%
30.00%
40.00%
50.00%
60.00%
70.00%
80.00%
90.00%
OK (3000/3000)
Test 8/8 : 10 channel(s) and 100 stream(s) : Processing...
0%
10.00%
20.00%
30.00%
40.00%
50.00%
60.00%
70.00%
80.00%
90.00%
OK (3000/3000)
As you can see, once the graphical bug appears, it keeps happening. Also note that it happens at random moments, and sometimes, it does not appear at all.
Here is my printing loop :
for ((i=0; i < d; i++));
do
echo "Test $((${i} + 1))/${d} : ${channelTab[i]} channel(s) and ${streamTab[i]} stream(s) : ${saveCursor}Processing..."
sent=0
received=0
errors=0
e=0
for ((idx = 0; idx < ${channelTab[i]}; idx++));
do
/u/ecmg/bin/simulator ${fileNameTab[i]} > /dev/null 2<&1 &
pourcentage=$(bc <<< "scale=2;((${idx}))/${channelTab[i]} *100")
echo ${restoreCursor}${eraseEndOfLine}${saveCursor}${pourcentage}%
pids[idx]=$!
sleep .5
done
for pid in ${pids[*]}; do
wait $pid
results[e]=$(grep -a "stats" "${fileNameTab[i]}.out")
((e=e+1))
done
for ((f=0; f < e; f++));
do
res=$(echo "${results[f]}" | grep -o -E '[0-9]+')
resArray=($res)
((sent=sent + ${resArray[0]}))
((received=received + ${resArray[1]}))
((errors=errors + ${resArray[2]}))
done
if [ "$sent" != "$received" ];
then
echo -e "${restoreCursor}${eraseEndOfLine}${red}KO${normal} --> ${errors} errors (${received}/${sent})"
fi
if [ "$sent" == "$received" ];
then
echo -e "${restoreCursor}${eraseEndOfLine}${green}OK${normal} (${received}/${sent})"
fi
done
Here is how ${restorCursor}, ${eraseEndOfLine} and ${saveCursor} are defined :
saveCursor=$'\033[s'
restoreCursor=$'\033[u'
eraseEndOfLine=$'\033[K'
Do you have any idea why is this happening ?