diff options
author | Magnus Svensson <msvensson@mysql.com> | 2009-01-27 15:10:15 +0100 |
---|---|---|
committer | Magnus Svensson <msvensson@mysql.com> | 2009-01-27 15:10:15 +0100 |
commit | d4c402db6437fe95495796cdb4098e3da2b481d3 (patch) | |
tree | 28cd85be612b4024b36ec2336196c29cd659c8d1 /mysql-test/include | |
parent | d85073033372b7e1513f8f72dabfd2bbda8faf24 (diff) | |
parent | 5a1e073fc7a61eb0d60198992552411dadc95ab2 (diff) | |
download | mariadb-git-d4c402db6437fe95495796cdb4098e3da2b481d3.tar.gz |
Merge
Diffstat (limited to 'mysql-test/include')
-rw-r--r-- | mysql-test/include/check-warnings.test | 36 | ||||
-rw-r--r-- | mysql-test/include/mtr_warnings.sql | 109 |
2 files changed, 52 insertions, 93 deletions
diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test index 9f404201ab8..154de4be290 100644 --- a/mysql-test/include/check-warnings.test +++ b/mysql-test/include/check-warnings.test @@ -1,9 +1,43 @@ - # # This test is executed once after each test to check the servers # for unexpected warnings found in the servers error log # +# NOTE! mysql-test-run.pl has already done a rough filtering +# of the file and written any suspicious lines +# to $error_log.warnings file +# --disable_query_log + +# Don't write these queries to binlog +set SQL_LOG_BIN=0; + +# Turn off any debug crashes, allow the variable to be +# non existent in release builds +--error 0,1193 +set debug=""; + +use mtr; + +create temporary table error_log ( + row int auto_increment primary key, + suspicious int default 1, + file_name varchar(255), + line varchar(1024) default null +) engine=myisam; + +# Get the name of servers error log +let $log_error= query_get_value(show variables like 'log_error', Value, 1); +let $log_warning= $log_error.warnings; + +# Load the warnings into a temporary table +eval load data infile '$log_warning' into table error_log + fields terminated by 'xykls37' + ignore 1 lines + (line) + set file_name='$log_error'; + +# Call check_warnings to filter out any warning in +# the error_log table call mtr.check_warnings(@result); if (`select @result = 0`){ skip OK; diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql index 3da64fbd791..73287900f3c 100644 --- a/mysql-test/include/mtr_warnings.sql +++ b/mysql-test/include/mtr_warnings.sql @@ -3,44 +3,6 @@ delimiter ||; use mtr|| -- --- Load table with the patterns that are considered --- as suspicious and should be examined further --- -CREATE TABLE suspicious_patterns ( - pattern VARCHAR(255) -) ENGINE=MyISAM|| - - --- --- Declare a trigger that makes sure --- no invalid patterns can be inserted --- into suspicious_patterns --- -/*!50002 -CREATE DEFINER=root@localhost TRIGGER sp_insert -BEFORE INSERT ON suspicious_patterns -FOR EACH ROW BEGIN - DECLARE dummy INT; - SELECT "" REGEXP NEW.pattern INTO dummy; -END -*/|| - - --- --- Insert patterns for the lines we should check --- -INSERT INTO suspicious_patterns VALUES - ("^Warning:|mysqld: Warning|\\[Warning\\]"), - ("^Error:|\\[ERROR\\]"), - ("^==.* at 0x"), - ("InnoDB: Warning"), - ("^safe_mutex:|allocated at line"), - ("missing DBUG_RETURN"), - ("Attempting backtrace"), - ("Assertion .* failed")|| - - --- -- Create table where testcases can insert patterns to -- be suppressed -- @@ -219,71 +181,34 @@ INSERT INTO global_suppressions VALUES -- CREATE DEFINER=root@localhost PROCEDURE check_warnings(OUT result INT) BEGIN - DECLARE `text` mediumtext charset utf8; DECLARE `pos` bigint unsigned; -- Don't write these queries to binlog SET SQL_LOG_BIN=0; + -- - -- Load the server .err file into "error_log" table + -- Remove mark from lines that are suppressed by global suppressions -- - CREATE TEMPORARY TABLE error_log ( - row INT AUTO_INCREMENT PRIMARY KEY, - line mediumtext NULL - ) ENGINE=MyISAM; - - SELECT variable_value INTO @log_error - FROM information_schema.global_variables - WHERE variable_name='LOG_ERROR'; - - SET @old_max_allowed_packet= @@global.max_allowed_packet; - SET @@global.max_allowed_packet= 1024*1024*1024; - SET text= load_file(@log_error); - SET @@global.max_allowed_packet= @old_max_allowed_packet; - -- select text; - - SET pos= LOCATE('\n', text); - WHILE pos DO - INSERT error_log (line) - VALUES ( - SUBSTR(text, 1, pos-1) - ); - SET text= SUBSTR(text FROM pos+1); - SET pos= LOCATE('\n', text); - END WHILE; - - -- select * from error_log; + UPDATE error_log el, global_suppressions gs + SET suspicious=0 + WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; -- - -- Remove all lines belonging to previous tests + -- Remove mark from lines that are suppressed by test specific suppressions -- - SELECT COALESCE(MAX(row),0) INTO @max_row - FROM error_log - WHERE line REGEXP "^CURRENT_TEST:"; - DELETE FROM error_log WHERE row < @max_row; - - CREATE TEMPORARY TABLE suspect_lines ENGINE=MyISAM AS - SELECT DISTINCT el.line, 0 as "suppressed" - FROM error_log el, suspicious_patterns ep - WHERE el.line REGEXP ep.pattern; - - -- Mark lines that are suppressed by global suppressions - UPDATE suspect_lines sl, global_suppressions gs - SET suppressed=1 - WHERE sl.line REGEXP gs.pattern; + UPDATE error_log el, test_suppressions ts + SET suspicious=0 + WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; - -- Mark lines that are suppressed by test specific suppressions - UPDATE suspect_lines sl, test_suppressions ts - SET suppressed=2 - WHERE sl.line REGEXP ts.pattern; - - SELECT COUNT(*) INTO @num_warnings FROM suspect_lines - WHERE suppressed=0; + -- + -- Get the number of marked lines and return result + -- + SELECT COUNT(*) INTO @num_warnings FROM error_log + WHERE suspicious=1; IF @num_warnings > 0 THEN - SELECT @log_error; - SELECT line as log_error - FROM suspect_lines WHERE suppressed=0; + SELECT file_name, line + FROM error_log WHERE suspicious=1; --SELECT * FROM test_suppressions; -- Return 2 -> check failed SELECT 2 INTO result; @@ -294,7 +219,7 @@ BEGIN -- Cleanup for next test TRUNCATE test_suppressions; - DROP TABLE error_log, suspect_lines; + DROP TABLE error_log; END|| |