forked from RexOps/Rex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_buffers.t
executable file
·43 lines (30 loc) · 951 Bytes
/
read_buffers.t
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
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env perl
use v5.12.5;
use warnings;
our $VERSION = '9999.99.99_99'; # VERSION
use Test::More;
if ( $^O =~ m/^MSWin/i ) {
plan tests => 1;
}
else {
plan tests => 2;
}
use Rex::Interface::Exec;
my $tty = $^O =~ m/^MSWin/i ? 0 : 1;
Rex::Config->set_no_tty($tty);
my $exec = Rex::Interface::Exec->create;
my $command =
( $^O =~ m/^MSWin/i && Rex::is_local() )
? qq{perl -e "my \$count = 500_000; while ( \$count-- ) { if ( \$count % 2) { print STDERR 'x'} else { print STDOUT 'x'} }"}
: qq{perl -e 'my \$count = 500_000; while ( \$count-- ) { if ( \$count % 2) { print STDERR "x"} else { print STDOUT "x"} }'};
alarm 30;
$SIG{ALRM} = sub { BAIL_OUT 'Reading from buffer timed out'; };
my ( $out, $err ) = $exec->exec($command);
alarm 0;
if ( $^O =~ m/^MSWin/i ) {
is length($out), 500_000, 'output length on Windows';
}
else {
is length($out), 250_000, 'STDOUT length';
is length($err), 250_000, 'STDERR length';
}