Bug #59002 Please make mtr print correct file and line number when tests fail
Submitted: 17 Dec 2010 14:45 Modified: 28 Jan 2011 15:41
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S1 (Critical)
Version:5.1 OS:Any
Assigned to: Bjørn Munch
Tags: debugging, mtr
Triage: Needs Triage: D2 (Serious)

[17 Dec 2010 14:45] Sven Sandberg
Description:
When a test case fails, mtr sometimes prints a correct line number, sometimes something else. Also, it sometimes prints the file name of the current file and sometimes not.

It would be better if it printed a full stack trace with filename and line number of all included files.

How to repeat:
==== bug_1.test ====
--let $i = 2
while ($i) {
  dec $i;
  if (!$i) {
    execute this nonsense query on line 5;
  }
}
==== end of bug_1.test ====

==== bug_2.test ====
--let $i= 2
while ($i) {
  --dec $i
  if (!$i) {
    --source t/bug_1.test
  }
}
==== end of bug_2.test ====

bug_1 fails with this message:

CURRENT_TEST: main.bug_1
mysqltest: At line 7: query 'execute this nonsense query on line 5' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'nonsense query on line 5' at line 1

Note that the error was on line 5 but the test reports line 7.

bug_2 fails with exactly the same message: there is no indication that the line number refers to another file than the top-level file that was executed.
[17 Dec 2010 14:56] Valerii Kravchuk
Verified on Mac OS X:

macbook-pro:mysql-test openxs$ ./mtr bug59002
Logging: ./mtr  bug59002
101217 16:54:58 [Warning] Setting lower_case_table_names=2 because file system for /var/folders/dX/dXCzvuSlHX4Op1g-o1jIWk+++TI/-Tmp-/9Fxh1AGsCZ/ is case insensitive
101217 16:54:58 [Note] Plugin 'FEDERATED' is disabled.
101217 16:54:58 [Note] Plugin 'ndbcluster' is disabled.
MySQL Version 5.1.54
Checking supported features...
 - skipping ndbcluster
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
vardir: /Users/openxs/dbs/5.1/mysql-test/var
Checking leftover processes...
Removing old var directory...
Creating var directory '/Users/openxs/dbs/5.1/mysql-test/var'...
Installing system database...
Using server port 49260

==============================================================================

TEST                                      RESULT   TIME (ms)
------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
main.bug59002                            [ fail ]
        Test ended at 2010-12-17 16:55:02

CURRENT_TEST: main.bug59002
mysqltest: At line 7: query 'execute this nonsense query on line 5' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'nonsense query on line 5' at line 1
...
[6 Jan 2011 14:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128082

2963 Bjorn Munch	2011-01-06
      Bug #59002 Please make mtr print correct file and line number when tests fail
      This patchs adds printing of a file stack (with line numbers)
      It does not fix the problem of a failure in the non-first iteration of a loop
[6 Jan 2011 14:26] Bjørn Munch
If a failure occurs inside a while() except in the first iteration, then:

 - The line number reported is the end curly brace of the while
 - If the line is a source command, information about the sourced file will be missing.

Fixing this would requite a major rewrite of the loop handling.
[11 Jan 2011 9:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128404

2964 Bjorn Munch	2011-01-11
      Bug #59002 Please make mtr print correct file and line number when tests fail
      This patchs adds printing of a file stack (with line numbers)
      It does not fix the problem of a failure in the non-first iteration of a loop
[11 Jan 2011 14:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/128430

2967 Bjorn Munch	2011-01-11
      Bug #59002 Please make mtr print correct file and line number when tests fail
      Followup: had forgotten to update mysqltest.test due to changed output - duh!
[12 Jan 2011 10:31] Bjørn Munch
Pushed to -mtr branches
[12 Jan 2011 23:25] Bugs System
Pushed into mysql-trunk 5.6.2 (revid:bjorn.munch@oracle.com-20110112231827-w6nuz7qcr3f2zylq) (version source revid:bjorn.munch@oracle.com-20110112225756-g2nv4mukrmvnl3uz) (merge vers: 5.6.2) (pib:24)
[12 Jan 2011 23:26] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:bjorn.munch@oracle.com-20110112225418-3zw6jvo3jywfqsva) (version source revid:bjorn.munch@oracle.com-20110112223239-fep31owswretsv6w) (merge vers: 5.5.9) (pib:24)
[12 Jan 2011 23:29] Bugs System
Pushed into mysql-5.1 5.1.55 (revid:bjorn.munch@oracle.com-20110112222953-xhso3rjm0isfgvxn) (version source revid:bjorn.munch@oracle.com-20110112222953-xhso3rjm0isfgvxn) (merge vers: 5.1.55) (pib:24)
[14 Jan 2011 17:24] Paul Dubois
Changes to test suite. No changelog entry needed.