diff --git a/cmake_targets/autotests/tools/free_mem.bash b/cmake_targets/autotests/tools/free_mem.bash index 873d6121e739e79b7042f396acba77dc3a40ee03..f0a5b03d85c09858c5b33a93e3f5e69d883c1589 100755 --- a/cmake_targets/autotests/tools/free_mem.bash +++ b/cmake_targets/autotests/tools/free_mem.bash @@ -31,6 +31,26 @@ # \author Navid Nikaein, Rohit Gupta # To free unused memory else test setup runs out of memory -sudo -E bash -c 'echo 3 > /proc/sys/vm/drop_caches ' + +mem_threshold=0.2 #If free memory is less than this threshold, then VM drop cache is called +mem_tot=`vmstat -s -S k |grep "total memory" | awk '{print $1}'` +mem_free=`vmstat -s -S k |grep "free memory" | awk '{print $1}'` + +mem_frac=`bc <<< "scale=4;$mem_free/$mem_tot"` +echo $mem_frac +#mem_frac=`bc <<< "scale=4;`echo $mem_free`/`echo $mem_tot`"` +echo "Total Memory = $mem_tot k " +echo "Free Memory = $mem_free k" +echo "Fraction free memory = $mem_frac " + +res=`bc <<< "$mem_frac < 0.2" ` + +echo "Comparison Result = $res" + +if [ "$res" == "1" ] +then + echo "Free memory less than threshold = $mem_threshold" + sudo -E bash -c 'echo 3 > /proc/sys/vm/drop_caches ' +fi diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 4ebe2be1b0d2a986fbd4a7a6783d756f6acac929..73df7cc64002f5a0b67b8a14b20576cd5505cbfd 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -284,7 +284,8 @@ check_install_additional_tools (){ wvdial \ python-numpy \ sshpass \ - nscd + nscd \ + bc $SUDO pip install paramiko $SUDO pip install pyroute2