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