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

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

References cu_error_reporter(), default_rt_allocator(), default_rt_deallocator(), default_rt_info_handler(), default_rt_reallocator(), default_rt_warning_handler(), lwgeom_set_handlers(), rt_set_handlers(), and setupfuncs.

72 {
73  int index;
74  char *suite_name;
75  CU_pSuite suite_to_run;
76  char *test_name;
77  CU_pTest test_to_run;
78  CU_ErrorCode errCode = 0;
79  CU_pTestRegistry registry;
80  int num_run;
81  int num_failed;
82  PG_SuiteSetup *setupfunc = setupfuncs;
83 
84  /* install the custom error handler */
86 
94  );
95 
96  /* initialize the CUnit test registry */
97  if (CUE_SUCCESS != CU_initialize_registry())
98  {
99  errCode = CU_get_error();
100  printf(" Error attempting to initialize registry: %d. See CUError.h for error code list.\n", errCode);
101  return errCode;
102  }
103 
104  /* Register all the test suites. */
105  while ( *setupfunc )
106  {
107  (*setupfunc)();
108  setupfunc++;
109  }
110 
111  /* Run all tests using the CUnit Basic interface */
112  CU_basic_set_mode(CU_BRM_VERBOSE);
113  if (argc <= 1)
114  {
115  errCode = CU_basic_run_tests();
116  }
117  else
118  {
119  /* NOTE: The cunit functions used here (CU_get_registry, CU_get_suite_by_name, and CU_get_test_by_name) are
120  * listed with the following warning: "Internal CUnit system functions. Should not be routinely called by users."
121  * However, there didn't seem to be any other way to get tests by name, so we're calling them. */
122  registry = CU_get_registry();
123  for (index = 1; index < argc; index++)
124  {
125  suite_name = argv[index];
126  test_name = NULL;
127  suite_to_run = CU_get_suite_by_name(suite_name, registry);
128  if (NULL == suite_to_run)
129  {
130  /* See if it's a test name instead of a suite name. */
131  suite_to_run = registry->pSuite;
132  while (suite_to_run != NULL)
133  {
134  test_to_run = CU_get_test_by_name(suite_name, suite_to_run);
135  if (test_to_run != NULL)
136  {
137  /* It was a test name. */
138  test_name = suite_name;
139  suite_name = suite_to_run->pName;
140  break;
141  }
142  suite_to_run = suite_to_run->pNext;
143  }
144  }
145  if (suite_to_run == NULL)
146  {
147  printf("\n'%s' does not appear to be either a suite name or a test name.\n\n", suite_name);
148  }
149  else
150  {
151  if (test_name != NULL)
152  {
153  /* Run only this test. */
154  printf("\nRunning test '%s' in suite '%s'.\n", test_name, suite_name);
155  /* This should be CU_basic_run_test, but that method is broken, see:
156  * https://sourceforge.net/tracker/?func=detail&aid=2851925&group_id=32992&atid=407088
157  * This one doesn't output anything for success, so we have to do it manually. */
158  errCode = CU_run_test(suite_to_run, test_to_run);
159  if (errCode != CUE_SUCCESS)
160  {
161  printf(" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
162  }
163  else
164  {
165  num_run = CU_get_number_of_asserts();
166  num_failed = CU_get_number_of_failures();
167  printf("\n %s - asserts - %3d passed, %3d failed, %3d total.\n\n",
168  (0 == num_failed ? "PASSED" : "FAILED"), (num_run - num_failed), num_failed, num_run);
169  }
170  }
171  else
172  {
173  /* Run all the tests in the suite. */
174  printf("\nRunning all tests in suite '%s'.\n", suite_name);
175  /* This should be CU_basic_run_suite, but that method is broken, see:
176  * https://sourceforge.net/tracker/?func=detail&aid=2851925&group_id=32992&atid=407088
177  * This one doesn't output anything for success, so we have to do it manually. */
178  errCode = CU_run_suite(suite_to_run);
179  if (errCode != CUE_SUCCESS)
180  {
181  printf(" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode);
182  }
183  else
184  {
185  num_run = CU_get_number_of_tests_run();
186  num_failed = CU_get_number_of_tests_failed();
187  printf("\n %s - tests - %3d passed, %3d failed, %3d total.\n",
188  (0 == num_failed ? "PASSED" : "FAILED"), (num_run - num_failed), num_failed, num_run);
189  num_run = CU_get_number_of_asserts();
190  num_failed = CU_get_number_of_failures();
191  printf(" - asserts - %3d passed, %3d failed, %3d total.\n\n",
192  (num_run - num_failed), num_failed, num_run);
193  }
194  }
195  }
196  }
197  /* Presumably if the CU_basic_run_[test|suite] functions worked, we wouldn't have to do this. */
198  CU_basic_show_failures(CU_get_failure_list());
199  printf("\n\n"); /* basic_show_failures leaves off line breaks. */
200  }
201  num_failed = CU_get_number_of_failures();
202  CU_cleanup_registry();
203  return num_failed;
204 }
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.
void rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator, rt_deallocator deallocator, rt_message_handler error_handler, rt_message_handler info_handler, rt_message_handler warning_handler)
This function is called when the PostgreSQL backend is taking care of the memory and we want to use p...
Definition: rt_api.c:846
PG_SuiteSetup setupfuncs[]
void(* PG_SuiteSetup)(void)
void default_rt_info_handler(const char *fmt, va_list ap)
Definition: rt_api.c:788
void default_rt_deallocator(void *mem)
Definition: rt_api.c:756
void * default_rt_reallocator(void *mem, size_t size)
Definition: rt_api.c:749
void * default_rt_allocator(size_t size)
The default memory/logging handlers installed by lwgeom_install_default_allocators() ...
Definition: rt_api.c:742
void 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...
Definition: lwutil.c:151
void default_rt_warning_handler(const char *fmt, va_list ap)
Definition: rt_api.c:775

Here is the call graph for this function: