File: bad_dir.t

package info (click to toggle)
libhash-sharedmem-perl 0.005-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 600 kB
  • sloc: perl: 463; makefile: 3
file content (28 lines) | stat: -r--r--r-- 763 bytes parent folder | download
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
use warnings;
use strict;

use Errno 1.00 qw(ENOENT);
use File::Temp 0.22 qw(tempdir);
use Test::More tests => 7;

BEGIN { use_ok "Hash::SharedMem", qw(is_shash shash_open shash_set); }

my $enoent = do { local $! = ENOENT; "$!" };

my $tmpdir = tempdir(CLEANUP => 1);

sub touch($) {
	my($fn) = @_;
	open(my $fh, ">", $fn) or die "can't create $fn: $!";
}

is eval { shash_open("$tmpdir/t0", "rw") }, undef;
like $@, qr#\Acan't open shared hash \Q$tmpdir\E/t0: \Q$enoent\E at #;

touch("$tmpdir/t1");
is eval { shash_open("$tmpdir/t1", "rw") }, undef;
like $@, qr#\Acan't open shared hash \Q$tmpdir\E/t1: not a shared hash at #;
is eval { shash_open("$tmpdir/t1", "rwc") }, undef;
like $@, qr#\Acan't open shared hash \Q$tmpdir\E/t1: not a shared hash at #;

1;