Skip to content

Commit da34731

Browse files
committed
Install kludges to fix check-world for src/test/modules
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.
1 parent 475aedd commit da34731

File tree

9 files changed

+35
-4
lines changed

9 files changed

+35
-4
lines changed

src/test/modules/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ SUBDIRS = \
1010
test_shm_mq \
1111
test_parser
1212

13+
all: submake-errcodes
14+
15+
submake-errcodes:
16+
$(MAKE) -C $(top_builddir)/src/backend submake-errcodes
17+
1318
$(recurse)

src/test/modules/dummy_seclabel/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
MODULES = dummy_seclabel
44
PGFILEDESC = "dummy_seclabel - regression testing of the SECURITY LABEL statement"
55

6+
EXTENSION = dummy_seclabel
7+
DATA = dummy_seclabel--1.0.sql
8+
69
REGRESS = dummy_seclabel
710
EXTRA_CLEAN = sql/dummy_seclabel.sql expected/dummy_seclabel.out
811

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* src/test/modules/dummy_seclabel/dummy_seclabel--1.0.sql */
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION dummy_seclabel" to load this file. \quit
5+
6+
CREATE FUNCTION dummy_seclabel_dummy()
7+
RETURNS pg_catalog.void
8+
AS 'MODULE_PATHNAME' LANGUAGE C;
9+

src/test/modules/dummy_seclabel/dummy_seclabel.c

+12
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ PG_MODULE_MAGIC;
2121
/* Entrypoint of the module */
2222
void _PG_init(void);
2323

24+
PG_FUNCTION_INFO_V1(dummy_seclabel_dummy);
25+
2426
static void
2527
dummy_object_relabel(const ObjectAddress *object, const char *seclabel)
2628
{
@@ -48,3 +50,13 @@ _PG_init(void)
4850
{
4951
register_label_provider("dummy", dummy_object_relabel);
5052
}
53+
54+
/*
55+
* This function is here just so that the extension is not completely empty
56+
* and the dynamic library is loaded when CREATE EXTENSION runs.
57+
*/
58+
Datum
59+
dummy_seclabel_dummy(PG_FUNCTION_ARGS)
60+
{
61+
PG_RETURN_VOID();
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
comment = 'Test code for SECURITY LABEL feature'
2+
default_version = '1.0'
3+
module_pathname = '$libdir/dummy_seclabel'
4+
relocatable = true

src/test/modules/dummy_seclabel/expected/.gitignore

-1
This file was deleted.

src/test/modules/dummy_seclabel/output/dummy_seclabel.source renamed to src/test/modules/dummy_seclabel/expected/dummy_seclabel.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--
22
-- Test for facilities of security label
33
--
4-
LOAD '@libdir@/dummy_seclabel@DLSUFFIX@';
4+
CREATE EXTENSION dummy_seclabel;
55
-- initial setups
66
SET client_min_messages TO 'warning';
77
DROP ROLE IF EXISTS dummy_seclabel_user1;

src/test/modules/dummy_seclabel/sql/.gitignore

-1
This file was deleted.

src/test/modules/dummy_seclabel/input/dummy_seclabel.source renamed to src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--
22
-- Test for facilities of security label
33
--
4-
LOAD '@libdir@/dummy_seclabel@DLSUFFIX@';
4+
CREATE EXTENSION dummy_seclabel;
55

66
-- initial setups
77
SET client_min_messages TO 'warning';

0 commit comments

Comments
 (0)