1#!./perl 2 3use warnings; 4use strict; 5use Config; 6use Fcntl; 7use Test::More; 8use DB_File; 9use File::Temp qw(tempdir) ; 10 11if (-d "lib" && -f "TEST") { 12 if ($Config{'extensions'} !~ /\bDB_File\b/ ) { 13 plan skip_all => 'DB_File was not built'; 14 } 15} 16plan skip_all => 'Threads are disabled' 17 unless $Config{usethreads}; 18 19plan skip_all => 'Thread test needs Perl 5.8.7 or greater' 20 unless $] >= 5.008007; 21 22plan tests => 7; 23 24# Check DBM back-ends do not destroy objects from then-spawned threads. 25# RT#61912. 26use_ok('threads'); 27 28my $TEMPDIR = tempdir( CLEANUP => 1 ); 29chdir $TEMPDIR; 30 31my %h; 32unlink <threads*>; 33 34my $db = tie %h, 'DB_File', 'threads', O_RDWR|O_CREAT, 0640; 35isa_ok($db, 'DB_File'); 36 37for (1 .. 2) { 38 ok(threads->create( 39 sub { 40 $SIG{'__WARN__'} = sub { fail(shift) }; # debugging perl panics 41 # report it by spurious TAP line 42 1; 43 }), "Thread $_ created"); 44} 45for (threads->list) { 46 is($_->join, 1, "A thread exited successfully"); 47} 48 49pass("Tied object survived exiting threads"); 50 51undef $db; 52untie %h; 53unlink <threads*>; 54