Fix-n-skip the tests under 5005threads.
[p5sagit/p5-mst-13.2.git] / t / lib / ipc_sysv.t
index 00a157b..d2991e3 100755 (executable)
@@ -9,7 +9,9 @@ BEGIN {
 
     my $reason;
 
-    if ($Config{'d_sem'} ne 'define') {
+    if ($Config{'extensions'} !~ /\bIPC\/SysV\b/) {
+      $reason = 'IPC::SysV was not built';
+    } elsif ($Config{'d_sem'} ne 'define') {
       $reason = '$Config{d_sem} undefined';
     } elsif ($Config{'d_msg'} ne 'define') {
       $reason = '$Config{d_msg} undefined';
@@ -23,8 +25,7 @@ BEGIN {
 # These constants are common to all tests.
 # Later the sem* tests will import more for themselves.
 
-use IPC::SysV qw(IPC_PRIVATE IPC_NOWAIT IPC_STAT IPC_RMID
-                S_IRWXU S_IRWXG S_IRWXO S_IWGRP S_IROTH S_IWOTH);
+use IPC::SysV qw(IPC_PRIVATE IPC_NOWAIT IPC_STAT IPC_RMID S_IRWXU);
 use strict;
 
 print "1..16\n";
@@ -55,12 +56,7 @@ EOM
     exit(1);
 };
 
-my $perm;
-
-$perm = S_IRWXU | S_IRWXG | S_IRWXO | S_IWGRP | S_IROTH | S_IWOTH
-    if $^O eq 'vmesa';
-
-$perm = S_IRWXU | S_IRWXG | S_IRWXO unless defined $perm;
+my $perm = S_IRWXU;
 
 if ($Config{'d_msgget'} eq 'define' &&
     $Config{'d_msgctl'} eq 'define' &&
@@ -77,8 +73,34 @@ if ($Config{'d_msgget'} eq 'define' &&
     my $msgtype = 1;
     my $msgtext = "hello";
 
-    msgsnd($msg,pack("L a*",$msgtype,$msgtext),0) or print "not ";
+    my $test2bad;
+    my $test5bad;
+    my $test6bad;
+
+    unless (msgsnd($msg,pack("L! a*",$msgtype,$msgtext),IPC_NOWAIT)) {
+       print "not ";
+       $test2bad = 1;
+    }
     print "ok 2\n";
+    if ($test2bad) {
+       print <<EOM;
+#
+# The failure of the subtest #2 may indicate that the message queue
+# resource limits either of the system or of the testing account
+# have been reached.  Error message "Operating would block" is
+# usually indicative of this situation.  The error message was now:
+# "$!"
+#
+# You can check the message queues with the 'ipcs' command and
+# you can remove unneeded queues with the 'ipcrm -q id' command.
+# You may also consider configuring your system or account
+# to have more message queue resources.
+#
+# Because of the subtest #2 failing also the substests #5 and #6 will
+# very probably also fail.
+#
+EOM
+    }
 
     my $data;
     msgctl($msg,IPC_STAT,$data) or print "not ";
@@ -88,13 +110,33 @@ if ($Config{'d_msgget'} eq 'define' &&
     print "ok 4\n";
 
     my $msgbuf;
-    msgrcv($msg,$msgbuf,256,0,IPC_NOWAIT) or print "not ";
+    unless (msgrcv($msg,$msgbuf,256,0,IPC_NOWAIT)) {
+       print "not ";
+       $test5bad = 1;
+    }
     print "ok 5\n";
+    if ($test5bad && $test2bad) {
+       print <<EOM;
+#
+# This failure was to be expected because the subtest #2 failed.
+#
+EOM
+    }
 
-    my($rmsgtype,$rmsgtext) = unpack("L a*",$msgbuf);
-
-    print "not " unless($rmsgtype == $msgtype && $rmsgtext eq $msgtext);
+    my($rmsgtype,$rmsgtext);
+    ($rmsgtype,$rmsgtext) = unpack("L! a*",$msgbuf);
+    unless ($rmsgtype == $msgtype && $rmsgtext eq $msgtext) {
+       print "not ";
+       $test6bad = 1;
+    }
     print "ok 6\n";
+    if ($test6bad && $test2bad) {
+       print <<EOM;
+#
+# This failure was to be expected because the subtest #2 failed.
+#
+EOM
+     }
 } else {
     for (1..6) {
        print "ok $_\n"; # fake it