Convert mmstress to use the standard results format.

---
 testcases/kernel/mem/mtest05/Makefile   |    2 
 testcases/kernel/mem/mtest05/mmstress.c |   76 ++++++++++++++++----------------
 2 files changed, 41 insertions(+), 37 deletions(-)

--- ltp-full-20070630.orig/testcases/kernel/mem/mtest05/Makefile
+++ ltp-full-20070630/testcases/kernel/mem/mtest05/Makefile
@@ -1,5 +1,7 @@
 CFLAGS += -Wall -O -g
+CFLAGS += -I../../../../include
 LDLIBS := -lpthread
+LOADLIBES+=    -L../../../../lib -lltp
 
 SRCS=$(wildcard *.c)
 TARGETS=$(patsubst %.c,%,$(SRCS))
--- ltp-full-20070630.orig/testcases/kernel/mem/mtest05/mmstress.c
+++ ltp-full-20070630/testcases/kernel/mem/mtest05/mmstress.c
@@ -99,6 +99,8 @@
 #include <string.h>   /* declaration for memset                               
*/
 #include <sched.h>    /* declaration of sched_yield()                         
*/
 
+#include "test.h"
+
 /* GLOBAL DEFINES                                                             
*/
 #define SIGENDSIG    -1   /* end of signal marker                             
*/
 #define THNUM        0    /* array element pointing to number of threads      
*/
@@ -142,6 +144,8 @@ static   int  wait_thread = 0;       /* 
 static   int  thread_begin = 0;      /* used to coordinate threads            
*/
 static   int  verbose_print = FALSE; /* print more test information           
*/
 
+char *TCID = "mmstress";
+int TST_TOTAL = 6;
 
 
/******************************************************************************/
 /*                                                                            
*/
@@ -169,7 +173,7 @@ sig_handler(int signal) /* signal number
         exit(-1);
     }
     else
-        fprintf(stdout, "Test ended, success\n");
+       tst_resm(TPASS, "Test ended, success");
     exit(0);
 }
 
@@ -192,8 +196,8 @@ usage(char *progname)        /* name of 
 {
     fprintf(stderr, "usage:%s -h -n test -t time -v [-V]\n", progname);
     fprintf(stderr, "\t-h displays all options\n");
-    fprintf(stderr, "\t-n the test number, if no test number\n"
-            "\t   is specified all the tests will be run\n");
+    fprintf(stderr, "\t-n test number, if no test number\n"
+            "\t   is specified, all the tests will be run\n");
     fprintf(stderr, "\t-t specify the time in hours\n");
     fprintf(stderr, "\t-v verbose output\n");
     fprintf(stderr, "\t-V program version\n");
@@ -287,8 +291,8 @@ thread_fault(void *args)         /* poin
                                            : (*start_addr = write_to_addr[0]);
         start_addr += local_args[PAGESIZ]; 
         if (verbose_print)
-            fprintf(stdout, "thread_fault(): generating fault type %ld" 
-                            " @page adress %p\n", local_args[3], start_addr);
+           tst_resm(TINFO, "thread_fault(): generating fault type %ld"
+                            " @page address %p", local_args[3], start_addr);
         fflush(NULL);
     }
     PTHREAD_EXIT(0);
@@ -328,7 +332,7 @@ remove_files(char *filename, char * addr
     else
     {
         if (verbose_print)
-            fprintf(stdout, "file %s removed\n", filename);
+            tst_resm(TINFO, "file %s removed", filename);
         
     }      
     return SUCCESS;
@@ -430,8 +434,8 @@ map_and_thread(
         {
             retinfo->mapaddr = map_addr;
             if (verbose_print)
-                fprintf(stdout, 
-                "map_and_thread(): mmap success, address = %p\n", map_addr);
+                tst_resm(TINFO,
+                  "map_and_thread(): mmap success, address = %p", map_addr);
             fflush(NULL);
         }
     }
@@ -484,7 +488,7 @@ map_and_thread(
     } while (thrd_ndx < num_thread);
 
     if (verbose_print)
-        fprintf(stdout, "map_and_thread(): pthread_create() success\n");
+        tst_resm(TINFO, "map_and_thread(): pthread_create() success");
     wait_thread = FALSE; 
     th_status = malloc(sizeof(int *));
     
@@ -507,8 +511,8 @@ map_and_thread(
         {
             if ((int)*th_status == 1)
             {
-                fprintf(stderr,
-                        "thread [%ld] - process exited with errors\n",
+                tst_resm(TINFO,
+                        "thread [%ld] - process exited with errors",
                 (long)pthread_ids[thrd_ndx]);
                 free(empty_buf);                          
                 remove_files(tmpfile, map_addr);
@@ -563,8 +567,8 @@ test1() 
 {
     RETINFO_t retval;    /* contains info relating to test status          */
 
-    printf("\ttest1: Test case tests the race condition between\n"
-           "\t\tsimultaneous read faults in the same address space.\n");
+    tst_resm(TINFO, "test1: Test case tests the race condition between "
+           "simultaneous read faults in the same address space.");
     map_and_thread("./tmp.file.1", thread_fault, READ_FAULT, NUMTHREAD, 
                    &retval);
     return (retval.status);
