xref: /openbsd-src/gnu/usr.bin/perl/ext/FileCache/t/02maxopen.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1b39c5158Smillert#!./perl
2b39c5158Smillert
3b39c5158Smillertuse FileCache maxopen => 2;
45759b3d2Safresh1our @files;
5*f2a19305Safresh1BEGIN { @files = map { "max_$_" } qw(foo bar baz quux) }
6b39c5158SmillertEND { 1 while unlink @files }
7b39c5158Smillert
8b39c5158Smillertuse Test::More tests => 5;
9b39c5158Smillert
10b39c5158Smillert{# Test 2: that we actually adhere to maxopen
11b39c5158Smillert  for my $path ( @files ){
12b39c5158Smillert    cacheout $path;
13b39c5158Smillert    print $path "$path 1\n";
14b39c5158Smillert  }
15b39c5158Smillert
16b39c5158Smillert  my @cat;
17b39c5158Smillert  for my $path ( @files ){
18*f2a19305Safresh1    ok(fileno($path) || $path =~ /^max_(?:foo|bar)$/);
19b39c5158Smillert    next unless fileno($path);
20b39c5158Smillert    print $path "$path 2\n";
21b39c5158Smillert    close($path);
225759b3d2Safresh1    open($path, '<', $path);
23b39c5158Smillert    <$path>;
24b39c5158Smillert    push @cat, <$path>;
25b39c5158Smillert    close($path);
26b39c5158Smillert  }
27*f2a19305Safresh1  ok( grep(/^max_(?:baz|quux) 2$/, @cat) == 2 );
28b39c5158Smillert}
29