Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ca8df2

Browse files
committed
Skip the 004_io_direct.pl test if a pre-flight check fails.
The test previously had a list of OSes that direct I/O was expected to work on. That worked well enough for the systems in our build farm, but didn't survive contact with the Debian build bots running on tmpfs via overlayfs. tmpfs does not support O_DIRECT, but we don't want to exclude Linux generally. The new approach is to try to create an empty file with O_DIRECT from Perl first. If that fails, we'll skip the test and report what the error was. Reported-by: Christoph Berg <myon@debian.org> Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Reviewed-by: Andrew Dunstan <andrew@dunslane.net> Discussion: https://postgr.es/m/ZDYd4A78cT2ULxZZ%40msg.df7cb.de
1 parent b37d051 commit 6ca8df2

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

src/test/modules/test_misc/t/004_io_direct.pl

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,38 @@
22

33
use strict;
44
use warnings;
5+
use Fcntl;
6+
use IO::File;
57
use PostgreSQL::Test::Cluster;
68
use PostgreSQL::Test::Utils;
79
use Test::More;
810

9-
# Systems that we know to have direct I/O support, and whose typical local
10-
# filesystems support it or at least won't fail with an error. (illumos should
11-
# probably be in this list, but perl reports it as solaris. Solaris should not
12-
# be in the list because we don't support its way of turning on direct I/O, and
13-
# even if we did, its version of ZFS rejects it, and OpenBSD just doesn't have
14-
# it.)
15-
if (!grep { $^O eq $_ } qw(aix darwin dragonfly freebsd linux MSWin32 netbsd))
11+
# We know that macOS has F_NOCACHE, and we know that Windows has
12+
# FILE_FLAG_NO_BUFFERING, and we assume that their typical file systems will
13+
# accept those flags. For every other system, we'll probe for O_DIRECT
14+
# support.
15+
16+
if ($^O ne 'darwin' && $^O ne 'MSWin32')
1617
{
17-
plan skip_all => "no direct I/O support";
18+
# Perl's Fcntl module knows if this system has O_DIRECT in <fcntl.h>.
19+
if (defined &O_DIRECT)
20+
{
21+
# Can we open a file in O_DIRECT mode in the file system where
22+
# tmp_check lives?
23+
my $f = IO::File->new(
24+
"${PostgreSQL::Test::Utils::tmp_check}/test_o_direct_file",
25+
O_RDWR | O_DIRECT | O_CREAT);
26+
if (!$f)
27+
{
28+
plan skip_all =>
29+
"pre-flight test if we can open a file with O_DIRECT failed: $!";
30+
}
31+
$f->close;
32+
}
33+
else
34+
{
35+
plan skip_all => "no O_DIRECT";
36+
}
1837
}
1938

2039
my $node = PostgreSQL::Test::Cluster->new('main');

0 commit comments

Comments
 (0)