File: lock.t

package info (click to toggle)
libio-all-perl 0.33-3.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 460 kB
  • ctags: 292
  • sloc: perl: 2,092; makefile: 46
file content (30 lines) | stat: -rw-r--r-- 557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use lib 't', 'lib';
use strict;
use warnings;
use Test::More;
use IO::All;
use IO_All_Test;

# XXX This needs to be fixed!!!
plan( $^O !~ /^(cygwin|solaris)$/
    ? (tests => 3)
    : (skip_all => "XXX - locking problems on solaris/cygwin")
);

my $io1 = io('t/output/foo')->lock;
$io1->println('line 1');

fork and do {
    my $io2 = io('t/output/foo')->lock;
    is($io2->getline, "line 1\n");
    is($io2->getline, "line 2\n");
    is($io2->getline, "line 3\n");
    exit;
};

sleep 1;
$io1->println('line 2');
$io1->println('line 3');
$io1->unlock;

1;