PostGIS  2.2.7dev-r@@SVN_REVISION@@
int main ( int  argc,
char *  argv[] 
)

Definition at line 59 of file raster/test/cunit/cu_tester.c.

References cu_error_reporter(), and setupfuncs.

60 {
61  int index;
62  char *suite_name;
63  CU_pSuite suite_to_run;
64  char *test_name;
65  CU_pTest test_to_run;
66  CU_ErrorCode errCode = 0;
67  CU_pTestRegistry registry;
68  int num_run;
69  int num_failed;
70  PG_SuiteSetup *setupfunc = setupfuncs;
71 
72  /* install the custom error handler */
74 
75  /* initialize the CUnit test registry */
76  if (CUE_SUCCESS != CU_initialize_registry())
77  {
78  errCode = CU_get_error();
79  printf(" Error attempting to initialize registry: %d. See CUError.h for error code list.\n", errCode);
80  return errCode;
81  }
82 
83  /* Register all the test suites. */
84  while ( *setupfunc )
85  {
86  (*setupfunc)();
87  setupfunc++;
88  }
89 
90  /* Run all tests using the CUnit Basic interface */
91  CU_basic_set_mode(CU_BRM_VERBOSE);
92  if (argc <= 1)
93  {
94  errCode = CU_basic_run_tests();
95  }
96  else
97  {
98  /* NOTE: The cunit functions used here (CU_get_registry, CU_get_suite_by_name, and CU_get_test_by_name) are
99  * listed with the following warning: "Internal CUnit system functions. Should not be routinely called by users."
100  * However, there didn't seem to be any other way to get tests by name, so we're calling them. */
101  registry = CU_get_registry();
102  for (index = 1; index < argc; index++)
103  {
104  suite_name = argv[index];
105  test_name = NULL;
106  suite_to_run = CU_get_suite_by_name(suite_name, registry);
107  if (NULL == suite_to_run)
108  {
109  /* See if it's a test name instead of a suite name. */
110  suite_to_run = registry->pSuite;
111  while (suite_to_run != NULL)
112  {
113  test_to_run = CU_get_test_by_name(suite_name, suite_to_run);
114  if (test_to_run != NULL)
115  {
116  /* It was a test name. */
117  test_name = suite_name;
118  suite_name = suite_to_run->pName;
119  break;
120  }
121  suite_to_run = suite_to_run->pNext;
122  }
123  }
124  if (suite_to_run == NULL)
125  {
126  printf("\n'%s' does not appear to be either a suite name or a test name.\n\n", suite_name);
127  }
128  else
129  {
130  if (test_name != NULL)
131  {
132  /* Run only this test. */
133  printf("\nRunning test '%s' in suite '%s'.\n", test_name, suite_name);
134  /* This should be CU_basic_run_test, but that method is broken, see:
135  * https://sourceforge.net/tracker/?func=detail&aid=2851925&group_id=32992&atid=407088
136  * This one doesn't output anything for success, so we have to do it manually. */
137  errCode = CU_run_test(suite_to_run, test_to_run);
138  if (errCode != CUE_SUCCESS)
139  {
140  printf(" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
141  }
142  else
143  {
144  num_run = CU_get_number_of_asserts();
145  num_failed = CU_get_number_of_failures();
146  printf("\n %s - asserts - %3d passed, %3d failed, %3d total.\n\n",
147  (0 == num_failed ? "PASSED" : "FAILED"), (num_run - num_failed), num_failed, num_run);
148  }
149  }
150  else
151  {
152  /* Run all the tests in the suite. */
153  printf("\nRunning all tests in suite '%s'.\n", suite_name);
154  /* This should be CU_basic_run_suite, but that method is broken, see:
155  * https://sourceforge.net/tracker/?func=detail&aid=2851925&group_id=32992&atid=407088
156  * This one doesn't output anything for success, so we have to do it manually. */
157  errCode = CU_run_suite(suite_to_run);
158  if (errCode != CUE_SUCCESS)
159  {
160  printf(" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
161  }
162  else
163  {
164  num_run = CU_get_number_of_tests_run();
165  num_failed = CU_get_number_of_tests_failed();
166  printf("\n %s - tests - %3d passed, %3d failed, %3d total.\n",
167  (0 == num_failed ? "PASSED" : "FAILED"), (num_run - num_failed), num_failed, num_run);
168  num_run = CU_get_number_of_asserts();
169  num_failed = CU_get_number_of_failures();
170  printf(" - asserts - %3d passed, %3d failed, %3d total.\n\n",
171  (num_run - num_failed), num_failed, num_run);
172  }
173  }
174  }
175  }
176  /* Presumably if the CU_basic_run_[test|suite] functions worked, we wouldn't have to do this. */
177  CU_basic_show_failures(CU_get_failure_list());
178  printf("\n\n"); /* basic_show_failures leaves off line breaks. */
179  }
180  num_failed = CU_get_number_of_failures();
181  CU_cleanup_registry();
182  return num_failed;
183 }
static void cu_error_reporter(const char *fmt, va_list ap)
CUnit error handler Log message in a global var instead of printing in stderr.
PG_SuiteSetup setupfuncs[]
void(* PG_SuiteSetup)(void)
void(*) typedef void(*) voi lwgeom_set_handlers)(lwallocator allocator, lwreallocator reallocator, lwfreeor freeor, lwreporter errorreporter, lwreporter noticereporter)
Install custom memory management and error handling functions you want your application to use...

Here is the call graph for this function: