[postgis-tickets] r17411 - Fix several issues when building cunit tests

Raul raul at rmr.ninja
Wed Apr 24 03:59:37 PDT 2019


Author: algunenano
Date: 2019-04-24 03:59:37 -0700 (Wed, 24 Apr 2019)
New Revision: 17411

Modified:
   trunk/liblwgeom/cunit/cu_in_twkb.c
   trunk/liblwgeom/cunit/cu_in_wkb.c
   trunk/liblwgeom/cunit/cu_out_twkb.c
   trunk/liblwgeom/cunit/cu_out_wkb.c
   trunk/liblwgeom/cunit/cu_out_wkt.c
   trunk/liblwgeom/cunit/cu_tester.c
   trunk/liblwgeom/cunit/cu_tester.h
   trunk/loader/cunit/Makefile.in
Log:
Fix several issues when building cunit tests

- loader cunit: Add missing $(CFLAGS) to the main binary
- liblwgeom cunit: Avoid link issues with some sanitizers

References #4383



Modified: trunk/liblwgeom/cunit/cu_in_twkb.c
===================================================================
--- trunk/liblwgeom/cunit/cu_in_twkb.c	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/liblwgeom/cunit/cu_in_twkb.c	2019-04-24 10:59:37 UTC (rev 17411)
@@ -20,10 +20,10 @@
 /*
 ** Global variable to hold TWKB strings
 */
-char *hex_a;
-char *hex_b;
-uint8_t precision = 0;
-uint8_t variant = 0;
+static char *hex_a;
+static char *hex_b;
+static uint8_t precision = 0;
+static uint8_t variant = 0;
 
 /*
 ** The suite initialization function.

Modified: trunk/liblwgeom/cunit/cu_in_wkb.c
===================================================================
--- trunk/liblwgeom/cunit/cu_in_wkb.c	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/liblwgeom/cunit/cu_in_wkb.c	2019-04-24 10:59:37 UTC (rev 17411)
@@ -20,8 +20,8 @@
 /*
 ** Global variable to hold WKB strings
 */
-char *hex_a;
-char *hex_b;
+static char *hex_a;
+static char *hex_b;
 
 /*
 ** The suite initialization function.

Modified: trunk/liblwgeom/cunit/cu_out_twkb.c
===================================================================
--- trunk/liblwgeom/cunit/cu_out_twkb.c	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/liblwgeom/cunit/cu_out_twkb.c	2019-04-24 10:59:37 UTC (rev 17411)
@@ -21,8 +21,8 @@
 /*
 ** Global variable to hold hex TWKB strings
 */
-char *s;
-char *w;
+static char *s;
+static char *w;
 
 /*
 ** The suite initialization function.

Modified: trunk/liblwgeom/cunit/cu_out_wkb.c
===================================================================
--- trunk/liblwgeom/cunit/cu_out_wkb.c	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/liblwgeom/cunit/cu_out_wkb.c	2019-04-24 10:59:37 UTC (rev 17411)
@@ -20,8 +20,8 @@
 /*
 ** Global variable to hold hex WKB strings
 */
-char *s;
-size_t s_size;
+static char *s;
+static size_t s_size;
 
 /*
 ** The suite initialization function.

Modified: trunk/liblwgeom/cunit/cu_out_wkt.c
===================================================================
--- trunk/liblwgeom/cunit/cu_out_wkt.c	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/liblwgeom/cunit/cu_out_wkt.c	2019-04-24 10:59:37 UTC (rev 17411)
@@ -20,7 +20,7 @@
 /*
 ** Global variable to hold WKT strings
 */
-char *s = NULL;
+static char *s = NULL;
 
 /*
 ** The suite initialization function.

Modified: trunk/liblwgeom/cunit/cu_tester.c
===================================================================
--- trunk/liblwgeom/cunit/cu_tester.c	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/liblwgeom/cunit/cu_tester.c	2019-04-24 10:59:37 UTC (rev 17411)
@@ -16,6 +16,8 @@
 #include "cu_tester.h"
 #include "../postgis_config.h"
 
+char cu_error_msg[MAX_CUNIT_ERROR_LENGTH + 1] = {0};
+
 /* Internal funcs */
 static void
 cu_errorreporter(const char *fmt, va_list ap);

Modified: trunk/liblwgeom/cunit/cu_tester.h
===================================================================
--- trunk/liblwgeom/cunit/cu_tester.h	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/liblwgeom/cunit/cu_tester.h	2019-04-24 10:59:37 UTC (rev 17411)
@@ -10,6 +10,9 @@
  *
  **********************************************************************/
 
+#ifndef _CU_TESTER_H
+#define _CU_TESTER_H 1
+
 #include "liblwgeom.h"
 
 #define MAX_CUNIT_ERROR_LENGTH 512
@@ -17,7 +20,7 @@
 #define PG_ADD_TEST(suite, testfunc) CU_add_test(suite, #testfunc, testfunc)
 
 /* Contains the most recent error message generated by lwerror. */
-char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1];
+extern char cu_error_msg[];
 
 /* Resets cu_error_msg back to blank. */
 void cu_error_msg_reset(void);
@@ -87,3 +90,5 @@
 
 /* Utility functions */
 void do_fn_test(LWGEOM* (*transfn)(LWGEOM*), char *input_wkt, char *expected_wkt);
+
+#endif /* _CU_TESTER_H */

Modified: trunk/loader/cunit/Makefile.in
===================================================================
--- trunk/loader/cunit/Makefile.in	2019-04-24 10:44:27 UTC (rev 17410)
+++ trunk/loader/cunit/Makefile.in	2019-04-24 10:59:37 UTC (rev 17411)
@@ -84,7 +84,7 @@
 # Build the main unit test executable
 cu_tester: $(LOADER_OBJS) $(OBJS)
 	$(LIBTOOL) --mode=link \
-	$(CC)  $^ -o $@ $(LIBLWGEOM) $(LDFLAGS)
+	$(CC) $(CFLAGS) $^ -o $@ $(LIBLWGEOM) $(LDFLAGS)
 
 # Command to build each of the .o files
 $(OBJS): %.o: %.c



More information about the postgis-tickets mailing list