Wednesday, February 29, 2012

Running the Penrose (or OpenJDK 8) tests

As a follow-up on my previous post, Building project Penrose (or OpenJDK 8), I wanted to run the unit tests. And, as with many other things in OpenJDK, it's different from what I was used to. While other projects typically use JUnit for unit testing, OpenJDK uses a tool called jtreg, which you'll have to install manually before you can run any tests.

Once you have jtreg installed you need to tell the build where it is (the directory specified contains linux/bin/jtreg) and add it to your path - note that the JT_HOME variable is used by the OpenJDK build:
export JT_HOME=/home/david/apps/jtreg
export PATH=$JT_HOME/linux/bin:$PATH

Now you can run the whole test suite (in your clone of http://hg.openjdk.java.net/penrose/jigsaw or whatever your clone of OpenJDK 8 is):
$ make test

The above takes a very long time (edit: in fact it doesn't properly finish at all for me, it just hangs after a number of hours).

If you're developing it's better to run a portion of the tests, for instance a single test directory:
.../jdk/test$ jtreg -testjdk:/home/david/hg/pj_230212/build/linux-i586/jdk-module-image org/openjdk/jigsaw/cli
Test results: passed: 10
Report written to /home/david/hg/pj_230212/jdk/test/JTreport/html/report.html
Results written to /home/david/hg/pj_230212/jdk/test/JTwork

or a single test class:
.../jdk/test$ jtreg -testjdk:/home/david/hg/pj_230212/build/linux-i586/jdk-module-image org/openjdk/jigsaw/cli/ModuleFileTest.java
Test results: passed: 1
Report written to /home/david/hg/pj_230212/jdk/test/JTreport/html/report.html
Results written to /home/david/hg/pj_230212/jdk/test/JTwork

Note that in the above command lines it's important to pass in the full absolute path of the JDK you're running with as some of the tests rely on that to launch certain executables (like javac).

No comments: