From: Jarkko Hietaniemi Date: Tue, 19 Jun 2001 10:34:35 +0000 (+0000) Subject: One test lost in the big shuffle restored. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6edcbe38e46d61636fab688fbe51e9884121ea57;p=p5sagit%2Fp5-mst-13.2.git One test lost in the big shuffle restored. p4raw-id: //depot/perl@10712 --- diff --git a/MANIFEST b/MANIFEST index c132200..1140a04 100644 --- a/MANIFEST +++ b/MANIFEST @@ -448,6 +448,7 @@ ext/IPC/SysV/SysV.pm IPC::SysV extension Perl module ext/IPC/SysV/SysV.xs IPC::SysV extension Perl module ext/IPC/SysV/hints/cygwin.pl Hint for IPC::SysV for named architecture ext/IPC/SysV/hints/next_3.pl Hint for IPC::SysV for named architecture +ext/IPC/SysV/ipcsysv.t See if IPC::SysV works ext/IPC/SysV/t/msg.t IPC::SysV extension Perl module ext/IPC/SysV/t/sem.t IPC::SysV extension Perl module ext/List/Util/ChangeLog Util extension @@ -605,7 +606,7 @@ ext/Thread/Thread/Queue.pm Thread synchronised queue objects ext/Thread/Thread/Semaphore.pm Thread semaphore objects ext/Thread/Thread/Signal.pm Start a thread to run signal handlers ext/Thread/Thread/Specific.pm Thread specific data access -ext/Thread/create.t Test thread creation +ext/Thread/create.tx Test thread creation ext/Thread/die.tx Test thread die() ext/Thread/die2.tx Test thread die() differently ext/Thread/io.tx Test threads doing simple I/O diff --git a/ext/IPC/SysV/ipcsysv.t b/ext/IPC/SysV/ipcsysv.t new file mode 100755 index 0000000..795ad5d --- /dev/null +++ b/ext/IPC/SysV/ipcsysv.t @@ -0,0 +1,218 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + + @INC = '../lib'; + + require Config; import Config; + + my $reason; + + 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'; + } + if ($reason) { + print "1..0 # Skip: $reason\n"; + exit 0; + } +} + +# 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); +use strict; + +print "1..16\n"; + +my $msg; +my $sem; + +$SIG{__DIE__} = 'cleanup'; # will cleanup $msg and $sem if needed + +# FreeBSD is known to throw this if there's no SysV IPC in the kernel. +$SIG{SYS} = sub { + print STDERR <= 0; + + print "ok 1\n"; + + #Putting a message on the queue + my $msgtype = 1; + my $msgtext = "hello"; + + 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 <= 0; + + print "ok 7\n"; + + my $data; + semctl($sem,0,IPC_STAT,$data) or print "not "; + print "ok 8\n"; + + print "not " unless length($data); + print "ok 9\n"; + + my $nsem = 10; + + semctl($sem,0,SETALL,pack("s!*",(0) x $nsem)) or print "not "; + print "ok 10\n"; + + $data = ""; + semctl($sem,0,GETALL,$data) or print "not "; + print "ok 11\n"; + + print "not " unless length($data) == length(pack("s!*",(0) x $nsem)); + print "ok 12\n"; + + my @data = unpack("s!*",$data); + + my $adata = "0" x $nsem; + + print "not " unless @data == $nsem and join("",@data) eq $adata; + print "ok 13\n"; + + my $poke = 2; + + $data[$poke] = 1; + semctl($sem,0,SETALL,pack("s!*",@data)) or print "not "; + print "ok 14\n"; + + $data = ""; + semctl($sem,0,GETALL,$data) or print "not "; + print "ok 15\n"; + + @data = unpack("s!*",$data); + + my $bdata = "0" x $poke . "1" . "0" x ($nsem-$poke-1); + + print "not " unless join("",@data) eq $bdata; + print "ok 16\n"; + } else { + for (7..16) { + print "ok $_ # skipped, no semctl possible\n"; + } + } +} else { + for (7..16) { + print "ok $_\n"; # fake it + } +} + +sub cleanup { + msgctl($msg,IPC_RMID,0) if defined $msg; + semctl($sem,0,IPC_RMID,undef) if defined $sem; +} + +cleanup; diff --git a/ext/IPC/SysV/t/msg.t b/ext/IPC/SysV/t/msg.t index f8c066b..e20d93c 100755 --- a/ext/IPC/SysV/t/msg.t +++ b/ext/IPC/SysV/t/msg.t @@ -1,12 +1,22 @@ BEGIN { - eval { require Config; import Config }; - if ($@) { - print "1..0 # Skip: no Config\n"; - exit(0); + chdir 't' if -d 't'; + + @INC = '../lib'; + + require Config; import Config; + + my $reason; + + 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'; } - if ($Config{extensions} !~ m!\bIPC/SysV\b!) { - print "1..0 # Skip: no SysV IPC\n"; - exit(0); + if ($reason) { + print "1..0 # Skip: $reason\n"; + exit 0; } } diff --git a/ext/IPC/SysV/t/sem.t b/ext/IPC/SysV/t/sem.t index 9fa5704..b3c813c 100755 --- a/ext/IPC/SysV/t/sem.t +++ b/ext/IPC/SysV/t/sem.t @@ -1,12 +1,22 @@ BEGIN { - eval { require Config; import Config }; - if ($@) { - print "1..0 # Skip: no Config\n"; - exit(0); + chdir 't' if -d 't'; + + @INC = '../lib'; + + require Config; import Config; + + my $reason; + + 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'; } - if ($Config{extensions} !~ m!\bIPC/SysV\b!) { - print "1..0 # Skip: no SysV IPC\n"; - exit(0); + if ($reason) { + print "1..0 # Skip: $reason\n"; + exit 0; } }