]> granicus.if.org Git - postgis/commitdiff
#3041, Cunit 2.1-3 breaks testing
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 18 Feb 2015 22:56:28 +0000 (22:56 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 18 Feb 2015 22:56:28 +0000 (22:56 +0000)
Renovate the raster cunit as well

git-svn-id: http://svn.osgeo.org/postgis/trunk@13238 b70326c6-7e19-0410-871a-916f4a2858ee

16 files changed:
liblwgeom/cunit/cu_tester.c
liblwgeom/cunit/cu_tester.h
raster/test/cunit/cu_band_basics.c
raster/test/cunit/cu_band_misc.c
raster/test/cunit/cu_band_stats.c
raster/test/cunit/cu_gdal.c
raster/test/cunit/cu_mapalgebra.c
raster/test/cunit/cu_misc.c
raster/test/cunit/cu_pixtype.c
raster/test/cunit/cu_raster_basics.c
raster/test/cunit/cu_raster_geometry.c
raster/test/cunit/cu_raster_misc.c
raster/test/cunit/cu_raster_wkb.c
raster/test/cunit/cu_spatial_relationship.c
raster/test/cunit/cu_tester.c
raster/test/cunit/cu_tester.h

index 408009e37044f68f2a9e8880f0925cdca3f1cfce..e801f5af0361a236d4907ed5088c3b137673df41 100644 (file)
@@ -113,11 +113,12 @@ int main(int argc, char *argv[])
        CU_pTestRegistry registry;
        int num_run;
        int num_failed;
+       PG_SuiteSetup *setupfunc = setupfuncs;
 
-       /* install the custom error handler */
+       /* Install the custom error handler */
        lwgeom_set_handlers(0, 0, 0, cu_errorreporter, 0);
 
-       /* initialize the CUnit test registry */
+       /* Initialize the CUnit test registry */
        if (CUE_SUCCESS != CU_initialize_registry())
        {
                errCode = CU_get_error();
@@ -125,21 +126,13 @@ int main(int argc, char *argv[])
                return errCode;
        }
 
-       PG_SuiteSetup *setupfunc = setupfuncs;
+       /* Register all the test suites. */
        while ( *setupfunc )
        {
                (*setupfunc)();
                setupfunc++;
        }
 
-       /* Register all the test suites. */
-       // if (CUE_SUCCESS != CU_register_suites(suites))
-       // {
-       //      errCode = CU_get_error();
-       //      printf("    Error attempting to register test suites: %d.  See CUError.h for error code list.\n", errCode);
-       //      return errCode;
-       // }
-
        /* Run all tests using the CUnit Basic interface */
        CU_basic_set_mode(CU_BRM_VERBOSE);
        if (argc <= 1)
index b926764a0dd94f9474933208471b67d613b9db0a..242bef74fb95e384dba7fc2863cbdf7ab6bf7f2b 100644 (file)
@@ -9,8 +9,6 @@
  *
  **********************************************************************/
 
-#define PG_TEST(test_func) { #test_func, test_func }
-
 #define MAX_CUNIT_ERROR_LENGTH 512
 
 #define PG_ADD_TEST(suite, testfunc) CU_add_test(suite, #testfunc, testfunc)
index 45ada1fa034ba67682647eef2533d79ce8fb5bee..72b6b841b1dbfc114ba5b1ed7966ceccd9afcb1f 100644 (file)
@@ -1253,20 +1253,22 @@ static void test_band_get_pixel_line() {
 }
 
 /* register tests */
-CU_TestInfo band_basics_tests[] = {
-       PG_TEST(test_band_metadata),
-       PG_TEST(test_band_pixtype_1BB),
-       PG_TEST(test_band_pixtype_2BUI),
-       PG_TEST(test_band_pixtype_4BUI),
-       PG_TEST(test_band_pixtype_8BUI),
-       PG_TEST(test_band_pixtype_8BSI),
-       PG_TEST(test_band_pixtype_16BUI),
-       PG_TEST(test_band_pixtype_16BSI),
-       PG_TEST(test_band_pixtype_32BUI),
-       PG_TEST(test_band_pixtype_32BSI),
-       PG_TEST(test_band_pixtype_32BF),
-       PG_TEST(test_band_pixtype_64BF),
-       PG_TEST(test_band_get_pixel_line),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo band_basics_suite = {"band_basics",  NULL,  NULL, band_basics_tests};
+void band_basics_suite_setup(void);
+void band_basics_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("band_basics", NULL, NULL);
+       PG_ADD_TEST(suite, test_band_metadata);
+       PG_ADD_TEST(suite, test_band_pixtype_1BB);
+       PG_ADD_TEST(suite, test_band_pixtype_2BUI);
+       PG_ADD_TEST(suite, test_band_pixtype_4BUI);
+       PG_ADD_TEST(suite, test_band_pixtype_8BUI);
+       PG_ADD_TEST(suite, test_band_pixtype_8BSI);
+       PG_ADD_TEST(suite, test_band_pixtype_16BUI);
+       PG_ADD_TEST(suite, test_band_pixtype_16BSI);
+       PG_ADD_TEST(suite, test_band_pixtype_32BUI);
+       PG_ADD_TEST(suite, test_band_pixtype_32BSI);
+       PG_ADD_TEST(suite, test_band_pixtype_32BF);
+       PG_ADD_TEST(suite, test_band_pixtype_64BF);
+       PG_ADD_TEST(suite, test_band_get_pixel_line);
+}
+
index a599db388d8f0c4e6e01c0158009f9717378f676..6eee0dcb22f29c8ba6461662b50a00d99a9178af 100644 (file)
@@ -579,10 +579,12 @@ static void test_pixel_set_to_array(){
 }
 
 /* register tests */
-CU_TestInfo band_misc_tests[] = {
-       PG_TEST(test_band_get_nearest_pixel),
-       PG_TEST(test_band_get_pixel_of_value),
-       PG_TEST(test_pixel_set_to_array),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo band_misc_suite = {"band_misc",  NULL,  NULL, band_misc_tests};
+void band_misc_suite_setup(void);
+void band_misc_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("band_misc", NULL, NULL);
+       PG_ADD_TEST(suite, test_band_get_nearest_pixel);
+       PG_ADD_TEST(suite, test_band_get_pixel_of_value);
+       PG_ADD_TEST(suite, test_pixel_set_to_array);
+}
+
index cd8ef8395be36b3fd209fc0987ac3a42d48190d1..cf15349870905cb8f0b6b789e50ab4766963630b 100644 (file)
@@ -267,9 +267,11 @@ static void test_band_value_count() {
 }
 
 /* register tests */
-CU_TestInfo band_stats_tests[] = {
-       PG_TEST(test_band_stats),
-       PG_TEST(test_band_value_count),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo band_stats_suite = {"band_stats",  NULL,  NULL, band_stats_tests};
+void band_stats_suite_setup(void);
+void band_stats_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("band_stats", NULL, NULL);
+       PG_ADD_TEST(suite, test_band_stats);
+       PG_ADD_TEST(suite, test_band_value_count);
+}
+
index 657c71aa2dada99cfc0cd0ba4790aa2aaff7706c..d6554cfbcd2997529106cc4c7cf659f3afff6b70 100644 (file)
@@ -644,14 +644,16 @@ static void test_gdal_warp() {
 }
 
 /* register tests */
-CU_TestInfo gdal_tests[] = {
-       PG_TEST(test_gdal_configured),
-       PG_TEST(test_gdal_drivers),
-       PG_TEST(test_gdal_rasterize),
-       PG_TEST(test_gdal_polygonize),
-       PG_TEST(test_raster_to_gdal),
-       PG_TEST(test_gdal_to_raster),
-       PG_TEST(test_gdal_warp),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo gdal_suite = {"gdal",  NULL,  NULL, gdal_tests};
+void gdal_suite_setup(void);
+void gdal_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("gdal", NULL, NULL);
+       PG_ADD_TEST(suite, test_gdal_configured);
+       PG_ADD_TEST(suite, test_gdal_drivers);
+       PG_ADD_TEST(suite, test_gdal_rasterize);
+       PG_ADD_TEST(suite, test_gdal_polygonize);
+       PG_ADD_TEST(suite, test_raster_to_gdal);
+       PG_ADD_TEST(suite, test_gdal_to_raster);
+       PG_ADD_TEST(suite, test_gdal_warp);
+}
+
index 77ec8243f5b5ad906768ff694c5de49aaa49d3ce..e87b6c20dbae482a342266ec701f9698e710af56 100644 (file)
@@ -1184,10 +1184,12 @@ static void test_raster_colormap() {
 }
 
 /* register tests */
-CU_TestInfo mapalgebra_tests[] = {
-       PG_TEST(test_raster_iterator),
-       PG_TEST(test_band_reclass),
-       PG_TEST(test_raster_colormap),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo mapalgebra_suite = {"mapalgebra",  NULL,  NULL, mapalgebra_tests};
+void mapalgebra_suite_setup(void);
+void mapalgebra_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("mapalgebra", NULL, NULL);
+       PG_ADD_TEST(suite, test_raster_iterator);
+       PG_ADD_TEST(suite, test_band_reclass);
+       PG_ADD_TEST(suite, test_raster_colormap);
+}
+
index 8993f5ef043005253e3cdf31ff16fe7bfd0f5dc1..55790729decc54907cbb273f78222df39a8052ea 100644 (file)
@@ -143,10 +143,12 @@ static void test_util_gdal_open() {
 }
 
 /* register tests */
-CU_TestInfo misc_tests[] = {
-       PG_TEST(test_rgb_to_hsv),
-       PG_TEST(test_hsv_to_rgb),
-       PG_TEST(test_util_gdal_open),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo misc_suite = {"misc",  NULL,  NULL, misc_tests};
+void misc_suite_setup(void);
+void misc_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("misc", NULL, NULL);
+       PG_ADD_TEST(suite, test_rgb_to_hsv);
+       PG_ADD_TEST(suite, test_hsv_to_rgb);
+       PG_ADD_TEST(suite, test_util_gdal_open);
+}
+
index d7d11b613bc4a3c1042c416170c1b3887a603cc1..45333a35e18f6f902d917ccb9c462838cf411c4f 100644 (file)
@@ -228,13 +228,15 @@ static void test_pixtype_compare_clamped_values() {
 }
 
 /* register tests */
-CU_TestInfo pixtype_tests[] = {
-       PG_TEST(test_pixtype_size),
-       PG_TEST(test_pixtype_alignment),
-       PG_TEST(test_pixtype_name),
-       PG_TEST(test_pixtype_index_from_name),
-       PG_TEST(test_pixtype_get_min_value),
-       PG_TEST(test_pixtype_compare_clamped_values),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo pixtype_suite = {"pixtype",  NULL,  NULL, pixtype_tests};
+void pixtype_suite_setup(void);
+void pixtype_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("pixtype", NULL, NULL);
+       PG_ADD_TEST(suite, test_pixtype_size);
+       PG_ADD_TEST(suite, test_pixtype_alignment);
+       PG_ADD_TEST(suite, test_pixtype_name);
+       PG_ADD_TEST(suite, test_pixtype_index_from_name);
+       PG_ADD_TEST(suite, test_pixtype_get_min_value);
+       PG_ADD_TEST(suite, test_pixtype_compare_clamped_values);
+}
+
index 4a600c81dce07ae4ffc30070a0cfd96630223c9c..98d640a1a31fae9bada34c88d19e5b553b65a3b1 100644 (file)
@@ -205,13 +205,15 @@ static void test_raster_replace_band() {
 }
 
 /* register tests */
-CU_TestInfo raster_basics_tests[] = {
-       PG_TEST(test_raster_new),
-       PG_TEST(test_raster_empty),
-       PG_TEST(test_raster_metadata),
-       PG_TEST(test_raster_clone),
-       PG_TEST(test_raster_from_band),
-       PG_TEST(test_raster_replace_band),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo raster_basics_suite = {"raster_basics",  NULL,  NULL, raster_basics_tests};
+void raster_basics_suite_setup(void);
+void raster_basics_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("raster_basics", NULL, NULL);
+       PG_ADD_TEST(suite, test_raster_new);
+       PG_ADD_TEST(suite, test_raster_empty);
+       PG_ADD_TEST(suite, test_raster_metadata);
+       PG_ADD_TEST(suite, test_raster_clone);
+       PG_ADD_TEST(suite, test_raster_from_band);
+       PG_ADD_TEST(suite, test_raster_replace_band);
+}
+
index 7ab31ae5b971d46711ba579afbe647ccc867da11..d1309f3611dd374a76b83e49027daacd49e58e27 100644 (file)
@@ -572,13 +572,15 @@ static void test_raster_pixel_as_polygon() {
 }
 
 /* register tests */
-CU_TestInfo raster_geometry_tests[] = {
-       PG_TEST(test_raster_envelope),
-       PG_TEST(test_raster_envelope_geom),
-       PG_TEST(test_raster_convex_hull),
-       PG_TEST(test_raster_surface),
-       PG_TEST(test_raster_perimeter),
-       PG_TEST(test_raster_pixel_as_polygon),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo raster_geometry_suite = {"raster_geometry",  NULL,  NULL, raster_geometry_tests};
+void raster_geometry_suite_setup(void);
+void raster_geometry_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("raster_geometry", NULL, NULL);
+       PG_ADD_TEST(suite, test_raster_envelope);
+       PG_ADD_TEST(suite, test_raster_envelope_geom);
+       PG_ADD_TEST(suite, test_raster_convex_hull);
+       PG_ADD_TEST(suite, test_raster_surface);
+       PG_ADD_TEST(suite, test_raster_perimeter);
+       PG_ADD_TEST(suite, test_raster_pixel_as_polygon);
+}
+
index 458ecb5b462429e96a37b6286f262bdebe54d617..705c3e441c6210b3f26d425b3bb71ad79ba9e880 100644 (file)
@@ -205,11 +205,13 @@ static void test_raster_compute_skewed_raster() {
 }
 
 /* register tests */
-CU_TestInfo raster_misc_tests[] = {
-       PG_TEST(test_raster_cell_to_geopoint),
-       PG_TEST(test_raster_geopoint_to_cell),
-       PG_TEST(test_raster_from_two_rasters),
-       PG_TEST(test_raster_compute_skewed_raster),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo raster_misc_suite = {"raster_misc",  NULL,  NULL, raster_misc_tests};
+void raster_misc_suite_setup(void);
+void raster_misc_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("raster_misc", NULL, NULL);
+       PG_ADD_TEST(suite, test_raster_cell_to_geopoint);
+       PG_ADD_TEST(suite, test_raster_geopoint_to_cell);
+       PG_ADD_TEST(suite, test_raster_from_two_rasters);
+       PG_ADD_TEST(suite, test_raster_compute_skewed_raster);
+}
+
index 72bf9e7246f74eb3893e945e8987ffff19632195..0533632ca4781d8fb000a83d9a59cb6b6f69146e 100644 (file)
@@ -809,8 +809,10 @@ static void test_raster_wkb() {
 }
 
 /* register tests */
-CU_TestInfo raster_wkb_tests[] = {
-       PG_TEST(test_raster_wkb),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo raster_wkb_suite = {"raster_wkb",  NULL,  NULL, raster_wkb_tests};
+void raster_wkb_suite_setup(void);
+void raster_wkb_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("raster_wkb", NULL, NULL);
+       PG_ADD_TEST(suite, test_raster_wkb);
+}
+
index 342f7228720fe0846c39355781e9a6e0092f15d1..f99e78b012488e1db2eb0c5860b668d3e1ef8cb0 100644 (file)
@@ -4779,17 +4779,19 @@ static void test_raster_same_alignment() {
 }
 
 /* register tests */
-CU_TestInfo spatial_relationship_tests[] = {
-       PG_TEST(test_raster_geos_overlaps),
-       PG_TEST(test_raster_geos_touches),
-       PG_TEST(test_raster_geos_contains),
-       PG_TEST(test_raster_geos_contains_properly),
-       PG_TEST(test_raster_geos_covers),
-       PG_TEST(test_raster_geos_covered_by),
-       PG_TEST(test_raster_within_distance),
-       PG_TEST(test_raster_fully_within_distance),
-       PG_TEST(test_raster_intersects),
-       PG_TEST(test_raster_same_alignment),
-       CU_TEST_INFO_NULL
-};
-CU_SuiteInfo spatial_relationship_suite = {"spatial_relationship",  NULL,  NULL, spatial_relationship_tests};
+void spatial_relationship_suite_setup(void);
+void spatial_relationship_suite_setup(void)
+{
+       CU_pSuite suite = CU_add_suite("spatial_relationship", NULL, NULL);
+       PG_ADD_TEST(suite, test_raster_geos_overlaps);
+       PG_ADD_TEST(suite, test_raster_geos_touches);
+       PG_ADD_TEST(suite, test_raster_geos_contains);
+       PG_ADD_TEST(suite, test_raster_geos_contains_properly);
+       PG_ADD_TEST(suite, test_raster_geos_covers);
+       PG_ADD_TEST(suite, test_raster_geos_covered_by);
+       PG_ADD_TEST(suite, test_raster_within_distance);
+       PG_ADD_TEST(suite, test_raster_fully_within_distance);
+       PG_ADD_TEST(suite, test_raster_intersects);
+       PG_ADD_TEST(suite, test_raster_same_alignment);
+}
+
index c57d9a998e7b14fc69bd686343cd8e8c5bbd1e1d..eb67af02b165f8ae2e8a51921f60bd54cd994d19 100644 (file)
 static void 
 cu_error_reporter(const char *fmt, va_list ap);
 
-/* ADD YOUR SUITE HERE (1 of 2) */
-extern CU_SuiteInfo pixtype_suite;
-extern CU_SuiteInfo raster_basics_suite;
-extern CU_SuiteInfo band_basics_suite;
-extern CU_SuiteInfo raster_wkb_suite;
-extern CU_SuiteInfo gdal_suite;
-extern CU_SuiteInfo raster_geometry_suite;
-extern CU_SuiteInfo raster_misc_suite;
-extern CU_SuiteInfo band_stats_suite;
-extern CU_SuiteInfo band_misc_suite;
-extern CU_SuiteInfo mapalgebra_suite;
-extern CU_SuiteInfo spatial_relationship_suite;
-extern CU_SuiteInfo misc_suite;
+/* ADD YOUR SUITE SETUP FUNCTION HERE (1 of 2) */
+extern void pixtype_suite_setup(void);
+extern void raster_basics_suite_setup(void);
+extern void band_basics_suite_setup(void);
+extern void raster_wkb_suite_setup(void);
+extern void gdal_suite_setup(void);
+extern void raster_geometry_suite_setup(void);
+extern void raster_misc_suite_setup(void);
+extern void band_stats_suite_setup(void);
+extern void band_misc_suite_setup(void);
+extern void mapalgebra_suite_setup(void);
+extern void spatial_relationship_suite_setup(void);
+extern void misc_suite_setup(void);
+
+/* AND ADD YOUR SUITE SETUP FUNCTION HERE (2 of 2) */
+PG_SuiteSetup setupfuncs[] =
+{
+       pixtype_suite_setup,
+       raster_basics_suite_setup,
+       band_basics_suite_setup,
+       raster_wkb_suite_setup,
+       gdal_suite_setup,
+       raster_geometry_suite_setup,
+       raster_misc_suite_setup,
+       band_stats_suite_setup,
+       band_misc_suite_setup,
+       mapalgebra_suite_setup,
+       spatial_relationship_suite_setup,
+       misc_suite_setup,
+       NULL
+};
+
 
 /*
 ** The main() function for setting up and running the tests.
@@ -40,24 +59,6 @@ extern CU_SuiteInfo misc_suite;
 */
 int main(int argc, char *argv[])
 {
-       /* ADD YOUR SUITE HERE (2 of 2) */
-       CU_SuiteInfo suites[] =
-       {
-               pixtype_suite,
-               raster_basics_suite,
-               band_basics_suite,
-               raster_wkb_suite,
-               gdal_suite,
-               raster_geometry_suite,
-               raster_misc_suite,
-               band_stats_suite,
-               band_misc_suite,
-               spatial_relationship_suite,
-               mapalgebra_suite,
-               misc_suite,
-               CU_SUITE_INFO_NULL
-       };
-
        int index;
        char *suite_name;
        CU_pSuite suite_to_run;
@@ -67,6 +68,7 @@ int main(int argc, char *argv[])
        CU_pTestRegistry registry;
        int num_run;
        int num_failed;
+       PG_SuiteSetup *setupfunc = setupfuncs;
 
        /* install the custom error handler */
        lwgeom_set_handlers(0, 0, 0, cu_error_reporter, 0);
@@ -80,11 +82,10 @@ int main(int argc, char *argv[])
        }
 
        /* Register all the test suites. */
-       if (CUE_SUCCESS != CU_register_suites(suites))
+       while ( *setupfunc )
        {
-               errCode = CU_get_error();
-               printf("    Error attempting to register test suites: %d.  See CUError.h for error code list.\n", errCode);
-               return errCode;
+               (*setupfunc)();
+               setupfunc++;
        }
 
        /* Run all tests using the CUnit Basic interface */
index fdd44bc1c09ecadfe57df2d9087bb865cf5a8e4d..7c8f9bbce747f6f101f84bbaf970a91f2b5dd705 100644 (file)
 #include "../../../postgis_config.h"
 #include "../../raster_config.h"
 
-#define PG_TEST(test_func) { #test_func, test_func }
 #define MAX_CUNIT_MSG_LENGTH 512
 
+#define PG_ADD_TEST(suite, testfunc) CU_add_test(suite, #testfunc, testfunc)
+
 /* Contains the most recent error message generated by rterror. */
 char cu_error_msg[MAX_CUNIT_MSG_LENGTH+1];
 
@@ -32,3 +33,6 @@ rt_band cu_add_band(
        rt_pixtype pixtype,
        int hasnodata, double nodataval
 );
+
+/* Our internal callback to register Suites with the main tester */
+typedef void (*PG_SuiteSetup)(void);