You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

393 lines
9.5 KiB

mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mysql-test/lib/mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mysql-test/mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves
21 years ago
mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mysql-test/lib/mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mysql-test/mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves
21 years ago
mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mysql-test/lib/mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mysql-test/mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves
21 years ago
mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mysql-test/lib/mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mysql-test/mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves
21 years ago
mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_io.pl: Remove starting/ending space reading server options from file mysql-test/lib/mtr_report.pl: Added option to disable test cases using <testcase>.disabled file If --timer, only try to open file with time data if it exists mysql-test/lib/mtr_process.pl: Find out if port is still in use, using simple TCP connect Use non blocking waitpid() to catch terminations early Make a special case spawning the 'mysqltest' application Redo the fork() if it returns EAGAIN Make sure to record if master or slave terminated Improved debugging output Improved code that remove PID files to avoid race Abort if we can't stop all mysqld servers using our ports Many improvements in killing mysqld servers Let sleep_until_file_created() catch if server died early mysql-test/mysql-test-run.pl: Let --start-and-exit actually start a server Added that test case names can be specified on the comman line Added embedded server support Added environment variables UMASK, UMASK_DIR Added missing MASTER_MYSOCK1, MASTER_MYPORT1, USE_RUNNING_SERVER Added missing CHARSETSDIR, MYSQL_FIX_SYSTEM_TABLES, MYSQL_CLIENT_TEST Pass on return value from sleep_until_file_created(), to fail test Fail test if early termination of mysqld servers Create intial databases for the second master, and two additional slaves
21 years ago
  1. # -*- cperl -*-
  2. # This is a library file used by the Perl version of mysql-test-run,
  3. # and is part of the translation of the Bourne shell script with the
  4. # same name.
  5. use strict;
  6. sub mtr_report_test_name($);
  7. sub mtr_report_test_passed($);
  8. sub mtr_report_test_failed($);
  9. sub mtr_report_test_skipped($);
  10. sub mtr_report_test_not_skipped_though_disabled($);
  11. sub mtr_show_failed_diff ($);
  12. sub mtr_report_stats ($);
  13. sub mtr_print_line ();
  14. sub mtr_print_thick_line ();
  15. sub mtr_print_header ();
  16. sub mtr_report (@);
  17. sub mtr_warning (@);
  18. sub mtr_error (@);
  19. sub mtr_child_error (@);
  20. sub mtr_debug (@);
  21. sub mtr_verbose (@);
  22. ##############################################################################
  23. #
  24. #
  25. #
  26. ##############################################################################
  27. # We can't use diff -u or diff -a as these are not portable
  28. sub mtr_show_failed_diff ($) {
  29. my $tname= shift;
  30. my $reject_file= "r/$tname.reject";
  31. my $result_file= "r/$tname.result";
  32. my $log_file= "r/$tname.log";
  33. my $eval_file= "r/$tname.eval";
  34. if ( $::opt_suite ne "main" )
  35. {
  36. $reject_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$reject_file";
  37. $result_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$result_file";
  38. $eval_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$eval_file";
  39. $log_file= "$::glob_mysql_test_dir/suite/$::opt_suite/$log_file";
  40. }
  41. if ( -f $eval_file )
  42. {
  43. $result_file= $eval_file;
  44. }
  45. my $diffopts= $::opt_udiff ? "-u" : "-c";
  46. if ( -f $reject_file )
  47. {
  48. print "Below are the diffs between actual and expected results:\n";
  49. print "-------------------------------------------------------\n";
  50. # FIXME check result code?!
  51. mtr_run("diff",[$diffopts,$result_file,$reject_file], "", "", "", "");
  52. print "-------------------------------------------------------\n";
  53. print "Please follow the instructions outlined at\n";
  54. print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n";
  55. print "to find the reason to this problem and how to report this.\n\n";
  56. }
  57. if ( -f $log_file )
  58. {
  59. print "Result from queries before failure can be found in $log_file\n";
  60. # FIXME Maybe a tail -f -n 10 $log_file here
  61. }
  62. }
  63. sub mtr_report_test_name ($) {
  64. my $tinfo= shift;
  65. printf "%-30s ", $tinfo->{'name'};
  66. }
  67. sub mtr_report_test_skipped ($) {
  68. my $tinfo= shift;
  69. $tinfo->{'result'}= 'MTR_RES_SKIPPED';
  70. if ( $tinfo->{'disable'} )
  71. {
  72. print "[ disabled ] $tinfo->{'comment'}\n";
  73. }
  74. else
  75. {
  76. print "[ skipped ] $tinfo->{'comment'}\n";
  77. }
  78. }
  79. sub mtr_report_tests_not_skipped_though_disabled ($) {
  80. my $tests= shift;
  81. if ( $::opt_enable_disabled )
  82. {
  83. my @disabled_tests= grep {$_->{'dont_skip_though_disabled'}} @$tests;
  84. if ( @disabled_tests )
  85. {
  86. print "\nTest(s) which will be run though they are marked as disabled:\n";
  87. foreach my $tinfo ( sort {$a->{'name'} cmp $b->{'name'}} @disabled_tests )
  88. {
  89. printf " %-20s : %s\n", $tinfo->{'name'}, $tinfo->{'comment'};
  90. }
  91. }
  92. }
  93. }
  94. sub mtr_report_test_passed ($) {
  95. my $tinfo= shift;
  96. my $timer= "";
  97. if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
  98. {
  99. $timer= mtr_fromfile("$::opt_vardir/log/timer");
  100. $::glob_tot_real_time += ($timer/1000);
  101. $timer= sprintf "%12s", $timer;
  102. }
  103. $tinfo->{'result'}= 'MTR_RES_PASSED';
  104. print "[ pass ] $timer\n";
  105. }
  106. sub mtr_report_test_failed ($) {
  107. my $tinfo= shift;
  108. $tinfo->{'result'}= 'MTR_RES_FAILED';
  109. if ( defined $tinfo->{'timeout'} )
  110. {
  111. print "[ fail ] timeout\n";
  112. return;
  113. }
  114. else
  115. {
  116. print "[ fail ]\n";
  117. }
  118. if ( $tinfo->{'comment'} )
  119. {
  120. print "\nERROR: $tinfo->{'comment'}\n";
  121. }
  122. elsif ( -f $::path_timefile )
  123. {
  124. print "\nErrors are (from $::path_timefile) :\n";
  125. print mtr_fromfile($::path_timefile); # FIXME print_file() instead
  126. print "\n(the last lines may be the most important ones)\n";
  127. }
  128. else
  129. {
  130. print "\nUnexpected termination, probably when starting mysqld\n";
  131. }
  132. }
  133. sub mtr_report_stats ($) {
  134. my $tests= shift;
  135. # ----------------------------------------------------------------------
  136. # Find out how we where doing
  137. # ----------------------------------------------------------------------
  138. my $tot_skiped= 0;
  139. my $tot_passed= 0;
  140. my $tot_failed= 0;
  141. my $tot_tests= 0;
  142. my $tot_restarts= 0;
  143. my $found_problems= 0; # Some warnings in the logfiles are errors...
  144. foreach my $tinfo (@$tests)
  145. {
  146. if ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
  147. {
  148. $tot_skiped++;
  149. }
  150. elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' )
  151. {
  152. $tot_tests++;
  153. $tot_passed++;
  154. }
  155. elsif ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
  156. {
  157. $tot_tests++;
  158. $tot_failed++;
  159. }
  160. if ( $tinfo->{'restarted'} )
  161. {
  162. $tot_restarts++;
  163. }
  164. }
  165. # ----------------------------------------------------------------------
  166. # Print out a summary report to screen
  167. # ----------------------------------------------------------------------
  168. if ( ! $tot_failed )
  169. {
  170. print "All $tot_tests tests were successful.\n";
  171. }
  172. else
  173. {
  174. my $ratio= $tot_passed * 100 / $tot_tests;
  175. print "Failed $tot_failed/$tot_tests tests, ";
  176. printf("%.2f", $ratio);
  177. print "\% were successful.\n\n";
  178. print
  179. "The log files in var/log may give you some hint\n",
  180. "of what went wrong.\n",
  181. "If you want to report this error, please read first ",
  182. "the documentation at\n",
  183. "http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
  184. }
  185. print
  186. "The servers were restarted $tot_restarts times\n";
  187. if ( $::opt_timer )
  188. {
  189. print
  190. "Spent $::glob_tot_real_time seconds actually executing testcases\n"
  191. }
  192. # ----------------------------------------------------------------------
  193. # If a debug run, there might be interesting information inside
  194. # the "var/log/*.err" files. We save this info in "var/log/warnings"
  195. # ----------------------------------------------------------------------
  196. if ( ! $::glob_use_running_server )
  197. {
  198. # Save and report if there was any fatal warnings/errors in err logs
  199. my $warnlog= "$::opt_vardir/log/warnings";
  200. unless ( open(WARN, ">$warnlog") )
  201. {
  202. mtr_warning("can't write to the file \"$warnlog\": $!");
  203. }
  204. else
  205. {
  206. # We report different types of problems in order
  207. foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x",
  208. "InnoDB: Warning", "missing DBUG_RETURN",
  209. "mysqld: Warning",
  210. "Attempting backtrace", "Assertion .* failed" )
  211. {
  212. foreach my $errlog ( sort glob("$::opt_vardir/log/*.err") )
  213. {
  214. unless ( open(ERR, $errlog) )
  215. {
  216. mtr_warning("can't read $errlog");
  217. next;
  218. }
  219. while ( <ERR> )
  220. {
  221. # Skip some non fatal warnings from the log files
  222. if ( /Warning:\s+Table:.* on (delete|rename)/ or
  223. /Warning:\s+Setting lower_case_table_names=2/ or
  224. /Warning:\s+One can only use the --user.*root/ or
  225. /InnoDB: Warning: we did not need to do crash recovery/)
  226. {
  227. next; # Skip these lines
  228. }
  229. if ( /$pattern/ )
  230. {
  231. $found_problems= 1;
  232. print WARN $_;
  233. }
  234. }
  235. }
  236. }
  237. if ( $found_problems )
  238. {
  239. mtr_warning("Got errors/warnings while running tests, please examine",
  240. "\"$warnlog\" for details.");
  241. }
  242. }
  243. }
  244. print "\n";
  245. # Print a list of testcases that failed
  246. if ( $tot_failed != 0 )
  247. {
  248. my $test_mode= join(" ", @::glob_test_mode) || "default";
  249. print "mysql-test-run in $test_mode mode: *** Failing the test(s):";
  250. foreach my $tinfo (@$tests)
  251. {
  252. if ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
  253. {
  254. print " $tinfo->{'name'}";
  255. }
  256. }
  257. print "\n";
  258. }
  259. # Print a list of check_testcases that failed(if any)
  260. if ( $::opt_check_testcases )
  261. {
  262. my @check_testcases= ();
  263. foreach my $tinfo (@$tests)
  264. {
  265. if ( defined $tinfo->{'check_testcase_failed'} )
  266. {
  267. push(@check_testcases, $tinfo->{'name'});
  268. }
  269. }
  270. if ( @check_testcases )
  271. {
  272. print "Check of testcase failed for: ";
  273. print join(" ", @check_testcases);
  274. print "\n\n";
  275. }
  276. }
  277. if ( $tot_failed != 0 || $found_problems)
  278. {
  279. mtr_error("there where failing test cases");
  280. }
  281. }
  282. ##############################################################################
  283. #
  284. # Text formatting
  285. #
  286. ##############################################################################
  287. sub mtr_print_line () {
  288. print '-' x 55, "\n";
  289. }
  290. sub mtr_print_thick_line () {
  291. print '=' x 55, "\n";
  292. }
  293. sub mtr_print_header () {
  294. print "\n";
  295. if ( $::opt_timer )
  296. {
  297. print "TEST RESULT TIME (ms)\n";
  298. }
  299. else
  300. {
  301. print "TEST RESULT\n";
  302. }
  303. mtr_print_line();
  304. print "\n";
  305. }
  306. ##############################################################################
  307. #
  308. # Misc
  309. #
  310. ##############################################################################
  311. sub mtr_report (@) {
  312. print join(" ", @_),"\n";
  313. }
  314. sub mtr_warning (@) {
  315. print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n";
  316. }
  317. sub mtr_error (@) {
  318. print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n";
  319. mtr_exit(1);
  320. }
  321. sub mtr_child_error (@) {
  322. print STDERR "mysql-test-run: *** ERROR(child): ",join(" ", @_),"\n";
  323. exit(1);
  324. }
  325. sub mtr_debug (@) {
  326. if ( $::opt_script_debug )
  327. {
  328. print STDERR "####: ",join(" ", @_),"\n";
  329. }
  330. }
  331. sub mtr_verbose (@) {
  332. if ( $::opt_verbose )
  333. {
  334. print STDERR "> ",join(" ", @_),"\n";
  335. }
  336. }
  337. 1;