From ea405a25f8ed435f6dc176705a32a720b6ff26c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ra=C3=BAl=20Mar=C3=ADn=20Rodr=C3=ADguez?= Date: Wed, 24 Apr 2019 10:59:37 +0000 Subject: [PATCH] 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 git-svn-id: http://svn.osgeo.org/postgis/trunk@17411 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/cunit/cu_in_twkb.c | 8 ++++---- liblwgeom/cunit/cu_in_wkb.c | 4 ++-- liblwgeom/cunit/cu_out_twkb.c | 4 ++-- liblwgeom/cunit/cu_out_wkb.c | 4 ++-- liblwgeom/cunit/cu_out_wkt.c | 2 +- liblwgeom/cunit/cu_tester.c | 2 ++ liblwgeom/cunit/cu_tester.h | 7 ++++++- loader/cunit/Makefile.in | 2 +- 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/liblwgeom/cunit/cu_in_twkb.c b/liblwgeom/cunit/cu_in_twkb.c index 9313f13ad..43542b217 100644 --- a/liblwgeom/cunit/cu_in_twkb.c +++ b/liblwgeom/cunit/cu_in_twkb.c @@ -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. diff --git a/liblwgeom/cunit/cu_in_wkb.c b/liblwgeom/cunit/cu_in_wkb.c index 8e051f7e6..bcd5e2891 100644 --- a/liblwgeom/cunit/cu_in_wkb.c +++ b/liblwgeom/cunit/cu_in_wkb.c @@ -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. diff --git a/liblwgeom/cunit/cu_out_twkb.c b/liblwgeom/cunit/cu_out_twkb.c index 27f51e9d1..3609416db 100644 --- a/liblwgeom/cunit/cu_out_twkb.c +++ b/liblwgeom/cunit/cu_out_twkb.c @@ -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. diff --git a/liblwgeom/cunit/cu_out_wkb.c b/liblwgeom/cunit/cu_out_wkb.c index d60db1b65..7b23fe634 100644 --- a/liblwgeom/cunit/cu_out_wkb.c +++ b/liblwgeom/cunit/cu_out_wkb.c @@ -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. diff --git a/liblwgeom/cunit/cu_out_wkt.c b/liblwgeom/cunit/cu_out_wkt.c index c070efbd5..199ca62b0 100644 --- a/liblwgeom/cunit/cu_out_wkt.c +++ b/liblwgeom/cunit/cu_out_wkt.c @@ -20,7 +20,7 @@ /* ** Global variable to hold WKT strings */ -char *s = NULL; +static char *s = NULL; /* ** The suite initialization function. diff --git a/liblwgeom/cunit/cu_tester.c b/liblwgeom/cunit/cu_tester.c index 88ab73981..3637226d5 100644 --- a/liblwgeom/cunit/cu_tester.c +++ b/liblwgeom/cunit/cu_tester.c @@ -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); diff --git a/liblwgeom/cunit/cu_tester.h b/liblwgeom/cunit/cu_tester.h index c5e6ccfac..862bc09e3 100644 --- a/liblwgeom/cunit/cu_tester.h +++ b/liblwgeom/cunit/cu_tester.h @@ -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 @@ typedef void (*PG_SuiteSetup)(void); /* Utility functions */ void do_fn_test(LWGEOM* (*transfn)(LWGEOM*), char *input_wkt, char *expected_wkt); + +#endif /* _CU_TESTER_H */ diff --git a/loader/cunit/Makefile.in b/loader/cunit/Makefile.in index 253a1c05c..345bfe8e7 100644 --- a/loader/cunit/Makefile.in +++ b/loader/cunit/Makefile.in @@ -84,7 +84,7 @@ endif # 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 -- 2.40.0