Commit ce7820eb authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-28931 --verbose option is too verbose

GetOpt::Long bundling option for convenient one-char verbosity levels:

  -v    General verbosity (file and execute operations)
  -vv   High verbosity (algorithmic considerations)
  -vvv  Debug verbosity (anything else)
parent 83f7d25c
...@@ -87,7 +87,7 @@ sub init_pattern { ...@@ -87,7 +87,7 @@ sub init_pattern {
# separator betwen suite and testname), make the pattern match # separator betwen suite and testname), make the pattern match
# beginning of string # beginning of string
$from= "^$from"; $from= "^$from";
mtr_verbose("$what='$from'"); mtr_verbose2("$what='$from'");
} }
# Check that pattern is a valid regex # Check that pattern is a valid regex
eval { "" =~/$from/; 1 } or eval { "" =~/$from/; 1 } or
...@@ -292,7 +292,7 @@ sub combinations_from_file($$) ...@@ -292,7 +292,7 @@ sub combinations_from_file($$)
} else { } else {
return () if @::opt_combinations or not -f $filename; return () if @::opt_combinations or not -f $filename;
# Read combinations file in my.cnf format # Read combinations file in my.cnf format
mtr_verbose("Read combinations file $filename"); mtr_verbose2("Read combinations file $filename");
my $config= My::Config->new($filename); my $config= My::Config->new($filename);
foreach my $group ($config->option_groups()) { foreach my $group ($config->option_groups()) {
my $comb= { name => $group->name(), comb_opt => [] }; my $comb= { name => $group->name(), comb_opt => [] };
...@@ -426,9 +426,9 @@ sub collect_suite_name($$) ...@@ -426,9 +426,9 @@ sub collect_suite_name($$)
sub collect_one_suite { sub collect_one_suite {
my ($opt_cases, $suitename, $over, $suitedir, @overlays) = @_; my ($opt_cases, $suitename, $over, $suitedir, @overlays) = @_;
mtr_verbose("Collecting: $suitename"); mtr_verbose2("Collecting: $suitename");
mtr_verbose("suitedir: $suitedir"); mtr_verbose2("suitedir: $suitedir");
mtr_verbose("overlays: @overlays") if @overlays; mtr_verbose2("overlays: @overlays") if @overlays;
# we always need to process the parent suite, even if we won't use any # we always need to process the parent suite, even if we won't use any
# test from it. # test from it.
...@@ -500,8 +500,8 @@ sub process_suite { ...@@ -500,8 +500,8 @@ sub process_suite {
$suite->{rdir} = -d $rdir ? $rdir : $suite->{tdir}; $suite->{rdir} = -d $rdir ? $rdir : $suite->{tdir};
} }
mtr_verbose("testdir: " . $suite->{tdir}); mtr_verbose2("testdir: " . $suite->{tdir});
mtr_verbose( "resdir: " . $suite->{rdir}); mtr_verbose2( "resdir: " . $suite->{rdir});
# disabled.def # disabled.def
parse_disabled($suite->{dir} .'/disabled.def', $suitename); parse_disabled($suite->{dir} .'/disabled.def', $suitename);
...@@ -511,7 +511,7 @@ sub process_suite { ...@@ -511,7 +511,7 @@ sub process_suite {
if (@::opt_combinations) if (@::opt_combinations)
{ {
# take the combination from command-line # take the combination from command-line
mtr_verbose("Take the combination from command line"); mtr_verbose2("Take the combination from command line");
foreach my $combination (@::opt_combinations) { foreach my $combination (@::opt_combinations) {
my $comb= {}; my $comb= {};
$comb->{name}= $combination; $comb->{name}= $combination;
......
...@@ -46,7 +46,7 @@ sub mtr_ping_port ($); ...@@ -46,7 +46,7 @@ sub mtr_ping_port ($);
sub mtr_ping_port ($) { sub mtr_ping_port ($) {
my $port= shift; my $port= shift;
mtr_verbose("mtr_ping_port: $port"); mtr_verbose2("mtr_ping_port: $port");
if (IS_WINDOWS && USE_NETPING) if (IS_WINDOWS && USE_NETPING)
{ {
...@@ -56,12 +56,12 @@ sub mtr_ping_port ($) { ...@@ -56,12 +56,12 @@ sub mtr_ping_port ($) {
$ping->port_number($port); $ping->port_number($port);
if ($ping->ping("localhost",0.1)) if ($ping->ping("localhost",0.1))
{ {
mtr_verbose("USED"); mtr_verbose2("USED");
return 1; return 1;
} }
else else
{ {
mtr_verbose("FREE"); mtr_verbose2("FREE");
return 0; return 0;
} }
} }
...@@ -84,12 +84,12 @@ sub mtr_ping_port ($) { ...@@ -84,12 +84,12 @@ sub mtr_ping_port ($) {
if ( connect(SOCK, $paddr) ) if ( connect(SOCK, $paddr) )
{ {
close(SOCK); # FIXME check error? close(SOCK); # FIXME check error?
mtr_verbose("USED"); mtr_verbose2("USED");
return 1; return 1;
} }
else else
{ {
mtr_verbose("FREE"); mtr_verbose2("FREE");
return 0; return 0;
} }
} }
......
...@@ -27,7 +27,7 @@ use Sys::Hostname; ...@@ -27,7 +27,7 @@ use Sys::Hostname;
use base qw(Exporter); use base qw(Exporter);
our @EXPORT= qw(report_option mtr_print_line mtr_print_thick_line our @EXPORT= qw(report_option mtr_print_line mtr_print_thick_line
mtr_print_header mtr_report mtr_report_stats mtr_print_header mtr_report mtr_report_stats
mtr_warning mtr_error mtr_debug mtr_verbose mtr_warning mtr_error mtr_debug mtr_verbose mtr_verbose2
mtr_verbose_restart mtr_report_test_passed mtr_verbose_restart mtr_report_test_passed
mtr_report_test_skipped mtr_print mtr_report_test_skipped mtr_print
mtr_report_test isotime); mtr_report_test isotime);
...@@ -716,6 +716,15 @@ sub mtr_verbose (@) { ...@@ -716,6 +716,15 @@ sub mtr_verbose (@) {
} }
sub mtr_verbose2 (@) {
if ( $verbose > 1 )
{
print STDERR _name(). _timestamp().
"> ".join(" ", @_)."\n";
}
}
sub mtr_verbose_restart (@) { sub mtr_verbose_restart (@) {
my ($server, @args)= @_; my ($server, @args)= @_;
my $proc= $server->{proc}; my $proc= $server->{proc};
......
...@@ -126,19 +126,19 @@ sub collect_test_cases ($) { ...@@ -126,19 +126,19 @@ sub collect_test_cases ($) {
{ {
my $base_name= $1; my $base_name= $1;
my $idx= $2; my $idx= $2;
mtr_verbose("$test_name => $base_name idx=$idx"); mtr_verbose2("$test_name => $base_name idx=$idx");
if ( $idx > 1 ) if ( $idx > 1 )
{ {
$idx-= 1; $idx-= 1;
$base_name= "$base_name$idx"; $base_name= "$base_name$idx";
mtr_verbose("New basename $base_name"); mtr_verbose2("New basename $base_name");
} }
foreach my $tinfo2 (@$cases) foreach my $tinfo2 (@$cases)
{ {
if ( $tinfo2->{'name'} eq $base_name ) if ( $tinfo2->{'name'} eq $base_name )
{ {
mtr_verbose("found dependent test $tinfo2->{'name'}"); mtr_verbose2("found dependent test $tinfo2->{'name'}");
$depend_on_test_name=$base_name; $depend_on_test_name=$base_name;
} }
} }
...@@ -146,7 +146,7 @@ sub collect_test_cases ($) { ...@@ -146,7 +146,7 @@ sub collect_test_cases ($) {
if ( defined $depend_on_test_name ) if ( defined $depend_on_test_name )
{ {
mtr_verbose("Giving $test_name same critera as $depend_on_test_name"); mtr_verbose2("Giving $test_name same critera as $depend_on_test_name");
$sort_criteria{$test_name} = $sort_criteria{$depend_on_test_name}; $sort_criteria{$test_name} = $sort_criteria{$depend_on_test_name};
} }
else else
...@@ -224,14 +224,14 @@ sub collect_one_suite($) ...@@ -224,14 +224,14 @@ sub collect_one_suite($)
my $suite= shift; # Test suite name my $suite= shift; # Test suite name
my @cases; # Array of hash my @cases; # Array of hash
mtr_verbose("Collecting: $suite"); mtr_verbose2("Collecting: $suite");
my $suitedir= "$::glob_mysql_test_dir"; # Default my $suitedir= "$::glob_mysql_test_dir"; # Default
if ( $suite ne "main" ) if ( $suite ne "main" )
{ {
$suitedir= mtr_path_exists("$suitedir/suite/$suite", $suitedir= mtr_path_exists("$suitedir/suite/$suite",
"$suitedir/$suite"); "$suitedir/$suite");
mtr_verbose("suitedir: $suitedir"); mtr_verbose2("suitedir: $suitedir");
} }
my $testdir= "$suitedir/t"; my $testdir= "$suitedir/t";
...@@ -363,7 +363,7 @@ sub collect_one_suite($) ...@@ -363,7 +363,7 @@ sub collect_one_suite($)
if (@::opt_combinations) if (@::opt_combinations)
{ {
# take the combination from command-line # take the combination from command-line
mtr_verbose("Take the combination from command line"); mtr_verbose2("Take the combination from command line");
foreach my $combination (@::opt_combinations) { foreach my $combination (@::opt_combinations) {
my $comb= {}; my $comb= {};
$comb->{name}= $combination; $comb->{name}= $combination;
...@@ -374,7 +374,7 @@ sub collect_one_suite($) ...@@ -374,7 +374,7 @@ sub collect_one_suite($)
elsif (-f $combination_file ) elsif (-f $combination_file )
{ {
# Read combinations file in my.cnf format # Read combinations file in my.cnf format
mtr_verbose("Read combinations file"); mtr_verbose2("Read combinations file");
my $config= My::Config->new($combination_file); my $config= My::Config->new($combination_file);
foreach my $group ($config->groups()) { foreach my $group ($config->groups()) {
...@@ -605,7 +605,7 @@ sub collect_one_test_case($$$$$$$$$) { ...@@ -605,7 +605,7 @@ sub collect_one_test_case($$$$$$$$$) {
# Add suite opts # Add suite opts
foreach my $opt ( @$suite_opts ) foreach my $opt ( @$suite_opts )
{ {
mtr_verbose($opt); mtr_verbose2($opt);
push(@{$tinfo->{'master_opt'}}, $opt); push(@{$tinfo->{'master_opt'}}, $opt);
push(@{$tinfo->{'slave_opt'}}, $opt); push(@{$tinfo->{'slave_opt'}}, $opt);
} }
......
...@@ -80,7 +80,7 @@ sub mtr_timer_start($$$) { ...@@ -80,7 +80,7 @@ sub mtr_timer_start($$$) {
if ( $tpid ) if ( $tpid )
{ {
# Parent, record the information # Parent, record the information
mtr_verbose("Starting timer for '$name',", mtr_verbose2("Starting timer for '$name',",
"duration: $duration, pid: $tpid"); "duration: $duration, pid: $tpid");
$timers->{'timers'}->{$name}->{'pid'}= $tpid; $timers->{'timers'}->{$name}->{'pid'}= $tpid;
$timers->{'timers'}->{$name}->{'duration'}= $duration; $timers->{'timers'}->{$name}->{'duration'}= $duration;
...@@ -96,13 +96,13 @@ sub mtr_timer_start($$$) { ...@@ -96,13 +96,13 @@ sub mtr_timer_start($$$) {
$SIG{INT}= 'DEFAULT'; $SIG{INT}= 'DEFAULT';
$SIG{TERM}= sub { $SIG{TERM}= sub {
mtr_verbose("timer $$ woke up, exiting!"); mtr_verbose2("timer $$ woke up, exiting!");
exit(0); exit(0);
}; };
$0= "mtr_timer(timers,$name,$duration)"; $0= "mtr_timer(timers,$name,$duration)";
sleep($duration); sleep($duration);
mtr_verbose("timer $$ expired after $duration seconds"); mtr_verbose2("timer $$ expired after $duration seconds");
exit(0); exit(0);
} }
} }
......
...@@ -78,7 +78,7 @@ use lib "lib"; ...@@ -78,7 +78,7 @@ use lib "lib";
use Cwd ; use Cwd ;
use Cwd 'realpath'; use Cwd 'realpath';
use Getopt::Long; use Getopt::Long qw(:config bundling);
use My::File::Path; # Patched version of File::Path use My::File::Path; # Patched version of File::Path
use File::Basename; use File::Basename;
use File::Copy; use File::Copy;
...@@ -758,7 +758,7 @@ sub run_test_server ($$$) { ...@@ -758,7 +758,7 @@ sub run_test_server ($$$) {
if ($sock == $server) { if ($sock == $server) {
# New client connected # New client connected
my $child= $sock->accept(); my $child= $sock->accept();
mtr_verbose("Client connected"); mtr_verbose2("Client connected");
$s->add($child); $s->add($child);
print $child "HELLO\n"; print $child "HELLO\n";
} }
...@@ -766,7 +766,7 @@ sub run_test_server ($$$) { ...@@ -766,7 +766,7 @@ sub run_test_server ($$$) {
my $line= <$sock>; my $line= <$sock>;
if (!defined $line) { if (!defined $line) {
# Client disconnected # Client disconnected
mtr_verbose("Child closed socket"); mtr_verbose2("Child closed socket");
$s->remove($sock); $s->remove($sock);
$sock->close; $sock->close;
if (--$childs == 0){ if (--$childs == 0){
...@@ -1311,7 +1311,7 @@ sub command_line_setup { ...@@ -1311,7 +1311,7 @@ sub command_line_setup {
'force-restart' => \$opt_force_restart, 'force-restart' => \$opt_force_restart,
'reorder!' => \$opt_reorder, 'reorder!' => \$opt_reorder,
'enable-disabled' => \&collect_option, 'enable-disabled' => \&collect_option,
'verbose+' => \$opt_verbose, 'verbose|v+' => \$opt_verbose,
'verbose-restart' => \&report_option, 'verbose-restart' => \&report_option,
'sleep=i' => \$opt_sleep, 'sleep=i' => \$opt_sleep,
'start-dirty' => \$opt_start_dirty, 'start-dirty' => \$opt_start_dirty,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment