Instrumenting Russian Roulette from the command line

Introduction

It is my hope to motivate the use of code coverage for command line debugging live via an example war training war file that fails in a reproducible manner.

See also:

Attachments:

  1. emma.jar
  2. qa-fails.war
  3. uva.tar.gz - source code

Details

Assuming JAVA_HOME is set to java 1.5 jdk

  • Copy emma.jar to $JAVA_HOME/jre/lib/ext
  • Expand sakai-demo
  • mkdir report
  • mkdir src
  • mkdir src/condensed_trunk/
  • ls returns report sakai-demo src
  • copy qa-fails.war to sakai-demo/webapps
  • start sakai-demo
  • login as admin and add qa-fails to the Administrative workspace
  • stop sakai-demo
  • cd report
  • run the script
inst.sh
#!/bin/bash
mkdir qa-fails
java emma instr -ix - -ip ../sakai-demo/webapps/qa-fails/WEB-INF/classes -m overwrite -out=qa-fails.em

this instruments the code and produces a local metafile and the output is something like

output
EMMA: processing instrumentation path ...
EMMA: instrumentation path processed in 170 ms
EMMA: 12 class(es) instrumented, 0 resource(s) copied
EMMA: metadata merged into /home/sakaiqa/coverage/report/qa-fails.em
  • start Sakai-demo
  • play around with qa-fails until you have a reproducible case.
  • reset the code coverage setting via a script (coverage.ec may not exist)
reset.sh
#!/bin/bash
rm coverage.ec
java emma ctl -connect localhost:47653 -command coverage.reset
output
EMMA: executing [coverage.reset ()] ...
EMMA: coverage.reset: coverage reset for 251 classes {in 0 ms}
EMMA: coverage.reset: command completed in 2 ms
EMMA: control command sequence complete
  • reproduce the qa-fails case through a web browser
  • capture code coverage data and generate the report
report.sh
#!/bin/bash
java emma ctl -connect localhost:47653 -command coverage.get,coverage.ec
java emma report -r html -sp ../src/condensed_trunk -in qa-fails.em -in coverage.ec -Dreport.html.out.file=qa-fails/index.html
output
EMMA: processing input files ...
EMMA: 2 file(s) read and merged in 40 ms
EMMA: writing [html] report to [/home/sakaiqa/coverage/report/qa-fails/index.html] ...

View the report via a web browser
You now can find the reproducible error live