Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
export JCOV_HOME=~/jcoverage

#Prepare base directory
mkdir $JCOV_HOME
cd $JCOV_HOME

#Build jtreg
git clone https://github.com/openjdk/jtreg.git
cd jtreg
bash make/build.sh --jdk $JAVA_HOME
cd -

#Build jcov
git clone https://github.com/openjdk/jcov.git
cd jcov/build

#Download dependencies
mvn dependency:get -Dartifact=org.ow2.asm:asm:9.1 -Dtransitive=false -Ddest=asm-9.1.jar
mvn dependency:get -Dartifact=org.ow2.asm:asm-util:9.1 -Dtransitive=false -Ddest=asm-util-9.1.jar
mvn dependency:get -Dartifact=org.ow2.asm:asm-tree:9.1 -Dtransitive=false -Ddest=asm-tree-9.1.jar

ant clean
ant -v -f build.xml -Dasm.jar=$PWD/asm-9.1.jar -Dasm-util.jar=$PWD/asm-util-9.1.jar -Dasm-tree.jar=$PWD/asm-tree-9.1.jar -Djavatestjar=$JCOV_HOME/jtreg/build/images/jtreg/lib/javatest.jar

...

Build

With jcov, the classes are instrumented after compilation, so we can build as usual and instrument the jar files later. After a regular compilation, you need to choose the jar files you'd like to use for coverage and instrument them:

Code Block
languagebash
mkdir coverage_reports
cd coverage_reports

#Identify jcov jar file
export JCOV_JAR=$JCOV_HOME/jcov/JCOV_BUILD/jcov_3.0/jcov.jar

#Instrument java classes
find $ACSROOT/lib -name "*.jar" | xargs java -cp $JCOV_JAR:$(acsMakeJavaClasspath -eclipse) com.sun.tdk.jcov.Instr -t coverage_instr.xml

...

Execute

There are two ways of performing coverage for the executions. One is to run the classes and generate intermediate files that would need to be combined at a later stage and the second is to instance a server that will receive the information from all instrumented Java classes and combine the data on-the-fly.

...