mtr_cases.pl
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PL 代码 · 共 682 行 · 第 1/2 页
PL
682 行
foreach my $opt ( @$master_opt ) { my $value; # The opt file is used both to send special options to the mysqld # as well as pass special test case specific options to this # script $value= mtr_match_prefix($opt, "--timezone="); if ( defined $value ) { $tinfo->{'timezone'}= $value; next; } $value= mtr_match_prefix($opt, "--slave-num="); if ( defined $value ) { $tinfo->{'slave_num'}= $value; next; } $value= mtr_match_prefix($opt, "--result-file="); if ( defined $value ) { # Specifies the file mysqltest should compare # output against $tinfo->{'result_file'}= "r/$value.result"; next; } # If we set default time zone, remove the one we have $value= mtr_match_prefix($opt, "--default-time-zone="); if ( defined $value ) { # Set timezone for this test case to something different $tinfo->{'timezone'}= "GMT-8"; # Fallthrough, add the --default-time-zone option } # The --restart option forces a restart even if no special # option is set. If the options are the same as next testcase # there is no need to restart after the testcase # has completed if ( $opt eq "--force-restart" ) { $tinfo->{'force_restart'}= 1; next; } # Ok, this was a real option, add it push(@{$tinfo->{'master_opt'}}, $opt); } } if ( -f $slave_opt_file ) { my $slave_opt= mtr_get_opts_from_file($slave_opt_file); foreach my $opt ( @$slave_opt ) { # If we set default time zone, remove the one we have my $value= mtr_match_prefix($opt, "--default-time-zone="); $tinfo->{'slave_opt'}= [] if defined $value; } push(@{$tinfo->{'slave_opt'}}, @$slave_opt); } if ( -f $slave_mi_file ) { $tinfo->{'slave_mi'}= mtr_get_opts_from_file($slave_mi_file); } if ( -f $master_sh ) { if ( $::glob_win32_perl ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No tests with sh scripts on Windows"; return; } else { $tinfo->{'master_sh'}= $master_sh; } } if ( -f $slave_sh ) { if ( $::glob_win32_perl ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No tests with sh scripts on Windows"; return; } else { $tinfo->{'slave_sh'}= $slave_sh; } } if ( -f $im_opt_file ) { $tinfo->{'im_opts'} = mtr_get_opts_from_file($im_opt_file); } else { $tinfo->{'im_opts'} = []; } # FIXME why this late? my $marked_as_disabled= 0; if ( $disabled->{$tname} ) { $marked_as_disabled= 1; $tinfo->{'comment'}= $disabled->{$tname}; } if ( -f $disabled_file ) { $marked_as_disabled= 1; $tinfo->{'comment'}= mtr_fromfile($disabled_file); } # If test was marked as disabled, either opt_enable_disabled is off and then # we skip this test, or it is on and then we run this test but warn if ( $marked_as_disabled ) { if ( $::opt_enable_disabled ) { $tinfo->{'dont_skip_though_disabled'}= 1; } else { $tinfo->{'skip'}= 1; $tinfo->{'disable'}= 1; # Sub type of 'skip' return; } } if ( $component_id eq 'im' ) { if ( $::glob_use_embedded_server ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No IM with embedded server"; return; } elsif ( $::opt_ps_protocol ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No IM with --ps-protocol"; return; } elsif ( $::opt_skip_im ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No IM tests(--skip-im)"; return; } } else { mtr_options_from_test_file($tinfo,"$testdir/${tname}.test"); if ( defined $::used_default_engine ) { # Different default engine is used # tag test to require that engine $tinfo->{'ndb_test'}= 1 if ( $::used_default_engine =~ /^ndb/i ); $tinfo->{'innodb_test'}= 1 if ( $::used_default_engine =~ /^innodb/i ); } if ( $tinfo->{'big_test'} and ! $::opt_big_test ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "Test need 'big-test' option"; return; } if ( $tinfo->{'ndb_extra'} and ! $::opt_ndb_extra_test ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "Test need 'ndb_extra' option"; return; } if ( $tinfo->{'require_manager'} ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "Test need the _old_ manager(to be removed)"; return; } if ( defined $tinfo->{'binlog_format'} and ! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "Not running with binlog format '$tinfo->{'binlog_format'}'"; return; } if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "Test need debug binaries"; return; } if ( $tinfo->{'ndb_test'} ) { # This is a NDB test if ( ! $::glob_ndbcluster_supported ) { # Ndb is not supported, skip it $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No ndbcluster support"; return; } elsif ( $::opt_skip_ndbcluster ) { # All ndb test's should be skipped $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No ndbcluster tests(--skip-ndbcluster)"; return; } # Ndb tests run with two mysqld masters $tinfo->{'master_num'}= 2; } else { # This is not a ndb test if ( $::opt_with_ndbcluster_only ) { # Only the ndb test should be run, all other should be skipped $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "Only ndbcluster tests(--with-ndbcluster-only)"; return; } } if ( $tinfo->{'innodb_test'} ) { # This is a test that need innodb if ( $::mysqld_variables{'innodb'} eq "FALSE" ) { # innodb is not supported, skip it $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "No innodb support"; return; } } if ( $tinfo->{'need_binlog'} ) { if (grep(/^--skip-log-bin/, @::opt_extra_mysqld_opt) ) { $tinfo->{'skip'}= 1; $tinfo->{'comment'}= "Test need binlog"; return; } } else { if ( $::mysql_version_id >= 50100 ) { # Test does not need binlog, add --skip-binlog to # the options used when starting it push(@{$tinfo->{'master_opt'}}, "--skip-log-bin"); } } }}# List of tags in the .test files that if found should set# the specified value in "tinfo"our @tags=( ["include/have_innodb.inc", "innodb_test", 1], ["include/have_binlog_format_row.inc", "binlog_format", "row"], ["include/have_binlog_format_statement.inc", "binlog_format", "stmt"], ["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"], ["include/have_log_bin.inc", "need_binlog", 1], ["include/big_test.inc", "big_test", 1], ["include/have_debug.inc", "need_debug", 1], ["include/have_ndb.inc", "ndb_test", 1], ["include/have_ndb_extra.inc", "ndb_extra", 1], ["require_manager", "require_manager", 1],);sub mtr_options_from_test_file($$) { my $tinfo= shift; my $file= shift; #mtr_verbose("$file"); my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!"); while ( my $line= <$F> ) { # Skip line if it start's with # next if ( $line =~ /^#/ ); # Match this line against tag in "tags" array foreach my $tag (@tags) { if ( index($line, $tag->[0]) >= 0 ) { # Tag matched, assign value to "tinfo" $tinfo->{"$tag->[1]"}= $tag->[2]; } } # If test sources another file, open it as well if ( $line =~ /^\-\-([[:space:]]*)source(.*)$/ or $line =~ /^([[:space:]]*)source(.*);$/ ) { my $value= $2; $value =~ s/^\s+//; # Remove leading space $value =~ s/[[:space:]]+$//; # Remove ending space my $sourced_file= "$::glob_mysql_test_dir/$value"; if ( -f $sourced_file ) { # Only source the file if it exists, we may get # false positives in the regexes above if someone # writes "source nnnn;" in a test case(such as mysqltest.test) mtr_options_from_test_file($tinfo, $sourced_file); } } }}1;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?