Re: bugzilla.redhat bug #101767 (threads, threads::shared)
[p5sagit/p5-mst-13.2.git] / ext / threads / t / basic.t
index 893c30b..09a148d 100755 (executable)
@@ -15,7 +15,7 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = '../lib';
+    push @INC, '../lib';
     require Config; import Config;
     unless ($Config{'useithreads'}) {
        print "1..0 # Skip: no useithreads\n";
@@ -25,7 +25,7 @@ BEGIN {
 
 use ExtUtils::testlib;
 use strict;
-BEGIN { $| = 1; print "1..15\n" };
+BEGIN { $| = 1; print "1..19\n" };
 use threads;
 
 
@@ -73,20 +73,13 @@ ok(5, 1 == $threads::threads,"Check that threads::threads is true");
 
 #test trying to detach thread
 
-sub test4 { ok(6,1,"Detach test"); rmdir "thrsem" }
-
-# Just a sleep() would not guarantee that we sleep and will not
-# wake up before the just created thread finishes.  Instead, let's
-# use the filesystem as a semaphore.  Creating a directory and removing
-# it should be a reasonably atomic operation even over NFS. 
-# Also, we do not want to depend here on shared variables.
-
-mkdir "thrsem", 0700;
+sub test4 { ok(6,1,"Detach test") }
 
 my $thread1 = threads->create('test4');
 
 $thread1->detach();
-sleep 1 while -d "thrsem";
+threads->yield; # help out non-preemptive thread implementations
+sleep 2;
 ok(7,1,"Detach test");
 
 
@@ -123,8 +116,29 @@ threads->create('test8')->join;
 ok(14, 0 == threads->self->tid(),"Check so that tid for threads work for main thread");
 ok(15, 0 == threads->tid(),"Check so that tid for threads work for main thread");
 
-END {
-    1 while rmdir "thrsem";
+{
+       no warnings;
+    local *CLONE = sub { ok(16, threads->tid() == 9, "Tid should be correct in the clone")};
+    threads->create(sub { ok(17, threads->tid() == 9, "And tid be 9 here too") })->join();
 }
 
+{ 
+
+    sub Foo::DESTROY { 
+       ok(19, threads->tid() == 10, "In destroy it should be correct too" )
+       }
+    my $foo;
+    threads->create(sub { ok(18, threads->tid() == 10, "And tid be 10 here");
+                         $foo = bless {}, 'Foo';                         
+                         return undef;
+                     })->join();
+
+}
 1;
+
+
+
+
+
+
+