mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-02-27 02:00:57 +08:00
PT-2503 - pt-eustack-resolver does not have --version option
- Cleaned warnings seen before - Added test case
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
# notices and disclaimers.
|
# notices and disclaimers.
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
#use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
|
|
||||||
# This tool is "fat-packed": most of its dependent modules are embedded
|
# This tool is "fat-packed": most of its dependent modules are embedded
|
||||||
# in this file. Setting %INC to this file for each module makes Perl aware
|
# in this file. Setting %INC to this file for each module makes Perl aware
|
||||||
@@ -1247,7 +1247,6 @@ if ( PTDEBUG ) {
|
|||||||
# End OptionParser package
|
# End OptionParser package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# This is a combination of modules and programs in one -- a runnable module.
|
# This is a combination of modules and programs in one -- a runnable module.
|
||||||
# http://www.perl.com/pub/a/2006/07/13/lightning-articles.html?page=last
|
# http://www.perl.com/pub/a/2006/07/13/lightning-articles.html?page=last
|
||||||
@@ -1259,7 +1258,10 @@ if ( PTDEBUG ) {
|
|||||||
package pt_eu_stack_resolver;
|
package pt_eu_stack_resolver;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
#use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
|
# We have to disable warnings here because Perl prints
|
||||||
|
# warnings for numbers greater than 2^32.
|
||||||
|
no warnings 'portable';
|
||||||
|
|
||||||
use Percona::Toolkit;
|
use Percona::Toolkit;
|
||||||
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||||
@@ -1370,7 +1372,7 @@ sub load_mapping {
|
|||||||
push @$arr, { S => hex($1), E => hex($2), B => hex($3), F => $4 };
|
push @$arr, { S => hex($1), E => hex($2), B => hex($3), F => $4 };
|
||||||
}
|
}
|
||||||
close $FH;
|
close $FH;
|
||||||
sort { $a->{S} <=> $b->{S} } @$arr;
|
@$arr = sort { $a->{S} <=> $b->{S} } @$arr;
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1414,7 +1416,7 @@ and resolve symbols.
|
|||||||
|
|
||||||
Usage: pt-eustack-resolver PID
|
Usage: pt-eustack-resolver PID
|
||||||
|
|
||||||
pt-eustack-resolver collects stack traces for the process with specified C<pid>.
|
pt-eustack-resolver collects stack traces for the process with specified C<PID>.
|
||||||
|
|
||||||
=head1 RISKS
|
=head1 RISKS
|
||||||
|
|
||||||
@@ -1463,7 +1465,6 @@ Show help and exit.
|
|||||||
|
|
||||||
Show version and exit.
|
Show version and exit.
|
||||||
|
|
||||||
|
|
||||||
=head1 ATTENTION
|
=head1 ATTENTION
|
||||||
|
|
||||||
Using <PTDEBUG> might expose passwords. When debug is enabled, all command line
|
Using <PTDEBUG> might expose passwords. When debug is enabled, all command line
|
||||||
|
|||||||
70
t/pt-eustack-resolver/option_sanity.t
Normal file
70
t/pt-eustack-resolver/option_sanity.t
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||||
|
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||||
|
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||||
|
};
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings FATAL => 'all';
|
||||||
|
use English qw(-no_match_vars);
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
use PerconaTest;
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# We only check basic option sanity here. It is hard to create tests for the
|
||||||
|
# eu-stack output that work in all environments. So we will simply check that
|
||||||
|
# the help and version options work as expected.
|
||||||
|
# ############################################################################
|
||||||
|
|
||||||
|
my $output = `$trunk/bin/pt-eustack-resolver --help`;
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/^\s+--help\s+Show help and exit/m,
|
||||||
|
"--help option is documented"
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/^\s+--version\s+Show version and exit/m,
|
||||||
|
"--version option is documented"
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/Options and values after processing arguments:/m,
|
||||||
|
"Help output contains expected section"
|
||||||
|
);
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Check error when no arguments are provided
|
||||||
|
# ############################################################################
|
||||||
|
my $error_output = `$trunk/bin/pt-eustack-resolver 2>&1`;
|
||||||
|
|
||||||
|
like(
|
||||||
|
$error_output,
|
||||||
|
qr/A PID must be specified/m,
|
||||||
|
"Error message shown when no PID is provided"
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$error_output,
|
||||||
|
qr/Usage: pt-eustack-resolver PID/m,
|
||||||
|
"Usage line shown in error"
|
||||||
|
);
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Check --version option
|
||||||
|
# ############################################################################
|
||||||
|
my $version_output = `$trunk/bin/pt-eustack-resolver --version`;
|
||||||
|
|
||||||
|
like(
|
||||||
|
$version_output,
|
||||||
|
qr/pt-eustack-resolver \d+\.\d+\.\d+(?:-\d+)?/m,
|
||||||
|
"--version shows tool name and version"
|
||||||
|
);
|
||||||
|
|
||||||
|
done_testing;
|
||||||
Reference in New Issue
Block a user