1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-17 21:02:25 +02:00
Files
coreutils/tests/misc/invalid-opt
Pádraig Brady 265c4b83a8 new program: timeout
* AUTHORS: Register as the author.
* NEWS: Mention this change.
* README: Add timeout command to list.
* src/timeout.c: New file.
* src/kill.c (operand2sig): Move function to its own file,
now that timeout.c will also use it.
* src/operand2sig.c (operand2sig): New file, extracted from kill.c.
* src/operand2sig.h (operand2sig): Declare.
* src/Makefile.am (EXTRA_PROGRAMS): Add timeout.
* src/.gitignore: Add timeout binary to list to ignore.
* doc/coreutils.texi (timeout invocation): Add timeout info.
(Signal specifications): New section, also referenced by kill.
* man/Makefile.am (timeout.1): Add dependency.
* man/timeout.x: New file.
* po/POTFILES.in: Add timeout.c and operand2sig.c to list to translate.
* tests/Makefile.am (TESTS): Add the two new tests.
* tests/misc/help-version: Add support for new timeout command.
* tests/misc/invalid-opt: Add support for new timeout command.
* tests/misc/timeout: New file: check basic timeout operation.
* tests/misc/timeout-parameters: New file: check invalid parameter
combinations.
2008-06-02 14:40:26 +02:00

98 lines
2.3 KiB
Perl
Executable File

#!/usr/bin/perl
# exercise the 'invalid option' handling code in each program
# Copyright (C) 2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 5.003;
use strict;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
my %exit_status =
(
ls => 2,
dir => 2,
vdir => 2,
test => 2,
echo => 0,
expr => 0,
nohup => 127,
sort => 2,
test => 0,
timeout => 125,
true => 0,
tty => 2,
printf => 0,
printenv => 2,
);
my %expected_out =
(
echo => "-/\n",
expr => "-/\n",
printf => "-/",
);
my %expected_err =
(
false => '',
stty => '',
);
my $fail = 0;
my @built_programs = split ' ', $ENV{built_programs};
foreach my $prog (@built_programs)
{
$prog eq '['
and next;
my $try = "Try \`$prog --help' for more information.\n";
my $x = $exit_status{$prog};
defined $x
or $x = 1;
my $out = $expected_out{$prog};
defined $out
or $out = '';
my $err = $expected_err{$prog};
defined $err
or $err = $x == 0 ? '' : "$prog: invalid option -- /\n$try";
# Accommodate different syntax in glibc's getopt
# diagnostics by filtering out single quotes.
my $err_subst = "s,'/',/,";
# Depending on how this script is run, stty emits different
# diagnostics. Don't bother checking them.
$prog eq 'stty'
and $err_subst = 's/(.|\n)*//ms';
my @Tests = (["$prog-invalid-opt", '-/', {OUT=>$out},
{ERR_SUBST => $err_subst},
{EXIT=>$x}, {ERR=>$err}]);
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
my $f = run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose);
$f
and $fail = 1;
}
exit $fail;