aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-07-03 15:01:55 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-07-03 15:01:55 +0300
commit3a1d5f8bdc29803fb7a6713515f2c0c332e379fc (patch)
treef95c9240257bec56094b938541c80aa7b61c62f3 /t
downloadGDBM_File-3a1d5f8bdc29803fb7a6713515f2c0c332e379fc.tar.gz
GDBM_File-3a1d5f8bdc29803fb7a6713515f2c0c332e379fc.tar.bz2
Perl 5.28.0
Diffstat (limited to 't')
-rw-r--r--t/fatal.t49
-rw-r--r--t/gdbm.t6
2 files changed, 55 insertions, 0 deletions
diff --git a/t/fatal.t b/t/fatal.t
new file mode 100644
index 0000000..0e426d4
--- /dev/null
+++ b/t/fatal.t
@@ -0,0 +1,49 @@
+#!./perl -w
+use strict;
+
+use Test::More;
+use Config;
+
+BEGIN {
+ plan(skip_all => "GDBM_File was not built")
+ unless $Config{extensions} =~ /\bGDBM_File\b/;
+
+ # https://rt.perl.org/Public/Bug/Display.html?id=117967
+ plan(skip_all => "GDBM_File is flaky in $^O")
+ if $^O =~ /darwin/;
+
+ plan(tests => 8);
+ use_ok('GDBM_File');
+}
+
+unlink <Op_dbmx*>;
+
+open my $fh, '<', $^X or die "Can't open $^X: $!";
+my $fileno = fileno $fh;
+isnt($fileno, undef, "Can find next available file descriptor");
+close $fh or die $!;
+
+is((open $fh, "<&=$fileno"), undef,
+ "Check that we cannot open fileno $fileno. \$! is $!");
+
+umask(0);
+my %h;
+isa_ok(tie(%h, 'GDBM_File', 'Op_dbmx', GDBM_WRCREAT, 0640), 'GDBM_File');
+
+isnt((open $fh, "<&=$fileno"), undef, "dup fileno $fileno")
+ or diag("\$! = $!");
+isnt(close $fh, undef,
+ "close fileno $fileno, out from underneath the GDBM_File");
+is(eval {
+ $h{Perl} = 'Rules';
+ untie %h;
+ 1;
+}, undef, 'Trapped error when attempting to write to knobbled GDBM_File');
+
+# Observed "File write error" and "lseek error" from two different systems.
+# So there might be more variants. Important part was that we trapped the error
+# via croak.
+like($@, qr/ at .*\bfatal\.t line \d+\.\n\z/,
+ 'expected error message from GDBM_File');
+
+unlink <Op_dbmx*>;
diff --git a/t/gdbm.t b/t/gdbm.t
new file mode 100644
index 0000000..af9dd38
--- /dev/null
+++ b/t/gdbm.t
@@ -0,0 +1,6 @@
+#!./perl
+
+$::Create_and_Write = '(GDBM_WRCREAT, GDBM_WRITER)';
+our $DBM_Class = 'GDBM_File';
+
+require '../../t/lib/dbmt_common.pl';

Return to:

Send suggestions and report system problems to the System administrator.