Skip to content

Commit 1bdcffb

Browse files
committed
MDEV-29025 Refactoring: moved out core_wanted() out of mysql-test-run.pl
1 parent e9be542 commit 1bdcffb

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

mysql-test/lib/My/CoreDump.pm

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ use Text::Wrap;
2323
use Data::Dumper;
2424

2525
use File::Temp qw/ tempfile tempdir /;
26+
use File::Find;
27+
use File::Basename;
2628
use mtr_results;
2729
use mtr_report;
2830

@@ -489,7 +491,7 @@ sub _auto
489491

490492

491493
sub show {
492-
my ($class, $core_name, $exe_mysqld, $parallel)= @_;
494+
my ($core_name, $exe_mysqld, $parallel)= @_;
493495
if ($config{print_core} ne 'no') {
494496
my $f= $config{print_core};
495497
my $m= $config{print_method};
@@ -506,4 +508,36 @@ sub show {
506508
}
507509

508510

511+
sub core_wanted($$$$$) {
512+
my ($num_saved_cores, $opt_max_save_core, $compress,
513+
$exe_mysqld, $opt_parallel)= @_;
514+
my $core_file= $File::Find::name;
515+
my $core_name= basename($core_file);
516+
517+
# Name beginning with core, not ending in .gz
518+
if (($core_name =~ /^core/ and $core_name !~ /\.gz$/)
519+
or (IS_WINDOWS and $core_name =~ /\.dmp$/))
520+
{
521+
# Ending with .dmp
522+
mtr_report(" - found '$core_name'",
523+
"($$num_saved_cores/$opt_max_save_core)");
524+
525+
show($core_file, $exe_mysqld, $opt_parallel);
526+
527+
# Limit number of core files saved
528+
if ($$num_saved_cores >= $opt_max_save_core)
529+
{
530+
mtr_report(" - deleting it, already saved",
531+
"$opt_max_save_core");
532+
unlink("$core_file");
533+
}
534+
else
535+
{
536+
main::mtr_compress_file($core_file) if $compress;
537+
++$$num_saved_cores;
538+
}
539+
}
540+
}
541+
542+
509543
1;

mysql-test/mysql-test-run.pl

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -801,32 +801,10 @@ ($$$)
801801
no_chdir => 1,
802802
wanted => sub
803803
{
804-
my $core_file= $File::Find::name;
805-
my $core_name= basename($core_file);
806-
807-
# Name beginning with core, not ending in .gz
808-
if (($core_name =~ /^core/ and $core_name !~ /\.gz$/)
809-
or (IS_WINDOWS and $core_name =~ /\.dmp$/))
810-
{
811-
# Ending with .dmp
812-
mtr_report(" - found '$core_name'",
813-
"($num_saved_cores/$opt_max_save_core)");
814-
815-
My::CoreDump->show($core_file, $exe_mysqld, $opt_parallel);
816-
817-
# Limit number of core files saved
818-
if ($num_saved_cores >= $opt_max_save_core)
819-
{
820-
mtr_report(" - deleting it, already saved",
821-
"$opt_max_save_core");
822-
unlink("$core_file");
823-
}
824-
else
825-
{
826-
mtr_compress_file($core_file) unless @opt_cases;
827-
++$num_saved_cores;
828-
}
829-
}
804+
My::CoreDump::core_wanted(\$num_saved_cores,
805+
$opt_max_save_core,
806+
@opt_cases == 0,
807+
$exe_mysqld, $opt_parallel);
830808
}
831809
},
832810
$worker_savedir);

0 commit comments

Comments
 (0)