Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
regression-utils.c File Reference
#include "ical.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

const char * ical_timet_string (const time_t t)
const char * ictt_as_string (struct icaltimetype t)
char * icaltime_as_ctime (struct icaltimetype t)
void die_on_errors_set (int val)
void _ok (char *test_name, int success, char *file, int linenum, char *test)
void _is (char *test_name, const char *str1, const char *str2, char *file, int linenum)
void _int_is (char *test_name, int i1, int i2, char *file, int linenum)
void verbose (int newval)
void test_start (int numtests)
void test_header (char *header, int set)
void test_end (void)
void test_run (char *test_name, void(*test_fcn)(void), int do_test, int headeronly)

Variables

static char ictt_str [1024]
int VERBOSE = 0
int QUIET = 0
static int die_on_errors = 0
 This variable is used to control whether we core dump on errors.
static int testnumber = 0
static int failed = 0
static int current_set = 0
struct {
int set
int test
failed_tests [1024]

Function Documentation

void _int_is ( char *  test_name,
int  i1,
int  i2,
char *  file,
int  linenum 
)

Definition at line 97 of file regression-utils.c.

                                                                       {
  _ok(test_name, (i1==i2), file, linenum, "");
  
  if (i1!=i2) {
    printf("#      got: %d\n", i1);
    printf("# expected: %d\n", i2);
  }
}

Here is the call graph for this function:

void _is ( char *  test_name,
const char *  str1,
const char *  str2,
char *  file,
int  linenum 
)

Definition at line 78 of file regression-utils.c.

                                                                                       {
  int diff;
  
  if (str1 == NULL || str2 == NULL) {
    diff = 1;
  } else {
    diff = strcmp(str1, str2);
  }

  if (!test_name) test_name = "()";

  _ok(test_name, (diff==0), file, linenum, "");
  
  if (diff) {
    printf("#      got: %s\n", str1 ? str1 : "(null)");
    printf("# expected: %s\n", str2 ? str2 : "(null)");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _ok ( char *  test_name,
int  success,
char *  file,
int  linenum,
char *  test 
)

Definition at line 59 of file regression-utils.c.

                                                                            {
  testnumber++;

  if (!QUIET || (QUIET && !success))
  printf("%sok %d - %s\n", (success)?"" : "not ", testnumber, test_name);
  if (!success) {
    failed_tests[failed].set  = current_set;
    failed_tests[failed].test = testnumber;
    failed++;

    printf("# test failed: \"%s\"\n", test);
    printf("#          at: %s:%-d\n", file, linenum);
  }

  if (die_on_errors == 1 && !success) {
    abort();
  }
}

Here is the caller graph for this function:

Definition at line 55 of file regression-utils.c.

                                {
  die_on_errors = 1;
}
const char* ical_timet_string ( const time_t  t)

Definition at line 10 of file regression-utils.c.

{
    struct tm stm = *(gmtime(&t));    

    sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d Z",stm.tm_year+1900,
           stm.tm_mon+1,stm.tm_mday,stm.tm_hour,stm.tm_min,stm.tm_sec);

    return ictt_str;
    
}

Here is the caller graph for this function:

char* icaltime_as_ctime ( struct icaltimetype  t)

Definition at line 36 of file regression-utils.c.

{
    time_t tt;
 
    tt = icaltime_as_timet(t);
    sprintf(ictt_str,"%s",ctime(&tt));

    return ictt_str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* ictt_as_string ( struct icaltimetype  t)

Definition at line 21 of file regression-utils.c.

{
    const char *zone = icaltimezone_get_tzid((icaltimezone *)t.zone);

    if (icaltime_is_utc(t))
       sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d Z UTC",
       t.year,t.month,t.day, t.hour,t.minute,t.second);
    else
       sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d %s",
       t.year,t.month,t.day, t.hour,t.minute,t.second,
       zone == NULL? "(floating)": zone);

    return ictt_str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 127 of file regression-utils.c.

                    {
  int pct;

  if (failed) {
    int i, oldset = 0;
    
    pct = ((testnumber - failed)*100)/testnumber;
    printf("\n        Failed %d/%d tests, %2d%% okay\n", failed, testnumber, pct);
    printf("\n        Failed tests:\n          ");
    for (i = 0; i < failed; i++) {
      int this_set = failed_tests[i].set;
      char *prefix = "";
      if (this_set != oldset) {
       prefix = "\n          ";
       oldset = this_set;
      }
      
      printf("%s%d/%d ", prefix, this_set, failed_tests[i].test);
    }
    printf("\n");
      
  } else {
    printf("\n        All Tests Successful.\n");
  }
}

Here is the caller graph for this function:

void test_header ( char *  header,
int  set 
)

Definition at line 121 of file regression-utils.c.

                                        {
  if (!QUIET)
  printf("########## %-40s (%d) ##########\n", header, set);
  current_set = set;
}

Here is the caller graph for this function:

void test_run ( char *  test_name,
void(*)(void test_fcn,
int  do_test,
int  headeronly 
)

Definition at line 154 of file regression-utils.c.

{
  static int test_set = 1;

  if (headeronly || do_test == 0 || do_test == test_set)
    test_header(test_name, test_set);
  
  if (!headeronly && (do_test==0 || do_test == test_set)) {
    (*test_fcn)();
    if (!QUIET)
    printf("\n");
  }
  test_set++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_start ( int  numtests)

Definition at line 111 of file regression-utils.c.

                              {
  if (numtests) {
    if (!QUIET)
    printf("1..%-d\n", numtests);
  } else {
    if (!QUIET)
    printf("1..\n");
  }
}

Here is the caller graph for this function:

void verbose ( int  newval)

Definition at line 107 of file regression-utils.c.

                         {
  VERBOSE = newval;
}

Variable Documentation

int current_set = 0 [static]

Definition at line 51 of file regression-utils.c.

int die_on_errors = 0 [static]

This variable is used to control whether we core dump on errors.

Definition at line 48 of file regression-utils.c.

int failed = 0 [static]

Definition at line 50 of file regression-utils.c.

struct { ... } failed_tests[1024] [static]
char ictt_str[1024] [static]

Definition at line 6 of file regression-utils.c.

int QUIET = 0

Definition at line 8 of file regression-utils.c.

int testnumber = 0 [static]

Definition at line 49 of file regression-utils.c.

int VERBOSE = 0

Definition at line 7 of file regression-utils.c.