diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2022-07-18 23:16:17 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2022-07-18 23:16:17 +0300 |
commit | 1bdcffb02801df880a63a6ced7c87bf70ee1886f (patch) | |
tree | e855429ef4f270c3cfb120bc5384e026a9066aac /mysql-test | |
parent | e9be5428a27eaaccf142f2bd53f4d30e8e368484 (diff) | |
download | mariadb-git-1bdcffb02801df880a63a6ced7c87bf70ee1886f.tar.gz |
MDEV-29025 Refactoring: moved out core_wanted() out of mysql-test-run.pl
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/lib/My/CoreDump.pm | 36 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 30 |
2 files changed, 39 insertions, 27 deletions
diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm index 3b61f20ef24..298cf9ef877 100644 --- a/mysql-test/lib/My/CoreDump.pm +++ b/mysql-test/lib/My/CoreDump.pm @@ -23,6 +23,8 @@ use Text::Wrap; use Data::Dumper; use File::Temp qw/ tempfile tempdir /; +use File::Find; +use File::Basename; use mtr_results; use mtr_report; @@ -489,7 +491,7 @@ sub _auto sub show { - my ($class, $core_name, $exe_mysqld, $parallel)= @_; + my ($core_name, $exe_mysqld, $parallel)= @_; if ($config{print_core} ne 'no') { my $f= $config{print_core}; my $m= $config{print_method}; @@ -506,4 +508,36 @@ sub show { } +sub core_wanted($$$$$) { + my ($num_saved_cores, $opt_max_save_core, $compress, + $exe_mysqld, $opt_parallel)= @_; + my $core_file= $File::Find::name; + my $core_name= basename($core_file); + + # Name beginning with core, not ending in .gz + if (($core_name =~ /^core/ and $core_name !~ /\.gz$/) + or (IS_WINDOWS and $core_name =~ /\.dmp$/)) + { + # Ending with .dmp + mtr_report(" - found '$core_name'", + "($$num_saved_cores/$opt_max_save_core)"); + + show($core_file, $exe_mysqld, $opt_parallel); + + # Limit number of core files saved + if ($$num_saved_cores >= $opt_max_save_core) + { + mtr_report(" - deleting it, already saved", + "$opt_max_save_core"); + unlink("$core_file"); + } + else + { + main::mtr_compress_file($core_file) if $compress; + ++$$num_saved_cores; + } + } +} + + 1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index adb1bc4914b..f9e9c34c566 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -801,32 +801,10 @@ sub run_test_server ($$$) { no_chdir => 1, wanted => sub { - my $core_file= $File::Find::name; - my $core_name= basename($core_file); - - # Name beginning with core, not ending in .gz - if (($core_name =~ /^core/ and $core_name !~ /\.gz$/) - or (IS_WINDOWS and $core_name =~ /\.dmp$/)) - { - # Ending with .dmp - mtr_report(" - found '$core_name'", - "($num_saved_cores/$opt_max_save_core)"); - - My::CoreDump->show($core_file, $exe_mysqld, $opt_parallel); - - # Limit number of core files saved - if ($num_saved_cores >= $opt_max_save_core) - { - mtr_report(" - deleting it, already saved", - "$opt_max_save_core"); - unlink("$core_file"); - } - else - { - mtr_compress_file($core_file) unless @opt_cases; - ++$num_saved_cores; - } - } + My::CoreDump::core_wanted(\$num_saved_cores, + $opt_max_save_core, + @opt_cases == 0, + $exe_mysqld, $opt_parallel); } }, $worker_savedir); |