build: ensure make-prime-list doesn't access out of bounds memory
[platform/upstream/coreutils.git] / tests / misc / timeout-blocked.pl
1 #!/usr/bin/perl
2 # Test that timeout handles blocked SIGALRM from its parent.
3
4 # Copyright (C) 2013 Free Software Foundation, Inc.
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 use strict;
20
21 (my $ME = $0) =~ s|.*/||;
22
23 eval { require POSIX; };
24 $@
25   and CuSkip::skip "$ME: this script requires Perl's POSIX module\n";
26
27 use POSIX qw(:signal_h);
28 my $sigset = POSIX::SigSet->new(SIGALRM); # define the signals to block
29 my $old_sigset = POSIX::SigSet->new;      # where the old sigmask will be kept
30 unless (defined sigprocmask(SIG_BLOCK, $sigset, $old_sigset)) {
31   CuSkip::skip "$ME: sigprocmask failed; skipped";
32 }
33
34 my @Tests =
35     (
36      # test-name, [option, option, ...] {OUT=>"expected-output"}
37      #
38
39      ['block-alrm',  ".1 sleep 10", {EXIT => 124}],
40     );
41
42 my $save_temps = $ENV{DEBUG};
43 my $verbose = $ENV{VERBOSE};
44
45 my $prog = 'timeout';
46 my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);
47
48 exit $fail;