[PATCH lkp-tests] tests/host-info: computing vm memory

[why] it can not compute vm memory when vm memory less than 16G. [how] keep the round-up feature when memory bigger then 16G, and get actual memory when memory less then 16G. Signed-off-by: Wei Jihui <weijihuiall@163.com> --- tests/host-info | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/host-info b/tests/host-info index fe55d1ff..86b49cf9 100755 --- a/tests/host-info +++ b/tests/host-info @@ -5,7 +5,12 @@ get_memory() { memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') memory_new=$(awk 'BEGIN{printf "%0.2f", '$memory_total'/1024/1024/16}') - memory=$(echo `expr $(echo $memory_new | awk '{print int($0)+1}') \* 16`)G + if [ `expr $memory_new \> 16` -eq 1 ]; then + memory=$(echo `expr $(echo $memory_new | awk '{print int($0)+1}') \* 16`)G + else + memory_new=$(awk 'BEGIN{printf "%0.2f", '$memory_total'/1024/1024}') + memory=$(echo $memory_new | awk '{print int($0)+1}')G + fi echo "memory: $memory" } -- 2.23.0
participants (1)
-
Wei Jihui