File: kill_kill.t

package info (click to toggle)
libipc-run-perl 0.94-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 748 kB
  • sloc: perl: 5,750; makefile: 5
file content (60 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download | duplicates (4)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl

=pod

=head1 NAME

kill_kill.t - Test suite for IPC::Run->kill_kill

=cut

BEGIN { 
	$|  = 1;
	$^W = 1;
	if( $ENV{PERL_CORE} ) {
		chdir '../lib/IPC/Run' if -d '../lib/IPC/Run';
		unshift @INC, 'lib', '../..';
		$^X = '../../../t/' . $^X;
	}
}

use strict;
use Test::More;
use IPC::Run ();

# Don't run this test script on Windows at all
if ( IPC::Run::Win32_MODE() ) {
	plan( skip_all => 'Temporarily ignoring test failure on Win32' );
	exit(0);
} else {
	plan( tests    => 2 );
}

# Test 1
SCOPE: {
	my $h = IPC::Run::start( [
		$^X,
		'-e',
		'sleep while 1',
	] );

	my $needed = $h->kill_kill;
	ok( ! $needed, 'Did not need kill_kill' );
}

# Test 2
SKIP: {
	if ( IPC::Run::Win32_MODE() ) {
		skip("$^O does not support ignoring the TERM signal", 1);
	}

	my $out;
	my $h = IPC::Run::start( [
		$^X,
		'-e',
		'$SIG{TERM}=sub{};$|=1;print "running\n";sleep while 1',
	], \undef, \$out );
	pump $h until $out =~ /running/;
	my $needed = $h->kill_kill( grace => 1 );
	ok( $needed, 'Did not need kill_kill' );
}