Bug 2829 - test.py produces malformed XML results
test.py produces malformed XML results
Status: REOPENED
Product: ns-3
Classification: Unclassified
Component: test framework
ns-3-dev
All All
: P3 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-11-24 13:27 EST by Robert Ammon
Modified: 2018-01-05 00:30 EST (History)
2 users (show)

See Also:


Attachments
Updated file with the fix (77.08 KB, text/plain)
2017-11-24 13:27 EST, Robert Ammon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Ammon 2017-11-24 13:27:03 EST
Created attachment 2964 [details]
Updated file with the fix

There is one test condition where test.py produces malformed XML results.  It also contains dead code that can never be reached.
Comment 1 Robert Ammon 2017-11-24 17:40:00 EST
Patch uploaded as http://codereview.appspot.com/337120043
Comment 2 Tom Henderson 2017-11-24 18:42:40 EST
(In reply to Robert Ammon from comment #0)
> Created attachment 2964 [details]
> Updated file with the fix
> 
> There is one test condition where test.py produces malformed XML results. 
> It also contains dead code that can never be reached.

I agree with the patch for malformed XML.  Regarding the dead code, I agree it is dead as it stands currently, but please look at the preceding comment in the code.  It seems to me that the 'if job.returncode == 2' branch belongs instead at the end of the 'if returncode == 0,1,or 2' branch, based on the preceding comment.  What do you think?
Comment 3 Robert Ammon 2017-11-24 19:14:49 EST
The code associated with the if job.returncode == 0 or job.returncode == 1 or job.returncode == 2: copies the results entry from the job output file to the XML results file.

If the removed code is at the same indentation level as if job.returncode == 0 or job.returncode == 1 or job.returncode == 2:, then there would be two VALGR entries in the XML results file for a single test execution which is the reason I removed it rather than changed the indentation level.
Comment 4 Tom Henderson 2018-01-04 17:08:43 EST
Fixed in changeset 13237:e06b75ea96cc
Comment 5 Peter Barnes 2018-01-04 17:26:17 EST
I'm puzzled by removing the valgrind stanza.  The comment is pretty clear there should be two entries: one for the test itself completing and passing, a second for the associated valgrind error.

Is the additional entry creating problems for you elsewhere?

Not obvious to me how to test this case (a test which deliberately fails valgrind).  Perhaps remove a suppression?
Comment 6 Tom Henderson 2018-01-04 17:56:11 EST
reopening for Peter's question
Comment 7 Robert Ammon 2018-01-04 22:21:14 EST
Regardless of what the comment says, its impossible for the following code block in the current code to be executed:

 1781                     if job.returncode == 2:	
 1782                         f = open(xml_results_file, 'a')	
 1783                         f.write("<Test>\n")	
 1784                         f.write("  <Name>%s</Name>\n" % job.display_name)	
 1785                         f.write('  <Result>VALGR</Result>\n')	
 1786                         f.write("</Test>\n")	
 1787                         f.close()
Comment 8 Peter Barnes 2018-01-05 00:30:16 EST
Agreed.

But if outdented one level it would execute...  Tom's suggestion is equivalent.