Blame SOURCES/0004-Fix-regress-test-numastat-function-and-few-test-fixe.patch

c88143
From 09d294e8d83151fb76a7fc741bc6251c0b171e25 Mon Sep 17 00:00:00 2001
c88143
From: Harish <harish@linux.vnet.ibm.com>
c88143
Date: Wed, 27 Jun 2018 22:29:10 +0530
c88143
Subject: [PATCH 4/7] Fix: regress test numastat function and few test fixes
c88143
c88143
nstat function previously assumed node indexes to be contiguous
c88143
and get the numastat of the required statname. When run on a
c88143
machine with combinations of memory/memory-less nodes in a
c88143
non-contiguous way, the test fetches wrong stats and fails. This
c88143
patch finds the index of the given node and returns proper value.
c88143
c88143
Signed-off-by: Harish <harish@linux.vnet.ibm.com>
c88143
Signed-off-by: Pingfan Liu <piliu@redhat.com>
c88143
---
c88143
 test/regress | 42 +++++++++++++++++++++---------------------
c88143
 1 file changed, 21 insertions(+), 21 deletions(-)
c88143
c88143
diff --git a/test/regress b/test/regress
c88143
index c0cf6d7..f06b22f 100755
c88143
--- a/test/regress
c88143
+++ b/test/regress
c88143
@@ -47,9 +47,11 @@ failed() {
c88143
 # nstat statname node
c88143
 nstat() {
c88143
     sleep $STAT_INTERVAL
c88143
+    nid=node$2
c88143
+    id=`numastat | head -1 | awk -v node=$nid '{ for (i = 1; i <= NF; ++i) if($i==node) print i; exit }'`
c88143
     declare -a fields
c88143
     numastat | grep $1 | while read -a fields ; do
c88143
-	echo ${fields[$[1 + $2]]}
c88143
+        echo ${fields[$id]}
c88143
     done
c88143
 }
c88143
 
c88143
@@ -89,14 +91,13 @@ _test_process_state() {
c88143
 test_process_state()
c88143
 {
c88143
 	declare -i n0=${node[0]} n1=${node[1]}
c88143
-
c88143
 	_test_process_state --interleave=$n1
c88143
 
c88143
-	a0=`nstat interleave_hit 0`
c88143
-	a1=`nstat interleave_hit 1`
c88143
+	a0=`nstat interleave_hit $n0`
c88143
+	a1=`nstat interleave_hit $n1`
c88143
 	_test_process_state --interleave=$n0,$n1
c88143
-	b0=`nstat interleave_hit 0`
c88143
-	b1=`nstat interleave_hit 1`
c88143
+	b0=`nstat interleave_hit $n0`
c88143
+	b1=`nstat interleave_hit $n1`
c88143
 	if [ $(expr $b1 - $a1) -lt $HALFPAGES ]; then
c88143
 	    echo "interleaving test failed $n1 $b1 $a1"
c88143
 	    failed
c88143
@@ -109,19 +110,18 @@ test_process_state()
c88143
 	_test_process_state --interleave=all
c88143
 	_test_process_state --membind=all
c88143
 
c88143
-	a=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1))
c88143
+	a=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1))
c88143
 	_test_process_state --membind=$n0,$n1
c88143
-	b=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1))
c88143
+	b=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1))
c88143
 	if [ $(expr $b - $a) -lt $PAGES ]; then
c88143
 	    echo "membind test failed $n1 $b $a ($PAGES)"
c88143
 	    failed
c88143
 	fi
c88143
 
c88143
-	for i in $(seq 0 $maxnode) ; do
c88143
-		declare -i ni=${node[$i]}
c88143
+	for i in "${node[@]}" ; do
c88143
 		a=`nstat numa_hit $i`
c88143
-		_test_process_state --membind=$ni
c88143
-		_test_process_state --preferred=$ni
c88143
+		_test_process_state --membind=$i
c88143
+		_test_process_state --preferred=$i
c88143
 		b=`nstat numa_hit $i`
c88143
 		if [ $(expr $b - $a) -lt $DOUBLEPAGES ]; then
c88143
 		    echo "membind/preferred on node $ni failed $b $a"
c88143
@@ -143,11 +143,11 @@ test_mbind()
c88143
 {
c88143
 	declare -i n0=${node[0]} n1=${node[1]}
c88143
 
c88143
-	a0=`nstat interleave_hit 0`
c88143
-	a1=`nstat interleave_hit 1`
c88143
+	a0=`nstat interleave_hit $n0`
c88143
+	a1=`nstat interleave_hit $n1`
c88143
 	_test_mbind interleave $n0,$n1
c88143
-	b0=`nstat interleave_hit 0`
c88143
-	b1=`nstat interleave_hit 1`
c88143
+	b0=`nstat interleave_hit $n0`
c88143
+	b1=`nstat interleave_hit $n1`
c88143
 	if [ $(expr $b1 - $a1) -lt $HALFPAGES ]; then
c88143
 	    echo "interleaving test 2 failed $n1 $b1 $a1 expected $HALFPAGES"
c88143
 	    failed
c88143
@@ -159,19 +159,19 @@ test_mbind()
c88143
 
c88143
 	_test_mbind interleave all
c88143
 
c88143
-	a=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1))
c88143
+	a=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1))
c88143
 	_test_mbind membind $n0,$n1
c88143
-	b=$(expr $(nstat numa_hit 0) + $(nstat numa_hit 1))
c88143
+	b=$(expr $(nstat numa_hit $n0) + $(nstat numa_hit $n1))
c88143
 	if [ $(expr $b - $a) -lt $PAGES ]; then
c88143
 	    echo "membind test 2 failed $b $a ($PAGES)"
c88143
 	    failed
c88143
 	fi
c88143
 
c88143
-	for i in $(seq 0 $maxnode) ; do
c88143
+	for i in "${node[@]}" ; do
c88143
 		declare -i ni=${node[$i]}
c88143
 		a=`nstat numa_hit $i`
c88143
-		_test_mbind membind $ni
c88143
-		_test_mbind preferred $ni
c88143
+		_test_mbind membind $i
c88143
+		_test_mbind preferred $i
c88143
 		b=`nstat numa_hit $i`
c88143
 		if [ $(expr $b - $a) -lt $DOUBLEPAGES ]; then
c88143
 		    echo "membind/preferred test 2 on node $ni failed $b $a"
c88143
-- 
c88143
2.7.4
c88143