]> granicus.if.org Git - postgresql/commitdiff
Install kludges to fix check-world for src/test/modules
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 3 Dec 2014 02:43:53 +0000 (23:43 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 3 Dec 2014 02:43:53 +0000 (23:43 -0300)
check-world failed in a completely clean tree, because src/test/modules
fail to build unless errcodes.h is generated first.  To fix this,
install a dependency in src/test/modules' Makefile so that the necessary
file is generated.  Even with this, running "make check" within
individual module subdirs will still fail because the dependency is not
considered there, but this case is less interesting and would be messier
to fix.

check-world still failed with the above fix in place, this time because
dummy_seclabel used LOAD to load the dynamic library, which doesn't work
because the @libdir@ (expanded by the makefile) is expanded to the final
install path, not the temporary installation directory used by make
check.  To fix, tweak things so that CREATE EXTENSION can be used
instead, which solves the problem because the library path is expanded
by the backend, which is aware of the true libdir.

src/test/modules/Makefile
src/test/modules/dummy_seclabel/Makefile
src/test/modules/dummy_seclabel/dummy_seclabel--1.0.sql [new file with mode: 0644]
src/test/modules/dummy_seclabel/dummy_seclabel.c
src/test/modules/dummy_seclabel/dummy_seclabel.control [new file with mode: 0644]
src/test/modules/dummy_seclabel/expected/.gitignore [deleted file]
src/test/modules/dummy_seclabel/expected/dummy_seclabel.out [moved from src/test/modules/dummy_seclabel/output/dummy_seclabel.source with 99% similarity]
src/test/modules/dummy_seclabel/sql/.gitignore [deleted file]
src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql [moved from src/test/modules/dummy_seclabel/input/dummy_seclabel.source with 98% similarity]

index 9d5aa97b4bad04466aacb986c30075f96f0d1cf3..4cb6af01f8fdc31ebdf6e92ddb22550bd2bbc371 100644 (file)
@@ -10,4 +10,9 @@ SUBDIRS = \
                  test_shm_mq \
                  test_parser
 
+all: submake-errcodes
+
+submake-errcodes:
+       $(MAKE) -C $(top_builddir)/src/backend submake-errcodes
+
 $(recurse)
index bddfa150dd513e41cdcd24cef800032217f05086..72049d43ba3752a4186da86aa3cf88ce776e94b5 100644 (file)
@@ -3,6 +3,9 @@
 MODULES = dummy_seclabel
 PGFILEDESC = "dummy_seclabel - regression testing of the SECURITY LABEL statement"
 
+EXTENSION = dummy_seclabel
+DATA = dummy_seclabel--1.0.sql
+
 REGRESS = dummy_seclabel
 EXTRA_CLEAN = sql/dummy_seclabel.sql expected/dummy_seclabel.out
 
diff --git a/src/test/modules/dummy_seclabel/dummy_seclabel--1.0.sql b/src/test/modules/dummy_seclabel/dummy_seclabel--1.0.sql
new file mode 100644 (file)
index 0000000..468a05d
--- /dev/null
@@ -0,0 +1,9 @@
+/* src/test/modules/dummy_seclabel/dummy_seclabel--1.0.sql */
+
+-- complain if script is sourced in psql, rather than via CREATE EXTENSION
+\echo Use "CREATE EXTENSION dummy_seclabel" to load this file. \quit
+
+CREATE FUNCTION dummy_seclabel_dummy()
+   RETURNS pg_catalog.void
+       AS 'MODULE_PATHNAME' LANGUAGE C;
+
index b5753cc908419d8d4b8156a91814b527ae112d7a..dae51da43bb8dc7c90341a819149c89fe88ce229 100644 (file)
@@ -21,6 +21,8 @@ PG_MODULE_MAGIC;
 /* Entrypoint of the module */
 void           _PG_init(void);
 
+PG_FUNCTION_INFO_V1(dummy_seclabel_dummy);
+
 static void
 dummy_object_relabel(const ObjectAddress *object, const char *seclabel)
 {
@@ -48,3 +50,13 @@ _PG_init(void)
 {
        register_label_provider("dummy", dummy_object_relabel);
 }
+
+/*
+ * This function is here just so that the extension is not completely empty
+ * and the dynamic library is loaded when CREATE EXTENSION runs.
+ */
+Datum
+dummy_seclabel_dummy(PG_FUNCTION_ARGS)
+{
+       PG_RETURN_VOID();
+}
diff --git a/src/test/modules/dummy_seclabel/dummy_seclabel.control b/src/test/modules/dummy_seclabel/dummy_seclabel.control
new file mode 100644 (file)
index 0000000..8c37272
--- /dev/null
@@ -0,0 +1,4 @@
+comment = 'Test code for SECURITY LABEL feature'
+default_version = '1.0'
+module_pathname = '$libdir/dummy_seclabel'
+relocatable = true
diff --git a/src/test/modules/dummy_seclabel/expected/.gitignore b/src/test/modules/dummy_seclabel/expected/.gitignore
deleted file mode 100644 (file)
index 2dd2462..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/dummy_seclabel.out
similarity index 99%
rename from src/test/modules/dummy_seclabel/output/dummy_seclabel.source
rename to src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
index 8275764cb9c194994ce5f18a6ad428492caf597f..a16558e8fd16f00e899807c044b5027d0673020a 100644 (file)
@@ -1,7 +1,7 @@
 --
 -- Test for facilities of security label
 --
-LOAD '@libdir@/dummy_seclabel@DLSUFFIX@';
+CREATE EXTENSION dummy_seclabel;
 -- initial setups
 SET client_min_messages TO 'warning';
 DROP ROLE IF EXISTS dummy_seclabel_user1;
diff --git a/src/test/modules/dummy_seclabel/sql/.gitignore b/src/test/modules/dummy_seclabel/sql/.gitignore
deleted file mode 100644 (file)
index ec54e63..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/dummy_seclabel.sql
similarity index 98%
rename from src/test/modules/dummy_seclabel/input/dummy_seclabel.source
rename to src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
index d39ce88aee93a2f64071df5288077aaef8169a13..49777aae38ba5c185fdeefdc5d7a59c897f6542e 100644 (file)
@@ -1,7 +1,7 @@
 --
 -- Test for facilities of security label
 --
-LOAD '@libdir@/dummy_seclabel@DLSUFFIX@';
+CREATE EXTENSION dummy_seclabel;
 
 -- initial setups
 SET client_min_messages TO 'warning';