Hi All,
memory controller testcase2.

Signed-off-by: Sudhir Kumar <[EMAIL PROTECTED]>
Acked-by: Balbir Singh <[EMAIL PROTECTED]>



Index: ltp-full-20080229/testcases/kernel/controllers/memctl/memctl_test01.c
===================================================================
--- ltp-full-20080229.orig/testcases/kernel/controllers/memctl/memctl_test01.c
+++ ltp-full-20080229/testcases/kernel/controllers/memctl/memctl_test01.c
@@ -62,6 +62,7 @@ int num_of_chunks, chunk_size, test_num,
 
 extern void cleanup();
 void signal_handler_sigusr1 (int signal);
+void signal_handler_sigusr2 (int signal);
 int allocate_memory(void);
 
 int main(int argc, char *argv[])
@@ -69,7 +70,7 @@ int main(int argc, char *argv[])
        int ret;
        char mygroup[FILENAME_MAX], mytaskfile[FILENAME_MAX];
        char *mygroup_p, *script_pid_p, *test_num_p, *chunk_size_p, 
*num_chunks_p;
-       struct sigaction newaction1, oldaction1;
+       struct sigaction newaction1, newaction2, oldaction1, oldaction2;
 
        /* Signal handling for SIGUSR1 recieved from script */
        sigemptyset (&newaction1.sa_mask);
@@ -77,6 +78,12 @@ int main(int argc, char *argv[])
        newaction1.sa_flags=0;
        sigaction (SIGUSR1, &newaction1, &oldaction1);
 
+       /* Signal handling for SIGUSR2 recieved from script */
+       sigemptyset (&newaction2.sa_mask);
+       newaction2.sa_handler = signal_handler_sigusr2;
+       newaction2.sa_flags=0;
+       sigaction (SIGUSR2, &newaction2, &oldaction2);
+
        /*
         *Capture variables from the script environment
         */
@@ -134,6 +141,21 @@ void signal_handler_sigusr1 (int signal)
        exit (0);
 }
 
+/*
+ * Function: signal_handler_sigusr2()
+ * signal handler for the new action
+ */
+
+void signal_handler_sigusr2 (int signal)
+{
+       int i;
+       for (i=0; i< num_of_chunks; ++i)
+               free(array_of_chunks[i]);
+       free(array_of_chunks);
+       allocate_memory();
+}
+
+
 int allocate_memory()
 {
        int i, j;
Index: ltp-full-20080229/testcases/kernel/controllers/memctl/run_memctl_test.sh
===================================================================
--- 
ltp-full-20080229.orig/testcases/kernel/controllers/memctl/run_memctl_test.sh
+++ ltp-full-20080229/testcases/kernel/controllers/memctl/run_memctl_test.sh
@@ -71,7 +71,8 @@ fi
 
 case ${TEST_NUM} in
 
-"1" )  NUM_GROUPS=2;
+"1" | "2" )
+       NUM_GROUPS=2;
        MEMLIMIT_GROUP_1=100M;
        MEMLIMIT_GROUP_2=132M;
        CHUNK_SIZE=6291456;                             # malloc n chunks of 
size m(6M)
@@ -101,7 +102,7 @@ echo "TEST STARTED: Please avoid using s
 #Check if  C source  file has been compiled and then run it in different groups
 
 case $TEST_NUM in
-"1")
+"1" | "2" )
        setmemlimits;
        if [ -f memctl_test01 ]
        then
@@ -156,27 +157,56 @@ case $TEST_NUM in
                # Wait for some time to check if memory usage of group_2 
increases
                # This is not the right approach however working. ??? 
thoughts???
                sleep 10;
-               GRP2_MEMUSAGE_NEW=`cat 
/dev/memctl/group_2/memory.usage_in_bytes`;
-               echo After task migration to group2
-               echo group2 memory usage: $GRP2_MEMUSAGE_NEW Bytes
 
                # Decision formula: decides PASS or FAIL
-               if [ $GRP2_MEMUSAGE_NEW -gt $GRP2_MEMUSAGE_OLD ]
-               then
-                       echo "TFAIL   Memory resource Controller:  Task 
Migration test FAILED";
-               else
-                       echo "TPASS   Memory Resource Controller: Task 
Migration test PASSED";
-               fi
+               case $TEST_NUM in
+               "1" )
+                       GRP2_MEMUSAGE_NEW=`cat 
/dev/memctl/group_2/memory.usage_in_bytes`;
+                       echo After task migration to group2
+                       echo group2 memory usage: $GRP2_MEMUSAGE_NEW Bytes
 
-                       # here we can add another testcases
+                       if [ $GRP2_MEMUSAGE_NEW -gt $GRP2_MEMUSAGE_OLD ]
+                       then
+                               echo "TFAIL   Memory resource Controller:  Task 
Migration test $TEST_NUM FAILED";
+                       else
+                               echo "TPASS   Memory Resource Controller: Task 
Migration test $TEST_NUM PASSED";
+                       fi
 
                        # Now we can signal the task to finish and do the 
cleanup
-               for i in $(seq 1 $TOTAL_TASKS)
-               do
-                       kill -SIGUSR1 ${PID[$i]};
-               done
-       else
-               echo "Source file not compiled..Plz check Makefile...Exiting 
test"
+                       for i in $(seq 1 $TOTAL_TASKS)
+                       do
+                               kill -SIGUSR1 ${PID[$i]};
+                       done
+                       ;;
+               "2" )
+                       GRP2_MEMUSAGE_OLD=`cat 
/dev/memctl/group_2/memory.usage_in_bytes`;
+
+                       # signal the migrated tasks to allocate memory
+                       for i in $(seq 1 $TOTAL_TASKS)
+                       do
+                               kill -SIGUSR2 ${PID[$i]};
+                       done
+                       sleep 10; # Is it fine? Need input/alternates
+                       GRP2_MEMUSAGE_NEW=`cat 
/dev/memctl/group_2/memory.usage_in_bytes`;
+                       echo After task migration to group2 and doing malloc
+                       echo group2 memory usage: $GRP2_MEMUSAGE_NEW Bytes
+                       if [ $GRP2_MEMUSAGE_NEW -le $GRP2_MEMUSAGE_OLD ]
+                       then
+                               echo "TFAIL   Memory resource Controller:  Task 
Migration test $TEST_NUM FAILED";
+                       else
+                               # Now we can signal the task to finish and do 
the cleanup
+                               for i in $(seq 1 $TOTAL_TASKS)
+                               do
+                                       kill -SIGUSR1 ${PID[$i]};
+                               done
+                               echo "TPASS   Memory Resource Controller: Task 
Migration test $TEST_NUM PASSED";
+                       fi
+
+                       ;;
+               esac
+
+               else
+               echo "Source file not compiled..Please check Makefile...Exiting 
test"
                cleanup;
                exit -1;
        fi;
Index: ltp-full-20080229/testcases/kernel/controllers/test_controllers.sh
===================================================================
--- ltp-full-20080229.orig/testcases/kernel/controllers/test_controllers.sh
+++ ltp-full-20080229/testcases/kernel/controllers/test_controllers.sh
@@ -60,6 +60,7 @@ then
        if [ "$MEM_CONTROLLER" = "memory" ]
        then
                $LTPROOT/testcases/bin/run_memctl_test.sh 1;
+               $LTPROOT/testcases/bin/run_memctl_test.sh 2;
        else
                echo "CONTROLLERS TESTCASES: WARNING";
                echo "Kernel does not support for memory controller";


Thanks
Sudhir

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to