You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2004/05/14 09:13:46 UTC

cvs commit: apr/test abts.c

jorton      2004/05/14 00:13:46

  Modified:    test     abts.c
  Log:
  * test/abts.c (report): Just print "success" if there were no failures.
  (update_status, main): Suppress the spinning bar if -q is used, and fix
  calloc usage.
  
  Revision  Changes    Path
  1.2       +22 -7     apr/test/abts.c
  
  Index: abts.c
  ===================================================================
  RCS file: /home/cvs/apr/test/abts.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -d -u -r1.1 -r1.2
  --- abts.c	13 May 2004 00:50:20 -0000	1.1
  +++ abts.c	14 May 2004 07:13:46 -0000	1.2
  @@ -25,6 +25,7 @@
   static int curr_char;
   static int verbose = 0;
   static int exclude = 0;
  +static int quiet = 0;
   
   const char **testlist = NULL;
   
  @@ -58,9 +59,11 @@
   
   static void update_status(void)
   {
  -    curr_char = (curr_char + 1) % ABTS_STAT_SIZE;
  -    fprintf(stdout, "\b%c", status[curr_char]);
  -    fflush(stdout);
  +    if (!quiet) {
  +        curr_char = (curr_char + 1) % ABTS_STAT_SIZE;
  +        fprintf(stdout, "\b%c", status[curr_char]);
  +        fflush(stdout);
  +    }
   }
   
   static void end_suite(abts_suite *suite)
  @@ -146,13 +149,22 @@
   
   static int report(abts_suite *suite)
   {
  -    int return_failed = 0;
  +    int count = 0;
       sub_suite *dptr;
   
       if (suite && suite->tail &&!suite->tail->not_run) {
           end_suite(suite);
       }
   
  +    for (dptr = suite->head; dptr; dptr = dptr->next) {
  +        count += dptr->failed;
  +    }
  +
  +    if (count == 0) {
  +        printf("All tests passed.\n");
  +        return 0;
  +    }
  +
       dptr = suite->head;
       fprintf(stdout, "%-15s\t\tTotal\tFail\tFailed %%\n", "Failed Tests");
       fprintf(stdout, "===================================================\n");
  @@ -161,11 +173,10 @@
               float percent = ((float)dptr->failed / (float)dptr->num_test);
               fprintf(stdout, "%-15s\t\t%5d\t%4d\t%6.2f%%\n", dptr->name, 
                       dptr->num_test, dptr->failed, percent * 100);
  -            return_failed = 1;
           }
           dptr = dptr->next;
       }
  -    return return_failed;
  +    return 1;
   }
   
   void abts_log_message(const char *fmt, ...)
  @@ -338,6 +349,10 @@
               /* print the list. */
               continue;
           }
  +        if (!strcmp(argv[i], "-q")) {
  +            quiet = 1;
  +            continue;
  +        }
           if (argv[i][0] == '-') {
               fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
               exit(1);
  @@ -349,7 +364,7 @@
           /* Waste a little space here, because it is easier than counting the
            * number of tests listed.  Besides it is at most three char *.
            */
  -        testlist = calloc(0, sizeof(char *) * (argc + 1));
  +        testlist = calloc(argc + 1, sizeof(char *));
           for (i = 1; i < argc; i++) {
               testlist[i - 1] = argv[i];
           }