mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Merge branch '10.6' into 10.11
This commit is contained in:
30
mysql-test/include/read_head.inc
Normal file
30
mysql-test/include/read_head.inc
Normal file
@ -0,0 +1,30 @@
|
||||
# Purpose:
|
||||
# Print first LINES_TO_READ from a file.
|
||||
# The environment variables SEARCH_FILE and LINES_TO_READ must be set
|
||||
# before sourcing this routine.
|
||||
# Use:
|
||||
# When the test is slow ( example because of ASAN build) then it
|
||||
# may not flush the lines when 'cat' command is called and the
|
||||
# test could fail with missing lines. Hence this can be used to
|
||||
# to print first N lines.
|
||||
#
|
||||
|
||||
perl;
|
||||
|
||||
use strict;
|
||||
|
||||
my $search_file = $ENV{SEARCH_FILE} or die "SEARCH_FILE not set";
|
||||
my $lines_to_read = $ENV{LINES_TO_READ} or die "LINES_TO_READ not set";
|
||||
|
||||
open(FILE, '<', $search_file) or die "Can't open file $search_file: $!";
|
||||
|
||||
my $line_count = 0;
|
||||
while ($line_count < $lines_to_read and my $line = <FILE>)
|
||||
{
|
||||
print $line;
|
||||
$line_count++;
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
|
||||
EOF
|
@ -51,12 +51,15 @@
|
||||
# Created: 2011-11-11 mleich
|
||||
#
|
||||
|
||||
--error 0,1
|
||||
perl;
|
||||
use strict;
|
||||
die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE};
|
||||
my @search_files= glob($ENV{SEARCH_FILE});
|
||||
my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set";
|
||||
my $search_range= $ENV{SEARCH_RANGE};
|
||||
my $silent= $ENV{SEARCH_SILENT};
|
||||
my $search_result= 0;
|
||||
my $content;
|
||||
foreach my $search_file (@search_files) {
|
||||
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
|
||||
@ -89,16 +92,39 @@ perl;
|
||||
{
|
||||
@matches=($content =~ /$search_pattern/gm);
|
||||
}
|
||||
my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
|
||||
my $res;
|
||||
if (@matches)
|
||||
{
|
||||
$res="FOUND " . scalar(@matches);
|
||||
$search_result= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$res= "NOT FOUND";
|
||||
}
|
||||
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
|
||||
|
||||
if ($ENV{SEARCH_OUTPUT} eq "matches") {
|
||||
foreach (@matches) {
|
||||
print $_ . "\n";
|
||||
}
|
||||
} else {
|
||||
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
|
||||
if (!$silent || $search_result)
|
||||
{
|
||||
if ($ENV{SEARCH_OUTPUT} eq "matches")
|
||||
{
|
||||
foreach (@matches)
|
||||
{
|
||||
print $_ . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
|
||||
}
|
||||
}
|
||||
die "$ENV{SEARCH_ABORT}\n"
|
||||
if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/;
|
||||
exit($search_result != 1);
|
||||
EOF
|
||||
|
||||
let $SEARCH_RESULT= 1; # Found pattern
|
||||
if ($errno)
|
||||
{
|
||||
let $SEARCH_RESULT= 0; # Did not find pattern
|
||||
}
|
||||
|
56
mysql-test/include/wait_for_pattern_in_file.inc
Normal file
56
mysql-test/include/wait_for_pattern_in_file.inc
Normal file
@ -0,0 +1,56 @@
|
||||
# ==== Purpose ====
|
||||
#
|
||||
# Waits until pattern comes into log file or until a timeout is reached.
|
||||
# This is a timeout wrapper for search_pattern_in_file.inc
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $timeout= NUMBER in seconds]
|
||||
# For other parameters, check search_pattern_in_file.inc
|
||||
|
||||
--let $wait_save_keep_include_silent=$keep_include_silent
|
||||
--let $include_filename= wait_for_pattern_in_file.inc
|
||||
--source include/begin_include_file.inc
|
||||
--let $keep_include_silent= 1
|
||||
|
||||
let $_timeout= $timeout;
|
||||
if (!$_timeout)
|
||||
{
|
||||
let $_timeout= 10;
|
||||
if ($VALGRIND_TEST)
|
||||
{
|
||||
let $_timeout= 30;
|
||||
}
|
||||
}
|
||||
|
||||
let $_timeout_counter=`SELECT $_timeout * 10`;
|
||||
let SEARCH_SILENT=1;
|
||||
|
||||
let $_continue= 1;
|
||||
while ($_continue)
|
||||
{
|
||||
source include/search_pattern_in_file.inc;
|
||||
if ($SEARCH_RESULT)
|
||||
{
|
||||
# Found match
|
||||
let $_continue= 0;
|
||||
}
|
||||
if (!$SEARCH_RESULT)
|
||||
{
|
||||
dec $_timeout_counter;
|
||||
if ($_timeout_counter == 1)
|
||||
{
|
||||
let $SEARCH_SILENT= 0;
|
||||
}
|
||||
if (!$_timeout_counter)
|
||||
{
|
||||
let $_continue= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let SEARCH_SILENT=0;
|
||||
|
||||
--source include/end_include_file.inc
|
||||
--let $keep_include_silent=$wait_save_keep_include_silent
|
Reference in New Issue
Block a user