# Set PGHOST for backward compatibility. This doesn't work for own_host
# nodes, so prefer to not rely on this when writing new tests.
- $use_tcp = $TestLib::windows_os;
+ $use_tcp = !$TestLib::use_unix_sockets;
$test_localhost = "127.0.0.1";
$last_host_assigned = 1;
$test_pghost = $use_tcp ? $test_localhost : TestLib::tempdir_short;
open my $hba, '>>', "$pgdata/pg_hba.conf";
print $hba "\n# Allow replication (set up by PostgresNode.pm)\n";
- if ($TestLib::windows_os)
+ if ($TestLib::windows_os && !$TestLib::use_unix_sockets)
{
print $hba
"host replication all $test_localhost/32 sspi include_realm=1 map=regress\n";
command_checks_all
$windows_os
+ $use_unix_sockets
);
-our ($windows_os, $tmp_check, $log_path, $test_logfile);
+our ($windows_os, $use_unix_sockets, $tmp_check, $log_path, $test_logfile);
BEGIN
{
require Win32API::File;
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
}
+
+ # Specifies whether to use Unix sockets for test setups. On
+ # Windows we don't use them by default since it's not universally
+ # supported, but it can be overridden if desired.
+ $use_unix_sockets = (!$windows_os || defined $ENV{PG_TEST_USE_UNIX_SOCKETS});
}
=pod
* remove the directory. Ignore errors; leaking a temporary directory is
* unimportant. This can run from a signal handler. The code is not
* acceptable in a Windows signal handler (see initdb.c:trapsig()), but
- * on Windows, pg_regress does not use Unix sockets.
+ * on Windows, pg_regress does not use Unix sockets by default.
*/
static void
remove_temp(void)
{NULL, 0, NULL, 0}
};
+ bool use_unix_sockets;
_stringlist *sl;
int c;
int i;
atexit(stop_postmaster);
-#if !defined(HAVE_UNIX_SOCKETS) || defined(WIN32)
+#if !defined(HAVE_UNIX_SOCKETS)
+ use_unix_sockets = false;
+#elif defined(WIN32)
+
/*
- * No Unix-domain sockets available, so change default. For now, we also
- * don't use them on Windows, even if the build supports them. (See
- * comment at remove_temp() for a reason.)
+ * We don't use Unix-domain sockets on Windows by default, even if the
+ * build supports them. (See comment at remove_temp() for a reason.)
+ * Override at your own risk.
*/
- hostname = "localhost";
+ use_unix_sockets = getenv("PG_TEST_USE_UNIX_SOCKETS") ? true : false;
+#else
+ use_unix_sockets = true;
#endif
+ if (!use_unix_sockets)
+ hostname = "localhost";
+
/*
* We call the initialization function here because that way we can set
* default parameters and let them be overwritten by the commandline.
if (config_auth_datadir)
{
#ifdef ENABLE_SSPI
- config_sspi_auth(config_auth_datadir, user);
+ if (!use_unix_sockets)
+ config_sspi_auth(config_auth_datadir, user);
#endif
exit(0);
}
fclose(pg_conf);
#ifdef ENABLE_SSPI
-
- /*
- * Since we successfully used the same buffer for the much-longer
- * "initdb" command, this can't truncate.
- */
- snprintf(buf, sizeof(buf), "%s/data", temp_instance);
- config_sspi_auth(buf, NULL);
+ if (!use_unix_sockets)
+ {
+ /*
+ * Since we successfully used the same buffer for the much-longer
+ * "initdb" command, this can't truncate.
+ */
+ snprintf(buf, sizeof(buf), "%s/data", temp_instance);
+ config_sspi_auth(buf, NULL);
+ }
#elif !defined(HAVE_UNIX_SOCKETS)
#error Platform has no means to secure the test installation.
#endif