@@ -592,8 +596,8 @@ test2() 
 {
     RETINFO_t retval;    /* contains test stats information               */
 
-    printf("\ttest2: Test case tests the race condition between\n"
-       "\t\tsimultaneous write faults in the same address space.\n");
+    tst_resm(TINFO, "test2: Test case tests the race condition between "
+       "simultaneous write faults in the same address space.");
     map_and_thread("./tmp.file.2", thread_fault, WRITE_FAULT, NUMTHREAD, 
                    &retval);
     return (retval.status);
@@ -621,8 +625,8 @@ test3() 
 {
     RETINFO_t retval;    /* contains test stats information                   
*/
  
-    printf("\ttest3: Test case tests the race condition between\n"
-           "\t\tsimultaneous COW faults in the same address space.\n");
+    tst_resm(TINFO, "test3: Test case tests the race condition between "
+           "simultaneous COW faults in the same address space.");
     map_and_thread("./tmp.file.3", thread_fault, COW_FAULT, NUMTHREAD, 
&retval);
     return (retval.status);
 }
@@ -649,9 +653,9 @@ test4() 
 {
     RETINFO_t retval;     /* contains test status information                 
*/
 
-    printf("\ttest4: Test case tests the race condition between\n"
-           "\t\tsimultaneous READ faults in the same address space.\n"
-           "\t\tThe file mapped is /dev/zero\n");
+    tst_resm(TINFO, "test4: Test case tests the race condition between "
+           "simultaneous READ faults in the same address space. "
+           "The file mapped is /dev/zero");
     map_and_thread("/dev/zero", thread_fault, COW_FAULT, NUMTHREAD, &retval);
     return (retval.status);
 }
@@ -679,8 +683,8 @@ test5() 
     pid_t  pid      = 0;    /* process id, returned by fork system call.      
*/
     int    wait_status = 0; /* if status is not NULL store status information 
*/
 
-    printf("\ttest5: Test case tests the race condition between\n"
-           "\t\tsimultaneous fork - exit faults in the same address space.\n");
+    tst_resm(TINFO, "test5: Test case tests the race condition between "
+           "simultaneous fork - exit faults in the same address space.");
 
     /* increment the  program's  data  space  by 200*1024 (BRKSZ) bytes       
*/
 
@@ -708,7 +712,7 @@ test5() 
     
     if (sbrk(-BRKSZ) == (caddr_t)-1)
     {
-        fprintf(stderr, "test5(): rollback sbrk failed\n");
+        tst_resm(TINFO, "test5(): rollback sbrk failed");
         fflush(NULL);
         perror("test5(): sbrk()");
         fflush(NULL);
@@ -744,9 +748,8 @@ test6()
     char  *argv_init[2] =  /* parameter required for dummy function to execvp 
*/
                           {"arg1", NULL};
 
-    printf("\ttest6: Test case tests the race condition between\n"
-           "\t\tsimultaneous fork -exec - exit faults in the same\n"
-           "\t\taddress space.\n");
+    tst_resm(TINFO, "test6: Test case tests the race condition between "
+           "simultaneous fork -exec - exit faults in the same address space.");
 
     /* increment the  program's  data  space  by 200*1024 (BRKSZ) bytes       
*/
     
@@ -797,7 +800,7 @@ test6()
    
     if (sbrk(-BRKSZ) == (caddr_t)-1)
     {
-        fprintf(stderr, "test6(): rollback sbrk failed\n");
+        tst_resm(TINFO, "test6(): rollback sbrk failed");
         fflush(NULL);
         perror("test6(): sbrk()");
         fflush(NULL);
@@ -878,7 +881,7 @@ main(int   argc,     /* number of comman
     opterr = 0;
 
     if (argc < 2)
-    fprintf(stderr, "\nINFO: run %s -h for all options\n\n", argv[0]);
+    tst_resm(TINFO, "run %s -h for all options", argv[0]);
 
     while ((ch = getopt(argc, argv, "hn:t:vV")) != -1)
     {
@@ -893,8 +896,8 @@ main(int   argc,     /* number of comman
                       break;
             case 't': if (optarg)
                       {
-                          printf("Test is scheduled to run for %d hours\n",
-                          test_time = atoi(optarg));
+                          tst_resm(TINFO, "Test is scheduled to run for %d 
hours",
+                               test_time = atoi(optarg));
                           run_once = FALSE;
                       }
                       else
@@ -905,8 +908,7 @@ main(int   argc,     /* number of comman
             case 'V': if (!version_flag)
                       {
                           version_flag = TRUE;
-                          fprintf(stderr, "%s: %s\n", prog_name,
-                          version_info);
+                          tst_resm(TINFO, "%s: %s", prog_name, version_info);
                       }
                       break;
             case '?': if (argc < optind)
@@ -959,9 +961,9 @@ main(int   argc,     /* number of comman
             for (test_ndx = 1; test_ndx <= MAXTEST; test_ndx++) {
                 rc = test_ptr[test_ndx]();
                 if (rc == SUCCESS) {
-                   printf("                TEST %d Passed\n", test_ndx);
+                   tst_resm(TPASS, "TEST %d Passed", test_ndx);
                 } else {
-                   printf("                TEST %d Failed\n", test_ndx);
+                   tst_resm(TFAIL, "TEST %d Failed", test_ndx);
                    global_rc = rc;
                 }
             }
@@ -976,16 +978,16 @@ main(int   argc,     /* number of comman
         }
 
         if (global_rc != SUCCESS) {
-            printf("mmstress:  Test Failed\n");
+            tst_resm(TFAIL, "Test Failed");
             exit(global_rc);
         }
 
     } while ((TRUE) && (!run_once));
 
     if (global_rc != SUCCESS) {
-        printf("mmstress:  Test Failed\n");
+        tst_resm(TFAIL, "Test Failed");
     } else {
-        printf("mmstress:  Test Passed\n");
+        tst_resm(TPASS, "Test Passed");
     }
     exit(global_rc);
 }

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to