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

[why] it can not compute vm memory when vm memory less than 16G. Signed-off-by: Wei Jihui <weijihuiall@163.com> --- tests/host-info | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/host-info b/tests/host-info index fe55d1ff..2721648c 100755 --- a/tests/host-info +++ b/tests/host-info @@ -4,8 +4,8 @@ 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 + memory_new=$(awk 'BEGIN{printf "%0.2f", '$memory_total'/1024/1024}') + memory=$(echo $memory_new | awk '{print int($0)+1}')G echo "memory: $memory" } -- 2.23.0

Reviewed-by: Wang Chenglong <18509160991@163.com> On Wed, Jan 06, 2021 at 10:10:30AM +0800, Wei Jihui wrote:
[why] it can not compute vm memory when vm memory less than 16G.
Signed-off-by: Wei Jihui <weijihuiall@163.com> --- tests/host-info | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/host-info b/tests/host-info index fe55d1ff..2721648c 100755 --- a/tests/host-info +++ b/tests/host-info @@ -4,8 +4,8 @@ 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 + memory_new=$(awk 'BEGIN{printf "%0.2f", '$memory_total'/1024/1024}') + memory=$(echo $memory_new | awk '{print int($0)+1}')G echo "memory: $memory" }
-- 2.23.0

It loses the original round-up feature. Thanks, Fengguang On Wed, Jan 06, 2021 at 10:10:30AM +0800, Wei Jihui wrote:
[why] it can not compute vm memory when vm memory less than 16G.
Signed-off-by: Wei Jihui <weijihuiall@163.com> --- tests/host-info | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/host-info b/tests/host-info index fe55d1ff..2721648c 100755 --- a/tests/host-info +++ b/tests/host-info @@ -4,8 +4,8 @@ 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 + memory_new=$(awk 'BEGIN{printf "%0.2f", '$memory_total'/1024/1024}') + memory=$(echo $memory_new | awk '{print int($0)+1}')G echo "memory: $memory" }
-- 2.23.0
participants (3)
-
Wang Chenglong
-
Wei Jihui
-
Wu Fengguang