X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fnodatacow.t;h=0940d908e935772183fda449be0ff7d6b152e75c;hb=4ac15319847bc91ab2b7e8bb4b9f8955ba9fd55c;hp=9b67c521ffab7ff94e7986735c47683982c89856;hpb=80f4192574065106ae72a7a73ee0f02ebd86708a;p=public-inbox.git
diff --git a/t/nodatacow.t b/t/nodatacow.t
index 9b67c521..0940d908 100644
--- a/t/nodatacow.t
+++ b/t/nodatacow.t
@@ -1,50 +1,42 @@
#!perl -w
-# Copyright (C) 2020-2021 all contributors
+# Copyright (C) all contributors
# License: AGPL-3.0+
-use strict;
-use Test::More;
+use strict; use v5.10.1; use PublicInbox::TestCommon;
use File::Temp 0.19;
-use PublicInbox::TestCommon;
-use PublicInbox::Spawn qw(which);
-use_ok 'PublicInbox::NDC_PP';
+use_ok 'PublicInbox::Syscall';
+
+# btrfs on Linux is copy-on-write (COW) by default. As of Linux 5.7,
+# this still leads to fragmentation for SQLite and Xapian files where
+# random I/O happens, so we disable COW just for SQLite files and Xapian
+# directories. Disabling COW disables checksumming, so we only do this
+# for regeneratable files, and not canonical git storage (git doesn't
+# checksum refs, only data under $GIT_DIR/objects).
SKIP: {
my $nr = 2;
skip 'test is Linux-only', $nr if $^O ne 'linux';
my $dir = $ENV{BTRFS_TESTDIR};
skip 'BTRFS_TESTDIR not defined', $nr unless defined $dir;
- skip 'chattr(1) not installed', $nr unless which('chattr');
- my $lsattr = which('lsattr') or skip 'lsattr(1) not installed', $nr;
+
+ my $lsattr = require_cmd('lsattr', 1) or
+ skip 'lsattr(1) not installed', $nr;
+
my $tmp = File::Temp->newdir('nodatacow-XXXX', DIR => $dir);
my $dn = $tmp->dirname;
my $name = "$dn/pp.f";
open my $fh, '>', $name or BAIL_OUT "open($name): $!";
- my $pp_sub = \&PublicInbox::NDC_PP::nodatacow_fd;
- $pp_sub->(fileno($fh));
+ PublicInbox::Syscall::nodatacow_fh($fh);
my $res = xqx([$lsattr, $name]);
+
+ BAIL_OUT "lsattr(1) fails in $dir" if $?;
like($res, qr/C.*\Q$name\E/, "`C' attribute set on fd with pure Perl");
$name = "$dn/pp.d";
mkdir($name) or BAIL_OUT "mkdir($name) $!";
- PublicInbox::NDC_PP::nodatacow_dir($name);
+ PublicInbox::Syscall::nodatacow_dir($name);
$res = xqx([$lsattr, '-d', $name]);
like($res, qr/C.*\Q$name\E/, "`C' attribute set on dir with pure Perl");
-
- $name = "$dn/ic.f";
- my $ic_sub = \&PublicInbox::Spawn::nodatacow_fd;
- $pp_sub == $ic_sub and
- skip 'Inline::C or Linux kernel headers missing', 2;
- open $fh, '>', $name or BAIL_OUT "open($name): $!";
- $ic_sub->(fileno($fh));
- $res = xqx([$lsattr, $name]);
- like($res, qr/C.*\Q$name\E/, "`C' attribute set on fd with Inline::C");
-
- $name = "$dn/ic.d";
- mkdir($name) or BAIL_OUT "mkdir($name) $!";
- PublicInbox::Spawn::nodatacow_dir($name);
- $res = xqx([$lsattr, '-d', $name]);
- like($res, qr/C.*\Q$name\E/, "`C' attribute set on dir with Inline::C");
};
done_testing;