Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1d53432

Browse files
committed
Allow using Unix-domain sockets on Windows in tests
The test suites currently don't use Unix-domain sockets on Windows.This optionally allows enabling that by setting the environmentvariable PG_TEST_USE_UNIX_SOCKETS.This should currently be considered experimental. In particular,pg_regress.c contains some comments that the cleanup code forUnix-domain sockets doesn't work correctly under Windows, which hasn'tbeen an problem until now. But it's good enough for locallysupervised testing of the functionality.Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>Discussion:https://www.postgresql.org/message-id/flat/54bde68c-d134-4eb8-5bd3-8af33b72a010@2ndquadrant.com
1 parent8c49454 commit1d53432

File tree

6 files changed

+42
-26
lines changed

6 files changed

+42
-26
lines changed

‎src/bin/pg_ctl/t/001_start_stop.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
print$conf TestLib::slurp_file($ENV{TEMP_CONFIG})
3030
ifdefined$ENV{TEMP_CONFIG};
3131

32-
if (!$windows_os)
32+
if ($use_unix_sockets)
3333
{
3434
print$conf"listen_addresses = ''\n";
3535
print$conf"unix_socket_directories = '$tempdir_short'\n";

‎src/test/authentication/t/001_password.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
# - Plain
44
# - MD5-encrypted
55
# - SCRAM-encrypted
6-
# This test cannot run on Windows as Postgres cannot be set up with Unix
7-
# sockets and needs to go through SSPI.
6+
# This test can only run with Unix-domain sockets.
87

98
use strict;
109
use warnings;
1110
use PostgresNode;
1211
use TestLib;
1312
use Test::More;
14-
if ($windows_os)
13+
if (!$use_unix_sockets)
1514
{
16-
planskip_all=>"authentication tests cannot runon Windows";
15+
planskip_all=>"authentication tests cannot runwithout Unix-domain sockets";
1716
}
1817
else
1918
{

‎src/test/authentication/t/002_saslprep.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# Test password normalization in SCRAM.
22
#
3-
# This test cannot run on Windows as Postgres cannot be set up with Unix
4-
# sockets and needs to go through SSPI.
3+
# This test can only run with Unix-domain sockets.
54

65
use strict;
76
use warnings;
87
use PostgresNode;
98
use TestLib;
109
use Test::More;
11-
if ($windows_os)
10+
if (!$use_unix_sockets)
1211
{
13-
planskip_all=>"authentication tests cannot runon Windows";
12+
planskip_all=>"authentication tests cannot runwithout Unix-domain sockets";
1413
}
1514
else
1615
{

‎src/test/perl/PostgresNode.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ INIT
116116

117117
# Set PGHOST for backward compatibility. This doesn't work for own_host
118118
# nodes, so prefer to not rely on this when writing new tests.
119-
$use_tcp =$TestLib::windows_os;
119+
$use_tcp =!$TestLib::use_unix_sockets;
120120
$test_localhost ="127.0.0.1";
121121
$last_host_assigned = 1;
122122
$test_pghost =$use_tcp ?$test_localhost : TestLib::tempdir_short;
@@ -387,7 +387,7 @@ sub set_replication_conf
387387

388388
openmy$hba,'>>',"$pgdata/pg_hba.conf";
389389
print$hba"\n# Allow replication (set up by PostgresNode.pm)\n";
390-
if ($TestLib::windows_os)
390+
if ($TestLib::windows_os && !$TestLib::use_unix_sockets)
391391
{
392392
print$hba
393393
"host replication all$test_localhost/32 sspi include_realm=1 map=regress\n";

‎src/test/perl/TestLib.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ our @EXPORT = qw(
8383
command_checks_all
8484
8585
$windows_os
86+
$use_unix_sockets
8687
);
8788

88-
our ($windows_os,$tmp_check,$log_path,$test_logfile);
89+
our ($windows_os,$use_unix_sockets,$tmp_check,$log_path,$test_logfile);
8990

9091
BEGIN
9192
{
@@ -117,6 +118,11 @@ BEGIN
117118
require Win32API::File;
118119
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
119120
}
121+
122+
# Specifies whether to use Unix sockets for test setups. On
123+
# Windows we don't use them by default since it's not universally
124+
# supported, but it can be overridden if desired.
125+
$use_unix_sockets = (!$windows_os ||defined$ENV{PG_TEST_USE_UNIX_SOCKETS});
120126
}
121127

122128
=pod

‎src/test/regress/pg_regress.c

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ stop_postmaster(void)
292292
* remove the directory. Ignore errors; leaking a temporary directory is
293293
* unimportant. This can run from a signal handler. The code is not
294294
* acceptable in a Windows signal handler (see initdb.c:trapsig()), but
295-
* on Windows, pg_regress does not use Unix sockets.
295+
* on Windows, pg_regress does not use Unix sockets by default.
296296
*/
297297
staticvoid
298298
remove_temp(void)
@@ -2106,6 +2106,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
21062106
{NULL,0,NULL,0}
21072107
};
21082108

2109+
booluse_unix_sockets;
21092110
_stringlist*sl;
21102111
intc;
21112112
inti;
@@ -2121,15 +2122,23 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
21212122

21222123
atexit(stop_postmaster);
21232124

2124-
#if !defined(HAVE_UNIX_SOCKETS)|| defined(WIN32)
2125+
#if !defined(HAVE_UNIX_SOCKETS)
2126+
use_unix_sockets= false;
2127+
#elif defined(WIN32)
2128+
21252129
/*
2126-
*NoUnix-domain socketsavailable, so change default. For now, we also
2127-
*don't use them on Windows, even if the build supports them. (See
2128-
*comment atremove_temp() for a reason.)
2130+
*We don't useUnix-domain socketson Windows by default, even if the
2131+
*build supports them. (See comment at remove_temp() for a reason.)
2132+
*Override atyour own risk.
21292133
*/
2130-
hostname="localhost";
2134+
use_unix_sockets=getenv("PG_TEST_USE_UNIX_SOCKETS") ? true : false;
2135+
#else
2136+
use_unix_sockets= true;
21312137
#endif
21322138

2139+
if (!use_unix_sockets)
2140+
hostname="localhost";
2141+
21332142
/*
21342143
* We call the initialization function here because that way we can set
21352144
* default parameters and let them be overwritten by the commandline.
@@ -2243,7 +2252,8 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
22432252
if (config_auth_datadir)
22442253
{
22452254
#ifdefENABLE_SSPI
2246-
config_sspi_auth(config_auth_datadir,user);
2255+
if (!use_unix_sockets)
2256+
config_sspi_auth(config_auth_datadir,user);
22472257
#endif
22482258
exit(0);
22492259
}
@@ -2364,13 +2374,15 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
23642374
fclose(pg_conf);
23652375

23662376
#ifdefENABLE_SSPI
2367-
2368-
/*
2369-
* Since we successfully used the same buffer for the much-longer
2370-
* "initdb" command, this can't truncate.
2371-
*/
2372-
snprintf(buf,sizeof(buf),"%s/data",temp_instance);
2373-
config_sspi_auth(buf,NULL);
2377+
if (!use_unix_sockets)
2378+
{
2379+
/*
2380+
* Since we successfully used the same buffer for the much-longer
2381+
* "initdb" command, this can't truncate.
2382+
*/
2383+
snprintf(buf,sizeof(buf),"%s/data",temp_instance);
2384+
config_sspi_auth(buf,NULL);
2385+
}
23742386
#elif !defined(HAVE_UNIX_SOCKETS)
23752387
#error Platform has no means to secure the test installation.
23762388
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp