user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
9b67c521ffab7ff94e7986735c47683982c89856 blob 1725 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
#!perl -w
# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use Test::More;
use File::Temp 0.19;
use PublicInbox::TestCommon;
use PublicInbox::Spawn qw(which);
use_ok 'PublicInbox::NDC_PP';

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 $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));
	my $res = xqx([$lsattr, $name]);
	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);
	$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;
debug log:

solving 9b67c521 ...
found 9b67c521 in https://80x24.org/public-inbox.git

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).