2 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use File::Temp qw(tempfile);
7 use PublicInbox::TestCommon;
8 use PublicInbox::Spawn qw(which);
9 use_ok 'PublicInbox::NDC_PP';
13 skip 'test is Linux-only', $nr if $^O ne 'linux';
14 my $dir = $ENV{BTRFS_TESTDIR};
15 skip 'BTRFS_TESTDIR not defined', $nr unless defined $dir;
16 skip 'chattr(1) not installed', $nr unless which('chattr');
17 my $lsattr = which('lsattr') or skip 'lsattr(1) not installed', $nr;
18 my ($fh, $name) = tempfile(DIR => $dir, UNLINK => 1);
19 BAIL_OUT "tempfile: $!" unless $fh && defined($name);
20 my $pp_sub = \&PublicInbox::NDC_PP::set_nodatacow;
21 $pp_sub->(fileno($fh));
22 my $res = xqx([$lsattr, $name]);
23 like($res, qr/C/, "`C' attribute set with pure Perl");
25 my $ic_sub = \&PublicInbox::Spawn::set_nodatacow;
26 $pp_sub == $ic_sub and
27 skip 'Inline::C or Linux kernel headers missing', 1;
28 ($fh, $name) = tempfile(DIR => $dir, UNLINK => 1);
29 $ic_sub->(fileno($fh));
30 $res = xqx([$lsattr, $name]);
31 like($res, qr/C/, "`C' attribute set with Inline::C");