Re: [PATCH] Re: Oops - Can't calculate our powers
[p5sagit/p5-mst-13.2.git] / ext / IPC / SysV / t / sem.t
CommitLineData
72802890 1BEGIN {
6edcbe38 2 chdir 't' if -d 't';
3
4 @INC = '../lib';
5
6 require Config; import Config;
7
8 my $reason;
9
10 if ($Config{'extensions'} !~ /\bIPC\/SysV\b/) {
11 $reason = 'IPC::SysV was not built';
12 } elsif ($Config{'d_sem'} ne 'define') {
13 $reason = '$Config{d_sem} undefined';
14 } elsif ($Config{'d_msg'} ne 'define') {
15 $reason = '$Config{d_msg} undefined';
72802890 16 }
6edcbe38 17 if ($reason) {
18 print "1..0 # Skip: $reason\n";
19 exit 0;
72802890 20 }
21}
0ade1984 22
23use IPC::SysV qw(
24 SETALL
25 IPC_PRIVATE
26 IPC_CREAT
27 IPC_RMID
28 IPC_NOWAIT
29 IPC_STAT
30 S_IRWXU
31 S_IRWXG
32 S_IRWXO
33);
34use IPC::Semaphore;
35
36print "1..10\n";
37
38$sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | S_IRWXG | S_IRWXO | IPC_CREAT)
39 || die "semget: ",$!+0," $!\n";
40
41print "ok 1\n";
42
43my $st = $sem->stat || print "not ";
44print "ok 2\n";
45
46$sem->setall( (0) x 10) || print "not ";
47print "ok 3\n";
48
49my @sem = $sem->getall;
50print "not " unless join("",@sem) eq "0000000000";
51print "ok 4\n";
52
53$sem[2] = 1;
54$sem->setall( @sem ) || print "not ";
55print "ok 5\n";
56
57@sem = $sem->getall;
58print "not " unless join("",@sem) eq "0010000000";
59print "ok 6\n";
60
61my $ncnt = $sem->getncnt(0);
62print "not " if $sem->getncnt(0) || !defined($ncnt);
63print "ok 7\n";
64
65$sem->op(2,-1,IPC_NOWAIT) || print "not ";
66print "ok 8\n";
67
68print "not " if $sem->getncnt(0);
69print "ok 9\n";
70
71$sem->remove || print "not ";
72print "ok 10\n";