Remove the option to build thread_test.c outside configure.
authorTom Lane <[email protected]>
Wed, 21 Oct 2020 16:08:48 +0000 (12:08 -0400)
committerTom Lane <[email protected]>
Wed, 21 Oct 2020 16:08:48 +0000 (12:08 -0400)
Theoretically one could go into src/test/thread and build/run this
program there.  In practice, that hasn't worked since 96bf88d52,
and probably much longer on some platforms (likely including just
the sort of hoary leftovers where this test might be of interest).
While it wouldn't be too hard to repair the breakage, the fact that
nobody has noticed for two years shows that there is zero usefulness
in maintaining this build pathway.  Let's get rid of it and decree
that thread_test.c is *only* meant to be built/used in configure.

Given that decision, it makes sense to put thread_test.c under config/
and get rid of src/test/thread altogether, so that's what I did.

In passing, update src/test/README, which had been ignored by some
not-so-recent additions of subdirectories.

Discussion: https://postgr.es/m/227659.1603041612@sss.pgh.pa.us

config/thread_test.c [moved from src/test/thread/thread_test.c with 93% similarity]
configure
configure.ac
src/Makefile
src/port/thread.c
src/test/Makefile
src/test/README
src/test/thread/.gitignore [deleted file]
src/test/thread/Makefile [deleted file]
src/test/thread/README [deleted file]

similarity index 93%
rename from src/test/thread/thread_test.c
rename to config/thread_test.c
index 09603c95dd683d45774b4c4e2c3ffb0c9e72a442..ff2eace87d841e9af328e82347c7929f7a92b5fd 100644 (file)
@@ -1,12 +1,12 @@
 /*-------------------------------------------------------------------------
  *
  * thread_test.c
- *     libc thread test program
+ *     libc threading test program
  *
  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * src/test/thread/thread_test.c
+ * config/thread_test.c
  *
  * This program tests to see if your standard libc functions use
  * pthread_setspecific()/pthread_getspecific() to be thread-safe.
  *-------------------------------------------------------------------------
  */
 
-#if !defined(IN_CONFIGURE) && !defined(WIN32)
-#include "postgres.h"
-
-/* we want to know what the native strerror does, not pg_strerror */
-#undef strerror
-#endif
+/* We cannot use c.h, as port.h will not exist yet */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -36,6 +31,7 @@
 #include <string.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <pthread.h>
 
 /* CYGWIN requires this for MAXHOSTNAMELEN */
 #ifdef __CYGWIN__
 #include <winsock2.h>
 #endif
 
-
 /* Test for POSIX.1c 2-arg sigwait() and fail on single-arg version */
 #include <signal.h>
 int            sigwait(const sigset_t *set, int *sig);
 
 
-#if !defined(ENABLE_THREAD_SAFETY) && !defined(IN_CONFIGURE) && !defined(WIN32)
-int
-main(int argc, char *argv[])
-{
-   fprintf(stderr, "This PostgreSQL build does not support threads.\n");
-   fprintf(stderr, "Perhaps rerun 'configure' using '--enable-thread-safety'.\n");
-   return 1;
-}
-#else
-
-/* This must be down here because this is the code that uses threads. */
-#include <pthread.h>
-
 #define        TEMP_FILENAME_1 "thread_test.1"
 #define        TEMP_FILENAME_2 "thread_test.2"
 
@@ -119,11 +101,9 @@ main(int argc, char *argv[])
        return 1;
    }
 
-#ifdef IN_CONFIGURE
    /* Send stdout to 'config.log' */
    close(1);
    dup(5);
-#endif
 
 #ifdef WIN32
    err = WSAStartup(MAKEWORD(2, 2), &wsaData);
@@ -455,5 +435,3 @@ func_call_2(void)
    pthread_mutex_lock(&init_mutex);    /* wait for parent to test */
    pthread_mutex_unlock(&init_mutex);
 }
-
-#endif                         /* !ENABLE_THREAD_SAFETY && !IN_CONFIGURE */
index 071d050ef009d6c51ea5a96aa4fb72390d0f2de6..ace4ed5decf10bb3ab57dbe129916e2de5901a7d 100755 (executable)
--- a/configure
+++ b/configure
@@ -18992,23 +18992,21 @@ $as_echo_n "checking thread safety of required library functions... " >&6; }
 
 _CFLAGS="$CFLAGS"
 _LIBS="$LIBS"
-CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
+CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 LIBS="$LIBS $PTHREAD_LIBS"
 if test "$cross_compiling" = yes; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: maybe" >&5
 $as_echo "maybe" >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
 *** Skipping thread test program because of cross-compile build.
-*** Run the program in src/test/thread on the target machine.
 " >&5
 $as_echo "$as_me: WARNING:
 *** Skipping thread test program because of cross-compile build.
-*** Run the program in src/test/thread on the target machine.
 " >&2;}
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include "$srcdir/src/test/thread/thread_test.c"
+#include "$srcdir/config/thread_test.c"
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -19017,9 +19015,8 @@ else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
   as_fn_error $? "thread test program failed
-This platform is not thread-safe.  Check the file 'config.log' or compile
-and run src/test/thread/thread_test for the exact reason.
-Use --disable-thread-safety to disable thread safety." "$LINENO" 5
+This platform is not thread-safe.  Check the file 'config.log' for the
+exact reason, or use --disable-thread-safety to disable thread safety." "$LINENO" 5
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
index e9ce611d23cb26ea1c12ec5d74eab53f4b0edb73..5b91c83fd07c2104e5660646e9f717ebaa6a8956 100644 (file)
@@ -2295,20 +2295,18 @@ AC_MSG_CHECKING([thread safety of required library functions])
 
 _CFLAGS="$CFLAGS"
 _LIBS="$LIBS"
-CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
+CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 LIBS="$LIBS $PTHREAD_LIBS"
 AC_RUN_IFELSE(
-  [AC_LANG_SOURCE([[#include "$srcdir/src/test/thread/thread_test.c"]])],
+  [AC_LANG_SOURCE([[#include "$srcdir/config/thread_test.c"]])],
   [AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)
   AC_MSG_ERROR([thread test program failed
-This platform is not thread-safe.  Check the file 'config.log' or compile
-and run src/test/thread/thread_test for the exact reason.
-Use --disable-thread-safety to disable thread safety.])],
+This platform is not thread-safe.  Check the file 'config.log' for the
+exact reason, or use --disable-thread-safety to disable thread safety.])],
   [AC_MSG_RESULT(maybe)
   AC_MSG_WARN([
 *** Skipping thread test program because of cross-compile build.
-*** Run the program in src/test/thread on the target machine.
 ])])
 CFLAGS="$_CFLAGS"
 LIBS="$_LIBS"
index bcdbd9588aa437ce3a41123e71be07154653645b..79e274a4769bebc2dc70ba9896a2da9a23ddf6ad 100644 (file)
@@ -66,13 +66,11 @@ clean:
    $(MAKE) -C test $@
    $(MAKE) -C tutorial NO_PGXS=1 $@
    $(MAKE) -C test/isolation $@
-   $(MAKE) -C test/thread $@
 
 distclean maintainer-clean:
    $(MAKE) -C test $@
    $(MAKE) -C tutorial NO_PGXS=1 $@
    $(MAKE) -C test/isolation $@
-   $(MAKE) -C test/thread $@
    rm -f Makefile.port Makefile.global
 
 
index 171df0f9e381d58b63a61990da03730dfd1d798f..0941cb6a88f4f27bdd468b98ff6aed0c19af6a0e 100644 (file)
@@ -47,9 +47,6 @@
  *     use non-*_r functions if they are thread-safe
  *
  * One thread-safe solution for gethostbyname() might be to use getaddrinfo().
- *
- * Run src/test/thread to test if your operating system has thread-safe
- * non-*_r functions.
  */
 
 
index efb206aa75014d83d28da68e21fd29a63891ca33..9774f534d93f87cb3ac53cf36e4d1f52e083ee61 100644 (file)
@@ -37,7 +37,7 @@ endif
 # clean" etc to recurse into them.  (We must filter out those that we
 # have conditionally included into SUBDIRS above, else there will be
 # make confusion.)
-ALWAYS_SUBDIRS = $(filter-out $(SUBDIRS),examples kerberos ldap locale thread ssl)
+ALWAYS_SUBDIRS = $(filter-out $(SUBDIRS),examples kerberos ldap locale ssl)
 
 # We want to recurse to all subdirs for all standard targets, except that
 # installcheck and install should not recurse into the subdirectory "modules".
index b5ccfc0cf6730883a6442f22c71e04da9cf3e80d..afdc7676519071a6fdb625ac4a7b279265ad711a 100644 (file)
@@ -9,7 +9,7 @@ Not all these tests get run by "make check". Check src/test/Makefile to see
 which tests get run automatically.
 
 authentication/
-  Tests for authentication
+  Tests for authentication (but see also below)
 
 examples/
   Demonstration programs for libpq that double as regression tests via
@@ -18,6 +18,12 @@ examples/
 isolation/
   Tests for concurrent behavior at the SQL level
 
+kerberos/
+  Tests for Kerberos/GSSAPI authentication and encryption
+
+ldap/
+  Tests for LDAP-based authentication
+
 locale/
   Sanity checks for locale data, encodings, etc
 
@@ -42,6 +48,3 @@ ssl/
 
 subscription/
   Tests for logical replication
-
-thread/
-  A thread-safety-testing utility used by configure
diff --git a/src/test/thread/.gitignore b/src/test/thread/.gitignore
deleted file mode 100644 (file)
index 1d54d54..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/thread_test
diff --git a/src/test/thread/Makefile b/src/test/thread/Makefile
deleted file mode 100644 (file)
index a13c0c6..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#-------------------------------------------------------------------------
-#
-# Makefile for tools/thread
-#
-# Copyright (c) 2003-2020, PostgreSQL Global Development Group
-#
-# src/test/thread/Makefile
-#
-#-------------------------------------------------------------------------
-
-subdir = src/tools/thread
-top_builddir = ../../..
-include $(top_builddir)/src/Makefile.global
-
-override CFLAGS += $(PTHREAD_CFLAGS)
-
-all: thread_test
-
-thread_test: thread_test.o
-# no need for $LIBS, might not be compiled yet
-   $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(PTHREAD_LIBS) -o $@$(X)
-
-clean distclean maintainer-clean:
-   rm -f thread_test$(X) thread_test.o
diff --git a/src/test/thread/README b/src/test/thread/README
deleted file mode 100644 (file)
index 4da2344..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-src/test/thread/README
-
-Threading
-=========
-
-This program is run by configure to determine if threading is
-properly supported on the platform.
-
-You can run the program manually to see details, which shows if your
-native libc functions are thread-safe, or if we use *_r functions or
-thread locking.
-
-To use this program manually, you must:
-
-   o run "configure"
-   o compile the main source tree
-   o compile and run this program
-
-If your platform requires special thread flags that are not tested by
-/config/acx_pthread.m4, add PTHREAD_CFLAGS and PTHREAD_LIBS defines to
-your template/${port} file.
-
-Windows Systems
-===============
-
-Windows systems do not vary in their thread-safeness in the same way that
-other systems might, nor do they generally have pthreads installed, hence
-on Windows this test is skipped by the configure program (pthreads is
-required by the test program, but not PostgreSQL itself). If you do wish
-to test your system however, you can do so as follows:
-
-1) Install pthreads in you Mingw/Msys environment. You can download pthreads
-   from ftp://sources.redhat.com/pub/pthreads-win32/.
-
-2) Build the test program:
-
-   gcc -o thread_test.exe \
-    -D_REENTRANT \
-    -D_THREAD_SAFE \
-    -D_POSIX_PTHREAD_SEMANTICS \
-    -I../../../src/include/port/win32 \
-    thread_test.c \
-    -lws2_32 \
-    -lpthreadgc2
-
-3) Run thread_test.exe. You should see output like:
-
-    dpage@PC30:/cvs/pgsql/src/tools/thread$ ./thread_test
-    Your GetLastError() is thread-safe.
-    Your system uses strerror() which is thread-safe.
-    getpwuid_r()/getpwuid() are not applicable to Win32 platforms.
-    Your system uses gethostbyname which is thread-safe.
-
-    Your platform is thread-safe.