Initial Set of NUMA Testcases written by "sivakumar.c@in.ibm.com"
diff --git a/README b/README
index 16de1ac..bbec9ad 100644
--- a/README
+++ b/README
@@ -103,7 +103,11 @@
 
 Using KDUMP test automation suite
 ---------------------------------
-
 For more information on how to use the kdump test automation suite please refer
 to file testcases/kdump/README.
 
+Using NUMA test automation suite
+---------------------------------
+For more information on how to use the 'numa' test automation suite please refer
+to file testcases/kernel/numa/README.
+
diff --git a/runtest/numa b/runtest/numa
new file mode 100644
index 0000000..510c353
--- /dev/null
+++ b/runtest/numa
@@ -0,0 +1 @@
+Numa-testcases numa01.sh
diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile
index 511849c..c77905a 100644
--- a/testcases/kernel/Makefile
+++ b/testcases/kernel/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS = containers include fs io ipc mem pty sched security syscalls
+SUBDIRS = numa containers include fs io ipc mem pty sched security syscalls
 UCLINUX_SUBDIRS = syscalls
 
 all:
diff --git a/testcases/kernel/numa/Makefile b/testcases/kernel/numa/Makefile
new file mode 100644
index 0000000..4931b64
--- /dev/null
+++ b/testcases/kernel/numa/Makefile
@@ -0,0 +1,32 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2007
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+CFLAGS += -I../../../include -Wall
+LDLIBS += -L../../../lib -lltp
+
+SRCS    = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+	@set -e; for i in $(TARGETS); do ln -f $$i ../../bin/$$i ; done
+	cp numa01.sh ../../bin/.
+
+clean:
+	rm -f $(TARGETS)
diff --git a/testcases/kernel/numa/README b/testcases/kernel/numa/README
new file mode 100644
index 0000000..2e64c38
--- /dev/null
+++ b/testcases/kernel/numa/README
@@ -0,0 +1,68 @@
+Introduction:
+
+====================================================================================================================
+
+NUMA ( Non-Uniform Memory Access ) is topology in which, time taken in accessing a memory dependes upon
+the local node or remote node memory. With the help of numa libraries or numactl command we could able
+to use the numa topology such that we can run an application on a specified node ( node affinity ) and
+also, we can apply memory policies such that an application running on a node can get memory alloctaion
+from any specified nodes memory. So, we can use the policies offered by numa libraries or numactl command
+to either decrease the memory latencies or increase the memory bandwidth by properly applying polcies.
+
+Please refer http://lse.sourceforge.net/numa/ to know the basics of numa and refer
+http://www.novell.com/collateral/4621437/4621437.pdf to understand the usage of numactl and numa libraries.
+
+We can always get the latest package from ftp://ftp.suse.com/pub/people/ak/numa.
+
+Testcase Description:
+====================================================================================================================
+numa01.sh shell script holds all the numa testcases and support_numa.c will help numa01.sh as and when needed.
+
+Testcase1:
+Verifies the node affinity and memory affinity by running the support_numa process which will allocate 1MB of memory.
+
+TestCase2:
+Verifies the preferred node memory policy which will allocate memory from the node we specify. This 
+testcase will use the support_numa process for the verfication.
+
+TestCase3:
+Verifies the memory interleaving policy which will distribute the memory evenly among all nodes. This 
+testcase will use the support_numa process for the verfication.
+
+TestCase4:
+Verifies the physical cpu affinity which runs the process support_numa on the specified physical cpu number.
+
+TestCase5:
+Verifies the local allocation policy which always allocates memory from the local node. This testcase 
+will use the support_numa process for the verfication.
+
+TestCase6: 
+Verifies the memory interleaving policy on the shared memory which will interleave the shared memory on
+all nodes equally. Here, the testcase use touch command instead of running a seperate process to verify
+the policy applied.
+
+Pre-requisites
+====================================================================================================================
+ * libnuma should be installed on the NUMA machine before executing theses testcases
+ * Testcases can also be executed on non-numa machines, but they will fail,
+
+Building the Tescases
+====================================================================================================================
+From LTP-Root, use <make> to build the testcases
+ltp-full-20070731]$ make
+or, from
+ltp-full-20070731_numa/testcases/kernel/numa]# make
+
+Installing the Testcases
+====================================================================================================================
+From LTP-Root, use <make> to install the testcases
+ltp-full-20070731]$ make install
+or, from
+ltp-full-20070731_numa/testcases/kernel/numa]# make install
+
+Running the Tescases
+====================================================================================================================
+From LTP-Root, invoke ./runltp
+ltp-full-20070731]$ ./runltp -p -l <logfile> -f numa
+
+ * NUMA testcases will not run by default in LTP-runall
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
new file mode 100644
index 0000000..33d064b
--- /dev/null
+++ b/testcases/kernel/numa/numa01.sh
@@ -0,0 +1,651 @@
+################################################################################
+##                                                                            ##
+## Copyright (c) International Business Machines  Corp., 2007                 ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software               ##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    ##
+##                                                                            ##
+################################################################################
+#
+# Author:        Sivakumar Chinnaiah, Sivakumar.C@in.ibm.com
+#
+# History:       July 04 2007 - Created - Sivakumar Chinnaiah.
+#
+#! /bin/sh
+#
+# File :         numa01.sh
+#
+# Description:  Test Basic functionality of numactl command.
+#		Test #1: Verifies cpunodebind and membind
+#		Test #2: Verifies preferred node bind for memory allocation
+#		Test #3: Verifies memory interleave on all nodes
+#		Test #4: Verifies physcpubind
+#		Test #5: Verifies localalloc
+#		Test #6: Verifies memory policies on shared memory 
+#		- it uses numastat output which is expected to be in the format
+#                           node0           node1
+#numa_hit                 4280408         4605341
+#numa_miss                      0               0
+#numa_foreign                   0               0
+#interleave_hit             12445           13006
+#local_node               4277766         4566799
+#other_node                  2642           38542
+
+
+
+# Function:     chk_ifexists
+#
+# Description:  - Check if command required for this test exits.
+#
+# Input:        - $1 - calling test case.
+#               - $2 - command that needs to be checked.
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+chk_ifexists()
+{
+    RC=0
+
+    which $2 &>$LTPTMP/tst_numa.err || RC=$?
+    if [ $RC -ne 0 ]
+    then
+        tst_brkm TBROK NULL "$1: command $2 not found."
+    fi
+    return $RC
+}
+
+
+
+# Function:     getmax
+#
+# Description:  - Returns the maximum available nodes if success.
+#
+# Input:        - o/p of numactl --hardware command which is expected in the format
+#                 shown below
+#               available: 2 nodes (0-1)
+#               node 0 size: 7808 MB
+#               node 0 free: 7457 MB
+#               node 1 size: 5807 MB
+#               node 1 free: 5731 MB
+#               node distances:
+#               node   0   1
+#                 0:  10  20
+#                 1:  20  10
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+getmax()
+{
+    numactl --hardware > $LTPTMP/avail_nodes
+
+    RC=$(awk '{ if ( NR == 1 ) {print $1;} }' $LTPTMP/avail_nodes)
+    if [ $RC = "available:" ]
+    then
+        RC=$(awk '{ if ( NR == 1 ) {print $3;} }' $LTPTMP/avail_nodes)
+        if [ $RC = "nodes" ]
+        then
+            RC=$(awk '{ if ( NR == 1 ) {print $2;} }' $LTPTMP/avail_nodes)
+            return 0;
+        else
+            tst_brkm TBROK NULL "the field nodes in the o/p of numactl --hardware seems to be different"
+        fi
+    else
+        tst_brkm TBROK NULL "the field available in the o/p of numactl --hardware seems to be different"
+    fi
+    return 1;
+}
+
+
+
+# Function:     extract_numastat 
+#
+# Description:  - extract the value of given row,column from the numastat output .
+#
+# Input:        - $1 - row number.
+#               - $2 - column number.
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+extract_numastat()
+{
+    RC=0
+
+    # check whether numastat output is changed
+
+    RC=$(awk '
+        { if ( NR == '$2' ){
+            print $1;
+            }
+        }
+        ' $LTPTMP/numalog)
+    if [ $RC != $1 ]
+    then
+	tst_brkm TBROK NULL "numastat o/p seems to be changed, $1 expected to be in the row $2"
+        return 1
+    fi
+   
+    RC=$(awk '
+        { if ( NR == '$2' ){
+            print $'$3';
+            }
+        }
+        ' $LTPTMP/numalog)
+    return 0 
+}
+
+
+
+# Function:     comparelog
+#
+# Description:  - return the difference of input arguments if they are in
+#                 increasing order.
+#
+# Input:        - $1 - original value.
+#               - $2 - changed value.
+#
+# Return:       - difference of arguments on success.
+comparelog()
+{
+
+    if [ $2 -gt $1 ]
+    then
+        RC=$[$2-$1]
+    else
+        RC=0
+    fi
+    return 0
+}
+
+
+
+# Function: init
+#
+# Description:  - Check if command required for this test exits.
+#               - Initialize global variables.
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+init()
+{
+    # Initialize global variables.
+    export RC=0
+    export TST_TOTAL=6
+    export TCID="Initnuma"
+    export TST_COUNT=0
+
+    # Max. no. of Nodes
+    max_node=0
+
+    # Page Size
+    page_size=0
+
+    # row definitions, pls see at the top of this file 
+    numa_hit=2
+    numa_miss=3
+    numa_foreign=4
+    interleave_hit=5
+    local_node=6
+    other_node=7
+
+    #arguments to memory exercise program support_numa.c
+    PRT_PG_SIZE=1
+    ALLOC_1MB=2
+    PAUSE=3
+
+    # Inititalize cleanup function.
+    trap "cleanup" 0
+
+    # create the temporary directory used by this testcase
+    if [ -z $TMP ]
+    then
+        LTPTMP=/tmp/tst_numa.$$
+    else
+        LTPTMP=$TMP/tst_numa.$$
+    fi
+
+    mkdir -p $LTPTMP &>/dev/null || RC=$?
+    if [ $RC -ne 0 ]
+    then
+         tst_brkm TBROK NULL "INIT: Unable to create temporary directory"
+         return $RC
+    fi
+
+    # check if commands tst_*, numa*, awk exists.
+    chk_ifexists INIT tst_resm   || return $RC
+    chk_ifexists INIT numactl    || return $RC
+    chk_ifexists INIT numastat   || return $RC
+    chk_ifexists INIT awk        || return $RC
+    chk_ifexists INIT cat        || return $RC
+    chk_ifexists INIT kill       || return $RC
+
+    RC=0
+    # set max_node 
+    getmax || return 1
+    max_node=$RC
+
+    if [ $max_node -eq 1 ]
+    then 
+        tst_resm TWARN "non-NUMA aware kernel is running or your machine does not support numa policy or 
+                        your machine is not a NUMA machine"
+    return 1
+    fi
+
+    RC=0
+    #Set pagesize
+    support_numa $PRT_PG_SIZE > $LTPTMP/numaarg || RC=$?
+    if [ $RC -ne 0 ]
+    then
+        tst_resm TFAIL "INIT: memory exerciser program support_numa exits abnormally"
+    fi
+    page_size=$(cat $LTPTMP/numaarg)
+
+    tst_resm TINFO "INIT: Numa tests will start now !!" 
+}
+
+
+
+# Function:     cleanup
+#
+# Description:  - remove temporaty files and directories.
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+cleanup()
+{
+    TCID=exitnuma
+    RC=0
+
+    # remove all the temporary files created by this test.
+    tst_resm TINFO "CLEAN: removing $LTPTMP"
+    rm -fr $LTPTMP || RC=$?
+    return $RC
+}
+
+
+
+# Function:     test01
+#
+# Description:  - Verification of local node and memory affinity
+# 
+# Return:       - zero on success.
+#               - non-zero on failure.
+test01()
+{
+    TCID=numa01
+    TST_COUNT=1
+
+    RC=0                # Return value from commands.
+    Prev_value=0        # extracted from the numastat o/p
+    Curr_value=0	# Current value extracted from numastat o/p
+    Exp_incr=0          # 1 MB/ PAGESIZE
+    Node_num=0          
+    col=0
+    MB=$[1024*1024]
+
+    # Increase in numastat o/p is interms of pages
+    Exp_incr=$[$MB/$page_size]
+
+    COUNTER=1 
+    while [  $COUNTER -le $max_node ]; do
+        Node_num=$[$COUNTER-1]		#Node numbers start from 0
+        col=$[$COUNTER+1]		#Node number in numastat o/p
+        numastat > $LTPTMP/numalog
+        extract_numastat local_node $local_node $col || return 1 
+        Prev_value=$RC
+        numactl --cpunodebind=$Node_num --membind=$Node_num support_numa $ALLOC_1MB 
+        numastat > $LTPTMP/numalog
+        extract_numastat local_node $local_node $col || return 1
+        Curr_value=$RC
+        comparelog $Prev_value $Curr_value 
+        if [ $RC -lt $Exp_incr ]
+        then
+             tst_resm TFAIL \
+                 "Test #1: NUMA hit and localnode increase in node$Node_num is less than expected"
+            return 1 
+        fi
+        COUNTER=$[$COUNTER+1] 
+    done
+    tst_resm TPASS "NUMA local node and memory affinity -TEST01 PASSED !!"
+    return 0
+}
+
+
+
+# Function:     test02
+#
+# Description:  - Verification of memory allocated from preferred node 
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+test02()
+{
+    TCID=numa02
+    TST_COUNT=2
+
+    RC=0                # Return value from commands.
+    Prev_value=0        # extracted from the numastat o/p
+    Curr_value=0        # Current value extracted from numastat o/p
+    Exp_incr=0          # 1 MB/ PAGESIZE
+    Node_num=0
+    col=0
+    MB=$[1024*1024]
+
+    # Increase in numastat o/p is interms of pages
+    Exp_incr=$[$MB/$page_size]
+
+    COUNTER=1
+    while [  $COUNTER -le $max_node ]; do
+        
+	if [ $max_node -eq 1 ]
+        then 
+            tst_brkm TBROK NULL "Preferred policy cant be applied for a single node machine"
+	    return 1
+	fi
+
+        Node_num=$[$COUNTER-1]         #Node numbers start from 0
+
+        if [ $COUNTER -eq $max_node ]   #wrap up for last node
+ 	then
+	    Preferred_node=0
+	    col=2			#column represents node0 in numastat o/p
+	else
+            Preferred_node=$[$Node_num+1]  #always next node is preferred node
+	    col=$[$COUNTER+2]              #Preferred Node number in numastat o/p
+	fi
+
+        numastat > $LTPTMP/numalog
+        extract_numastat other_node $other_node $col || return 1
+        Prev_value=$RC
+        numactl --cpunodebind=$Node_num --preferred=$Preferred_node support_numa $ALLOC_1MB 
+        numastat > $LTPTMP/numalog
+        extract_numastat other_node $other_node $col || return 1
+        Curr_value=$RC
+        comparelog $Prev_value $Curr_value 
+        if [ $RC -lt $Exp_incr ]
+        then
+             tst_resm TFAIL \
+                 "Test #2: NUMA hit and othernode increase in node$Node_num is less than expected"
+            return 1
+        fi
+        COUNTER=$[$COUNTER+1]        
+    done
+    tst_resm TPASS "NUMA preferred node policy -TEST02 PASSED !!"
+    return 0
+}
+
+
+# Function:     test03
+#
+# Description:  - Verification of memory interleaved on all nodes 
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+test03()
+{
+    TCID=numa03
+    TST_COUNT=3
+
+    RC=0                # Return value from commands.
+    Prev_value=0        # extracted from the numastat o/p
+    declare -a parray   # array contains previous value of all nodes
+    Curr_value=0        # Current value extracted from numastat o/p
+    Exp_incr=0          # 1 MB/ (PAGESIZE*num_of_nodes)
+    Node_num=0
+    col=0
+    MB=$[1024*1024]
+
+    # Increase in numastat o/p is interms of pages
+    Exp_incr=$[$MB/$page_size]
+    # Pages will be allocated using round robin on nodes.
+    Exp_incr=$[$Exp_incr/$max_node] 
+
+    # Check whether the pages are equally distributed among available nodes
+    numastat > $LTPTMP/numalog
+    COUNTER=1
+    while [  $COUNTER -le $max_node ]; do
+        col=$[$COUNTER+1]              #Node number in numastat o/p
+        extract_numastat interleave_hit $interleave_hit $col || return 1
+        Prev_value=$RC
+        parray[$COUNTER]=$Prev_value
+        COUNTER=$[$COUNTER+1]
+    done
+
+    numactl --interleave=all support_numa $ALLOC_1MB 
+
+    numastat > $LTPTMP/numalog
+    COUNTER=1
+    while [  $COUNTER -le $max_node ]; do
+        col=$[$COUNTER+1]              #Node number in numastat o/p
+	Node_num=$[$COUNTER-1]         #Node numbers start from 0
+        extract_numastat interleave_hit $interleave_hit $col || return 1
+        Curr_value=$RC
+        comparelog ${parray[$COUNTER]} $Curr_value 
+        if [ $RC -lt $Exp_incr ]
+        then
+             tst_resm TFAIL \
+                 "Test #3: NUMA interleave hit in node$Node_num is less than expected"
+            return 1
+        fi
+        COUNTER=$[$COUNTER+1]
+    done
+    tst_resm TPASS "NUMA interleave policy -TEST03 PASSED !!"
+    return 0
+}
+
+
+
+# Function:     test04
+#
+# Description:  - Verification of physical cpu bind 
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+test04()
+{
+
+    TCID=numa04
+    TST_COUNT=4
+
+    no_of_cpus=0	#no. of cpu's exist 
+    run_on_cpu=0	
+    running_on_cpu=0
+
+    no_of_cpus=$(ls /sys/devices/system/cpu/ | wc -w)
+    # not sure whether cpu's can't be in odd number
+    run_on_cpu=$[$[$no_of_cpus+1]/2]		
+    numactl --physcpubind=$run_on_cpu support_numa $PAUSE & #just waits for sigint
+    pid=$!
+    # Warning !! 39 represents cpu number, on which process pid is currently running and 
+    # this may change if Some more fields are added in the middle, may be in future
+    running_on_cpu=$(awk '{ print $39; }' /proc/$pid/stat) 
+    if [ $running_on_cpu -ne $run_on_cpu ]
+    then
+	 tst_resm TFAIL \
+	     "Test #4: Process running on cpu$running_on_cpu but expected to run on cpu$run_on_cpu"
+	 return 1
+    fi
+    RC=0
+    kill -INT $pid || RC=$?
+    if [ $RC -ne 0 ]
+    then
+        tst_brkm TBROK NULL "Kill on process $pid fails"
+    fi
+    tst_resm TPASS "NUMA phycpubind policy -TEST04 PASSED !!"
+    return 0
+}
+
+
+
+# Function:     test05
+#
+# Description:  - Verification of local node allocation 
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+test05()
+{
+    TCID=numa05
+    TST_COUNT=5
+
+    RC=0                # Return value from commands.
+    Prev_value=0        # extracted from the numastat o/p
+    Curr_value=0        # Current value extracted from numastat o/p
+    Exp_incr=0          # 1 MB/ PAGESIZE
+    Node_num=0
+    col=0
+    MB=$[1024*1024]
+
+    # Increase in numastat o/p is interms of pages
+    Exp_incr=$[$MB/$page_size]
+
+    COUNTER=1
+    while [  $COUNTER -le $max_node ]; do
+        Node_num=$[$COUNTER-1]          #Node numbers start from 0
+        col=$[$COUNTER+1]               #Node number in numastat o/p
+        numastat > $LTPTMP/numalog
+        extract_numastat local_node $local_node $col || return 1
+        Prev_value=$RC
+        numactl --cpunodebind=$Node_num --localalloc support_numa $ALLOC_1MB
+        numastat > $LTPTMP/numalog
+        extract_numastat local_node $local_node $col || return 1
+        Curr_value=$RC
+        comparelog $Prev_value $Curr_value
+        if [ $RC -lt $Exp_incr ]
+        then
+             tst_resm TFAIL \
+                 "Test #5: NUMA hit and localnode increase in node$Node_num is less than expected"
+            return 1
+        fi
+        COUNTER=$[$COUNTER+1]
+    done
+    tst_resm TPASS "NUMA local node allocation -TEST05 PASSED !!"
+    return 0 
+}
+
+
+
+# Function:     test06
+#
+# Description:  - Verification of shared memory interleaved on all nodes
+#
+# Return:       - zero on success.
+#               - non-zero on failure.
+test06()
+{
+    TCID=numa06
+    TST_COUNT=6
+
+    RC=0                # Return value from commands.
+    Prev_value=0        # extracted from the numastat o/p
+    declare -a parray   # array contains previous value of all nodes
+    Curr_value=0        # Current value extracted from numastat o/p
+    Exp_incr=0          # 1 MB/ (PAGESIZE*num_of_nodes)
+    Node_num=0
+    col=0
+    MB=$[1024*1024]
+
+    # Increase in numastat o/p is interms of pages
+    Exp_incr=$[$MB/$page_size]
+    # Pages will be allocated using round robin on nodes.
+    Exp_incr=$[$Exp_incr/$max_node]
+
+    # Check whether the pages are equally distributed among available nodes
+    numastat > $LTPTMP/numalog
+    COUNTER=1
+    while [  $COUNTER -le $max_node ]; do
+        col=$[$COUNTER+1]              #Node number in numastat o/p
+        extract_numastat numa_hit $numa_hit $col || return 1
+        Prev_value=$RC
+        parray[$COUNTER]=$Prev_value
+        COUNTER=$[$COUNTER+1]
+    done
+
+    numactl --length=1M --file /dev/shm/numa_shm --interleave=all --touch
+
+    numastat > $LTPTMP/numalog
+    COUNTER=1
+    while [  $COUNTER -le $max_node ]; do
+        col=$[$COUNTER+1]              #Node number in numastat o/p
+        Node_num=$[$COUNTER-1]         #Node numbers start from 0
+        extract_numastat numa_hit $numa_hit $col || return 1
+        Curr_value=$RC
+        comparelog ${parray[$COUNTER]} $Curr_value
+        if [ $RC -lt $Exp_incr ]
+        then
+             tst_resm TFAIL \
+                 "Test #6: NUMA numa_hit for shm file numa_shm in node$Node_num is less than expected"
+            return 1
+        fi
+        COUNTER=$[$COUNTER+1]
+    done
+    tst_resm TPASS "NUMA interleave policy on shared memory -TEST06 PASSED !!"
+    RC=0
+    rm -r /dev/shm/numa_shm || RC=$?
+    if [ $RC -ne 0 ]
+    then
+	tst_resm TINFO "Test #6: Failed removing shared memory file numa_shm"
+        return 1
+    fi
+    return 0
+}
+
+
+
+# Function:    main
+#
+# Description: - Execute all tests and report results.
+#
+# Exit:        - zero on success
+#              - non-zero on failure.
+    #WARNING!! Never use duplicate variables here...
+    TCID=numa
+    no_of_test=6	#total no. of testcases
+    no_of_test_failed=0	#total no. of testcases failed
+    numa_ret=0		#return value of main script
+
+    init_ret=0
+    init || init_ret=$?
+    if [ $init_ret -ne 0 ]
+    then 
+        tst_resm TFAIL "INIT NUMA FAILED !!"
+        exit $RC
+    fi
+
+    # call each testcases sequentially
+    COUNT=1
+    while [  $COUNT -le $no_of_test ]; do
+	call_test=$(echo test0$COUNT)
+        func_ret=0
+	$call_test || func_ret=$?
+        if [ $func_ret -ne 0 ]
+        then 
+            no_of_test_failed=$[$no_of_test_failed+1]
+        fi
+        COUNT=$[$COUNT+1]
+    done
+
+    TCID=numa
+    TST_COUNT=0
+
+    if [ $no_of_test_failed -ne 0 ]
+    then
+        numa_ret=1	#set return value to non-zero if any one of the testcas got failed
+        tst_resm TINFO "A total of $no_of_test_failed numa testcases FAILED !!"
+    else
+        numa_ret=0
+        tst_resm TINFO "All numa testcases PASSED !!"
+    fi
+
+exit $numa_ret
+
diff --git a/testcases/kernel/numa/support_numa.c b/testcases/kernel/numa/support_numa.c
new file mode 100644
index 0000000..96d15d4
--- /dev/null
+++ b/testcases/kernel/numa/support_numa.c
@@ -0,0 +1,122 @@
+/******************************************************************************/
+/*                                                                            */
+/* Copyright (c) International Business Machines  Corp., 2007                 */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software               */
+/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */
+/*                                                                            */
+/******************************************************************************/
+
+/******************************************************************************/
+/*                                                                            */
+/* File:        support_numa.c                                                     */
+/*                                                                            */
+/* Description: Allocates 1MB of memory and touches it to verify numa         */
+/*                                                                            */
+/* Author:      Sivakumar Chinnaiah  Sivakumar.C@in.ibm.com                   */
+/*                                                                            */
+/* History:     Created - Jul 18 2007 - Sivakumar Chinnaiah                   */
+/*                                                 Sivakumar.C@in.ibm.com     */
+/*                                                                            */
+/******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <signal.h>
+#include <limits.h>
+#include <string.h>
+#include "test.h"
+#include "usctest.h"
+
+/* Global Variables */
+#define MB (1<<20)
+#define PAGE_SIZE getpagesize()
+#define barrier() __asm__ __volatile__("": : :"memory")
+
+/* Extern Global Variables */
+extern int  Tst_count;               /* to avoid compilation errors. */
+extern char *TESTDIR;                /* to avoid compilation errors. */
+
+/* Global Variables */
+char *TCID     = "support_numa"; /* to avoid compilation errors. */
+int  TST_TOTAL = 1;                  /* to avoid compilation errors. */
+
+void sigfunc(int sig)
+{
+        tst_resm(TINFO, "#Caught signal signum=%d", sig);
+}
+
+/******************************************************************************/
+/*                                                                            */
+/* Function:    main                                                          */
+/*                                                                            */
+/* Description: Alloctes 1MB of memory and touches it to verify numa behaviour*/
+/*                                                                            */
+/* Input:       Describe input arguments to this program                      */
+/*               argv[1] ==1 then print pagesize                              */
+/*               argv[1] ==2 then allocate 1MB of memory                      */
+/*		 argv[1] ==3 then pause the program to catch sigint	      */
+/*                                                                            */
+/* Exit:       On failure - Exits with non-zero value.                        */
+/*             On success - exits with 0 exit value.                          */
+/*                                                                            */
+/******************************************************************************/
+
+int main( int argc, char *argv[] )
+{
+	int i;
+	char *buf = NULL;
+	int count=0;
+	struct sigaction sa;
+
+        switch(atoi(argv[1]))
+	{
+	case 1: printf("%d", PAGE_SIZE);
+		return 0;
+	case 2:
+		buf = (char*) malloc(MB);
+               	if (!buf) 
+		{
+			tst_resm(TINFO, "#Memory is not available\n");
+			tst_exit();
+			exit(2);
+		}
+       		for (i=0; i<MB; i+= PAGE_SIZE) 
+		{
+			count++;
+               		buf[i] = 'a';
+               		barrier();
+       		}
+		free(buf);
+		return 0;
+	case 3:
+                /* Trap SIGINT */
+                sa.sa_handler = sigfunc;
+                sa.sa_flags = SA_RESTART;
+                sigemptyset(&sa.sa_mask);
+                if( sigaction(SIGINT, &sa, 0) < 0 ) 
+		{
+			tst_brkm(TBROK, NULL, "#Sigaction SIGINT failed\n");
+			tst_exit();
+			exit(1);
+		}
+                /* wait for signat Int */
+                pause();
+		return 0;
+	default:
+		exit(1);
+	}
+}