PHP  
 PHP_5_6
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/sysvsem/tests/nowait.phpt ('sem_acquire with nowait')

Script

1: <?php
2: $SEMKEY    
ftok(__FILE__'P');  //  Semaphore key
3:
4:
$pid pcntl_fork();
5:
6: if (
$pid) {
7:     echo 
"Parent.\n";
8:
9:     
pcntl_signal(SIGCHLDSIG_IGN);
10:
11:     
// Get semaphore
12:     
$sem_id sem_get($SEMKEY1);
13:     if (
$sem_id === FALSE) {
14:         echo 
"P: fail to get semaphore";
15:         exit;
16:     }
17:     echo 
"P: got semaphore $sem_id.\n";
18:
19:     
register_shutdown_function(function () use ($sem_id) {
20:         echo 
"P: cleanup.\n";
21:         
sem_remove($sem_id);
22:     });
23:   
24:     
// Acquire semaphore
25:     
if (! sem_acquire($sem_id)) {
26:         echo 
"P: fail to acquire semaphore $sem_id.\n";
27:         
sem_remove($sem_id);
28:         exit;
29:     }
30:     echo 
"P: success acquire semaphore $sem_id.\n";
31:
32:     
usleep(20000);
33:
34:     echo 
"P: releases.\n";
35:     
sem_release($sem_id);
36:
37:     
usleep(5000);
38:
39:     
// Acquire semaphore
40:     
if (! sem_acquire($sem_id)) {
41:         echo 
"P: fail to acquire semaphore $sem_id.\n";
42:         
sem_remove($sem_id);
43:         exit;
44:     }
45:     echo 
"P: success acquire semaphore $sem_id.\n";
46:
47:     
$status null;
48:     
pcntl_waitpid($pid$status);
49:
50: } else {
51:     
usleep(10000);
52:     echo 
"Child.\n";
53:
54:     
// Get semaphore
55:     
$sem_id sem_get($SEMKEY1);
56:     if (
$sem_id === FALSE) {
57:         echo 
"C: fail to get semaphore";
58:         exit;
59:     }
60:     echo 
"C: got semaphore $sem_id.\n";
61:   
62:     
// Acquire semaphore
63:     
if (! sem_acquire($sem_id)) {
64:         echo 
"C: fail to acquire semaphore $sem_id.\n";
65:         exit;
66:     }
67:     echo 
"C: success acquire semaphore $sem_id.\n";
68:
69:     echo 
"C: releases.\n";
70:     
sem_release($sem_id);
71:
72:     
usleep(10000);
73:
74:     
// Acquire semaphore
75:     
if (! sem_acquire($sem_idtrue)) {
76:         echo 
"C: fail to acquire semaphore $sem_id.\n";
77:         exit;
78:     }
79:     echo 
"C: success acquire semaphore $sem_id.\n";
80: }
81:
82:
?>
83:

Expected

Parent.
P: got semaphore Resource id #%i.
P: success acquire semaphore Resource id #%i.
Child.
C: got semaphore Resource id #%i.
P: releases.
C: success acquire semaphore Resource id #%i.
C: releases.
P: success acquire semaphore Resource id #%i.
C: fail to acquire semaphore Resource id #%i.
P: cleanup.

Output

Parent.
Child.
P: got semaphore Resource id #4.
C: got semaphore Resource id #4.
C: success acquire semaphore Resource id #4.
C: releases.
C: success acquire semaphore Resource id #4.
P: success acquire semaphore Resource id #4.
P: releases.
P: success acquire semaphore Resource id #4.
P: cleanup.

Diff

002+ Child.
003- P: success acquire semaphore Resource id #%i.
004- Child.
006- P: releases.
007+ C: success acquire semaphore Resource id #4.
009+ P: releases.
010+ P: success acquire semaphore Resource id #4.
010- C: fail to acquire semaphore Resource id #%i.

 

Generated at Mon, 27 Nov 2017 05:04:32 +0000 (15 days ago)

Copyright © 2005-2017 The PHP Group
All rights reserved.