blob: 42c002c19bbcca0da74b9205f5567a392aad5c57 (
plain)
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
51
52
53
54
55
|
#!/usr/bin/perl
#
# Tests for various caching errors
#
use Config;
my $file = "tf$$.txt";
unless ($Config{d_alarm}) {
print "1..0\n"; exit;
}
$: = Tie::File::_default_recsep();
my $data = join $:, "record0" .. "record9", "";
my $V = $ENV{INTEGRITY}; # Verbose integrity checking?
print "1..3\n";
my $N = 1;
use Tie::File;
print "ok $N\n"; $N++;
open F, '>', $file or die $!;
binmode F;
print F $data;
close F;
# Limit cache size to 30 bytes
my $MAX = 30;
# -- that's enough space for 3 records, but not 4, on both \n and \r\n systems
my $o = tie @a, 'Tie::File', $file, memory => $MAX, autodefer => 1;
print $o ? "ok $N\n" : "not ok $N\n";
$N++;
# (3) In 0.50 this goes into an infinite loop. Explanation:
#
# Suppose you overfill the defer buffer by so much that the memory
# limit is also exceeded. You'll go into _splice to prepare to
# write out the defer buffer, and _splice will call _fetch, which
# will then try to flush the read cache---but the read cache is
# already empty, so you're stuck in an infinite loop.
#
# Five seconds should be plenty of time for it to complete if it works.
alarm 5 unless $^P;
@a = "record0" .. "record9";
print "ok 3\n";
alarm 0;
END {
undef $o;
untie @a;
1 while unlink $file;
}
|