Document how to ignore SIGSEV for debugging
[lttng-ust-java-tests.git] / README.md
CommitLineData
08d409fb
AM
1LTTng-UST Java Agent Test Package
2=================================
3
4This git tree contains integration tests and benchmarks for the
5[LTTng-UST](https://lttng.org/) Java Agent. It requires many additional
6dependencies compared to the library itself, so it is shipped as a separate
7package for now.
8
9
10Prerequisites
11-------------
12
13* Java 1.8
14* [Apache Maven](https://maven.apache.org/) 3.0+
15* A recent version of [LTTng-Tools](https://lttng.org/download/)
16* A recent version of [Babeltrace](http://www.efficios.com/babeltrace)
17* A git branch or version of LTTng-UST you want to test
18
19For example, on Ubuntu you can use the
20[LTTng PPA](https://launchpad.net/~lttng/+archive/ubuntu/ppa), then Maven and
21OpenJDK from the main repository:
22
23 sudo apt-add-repository ppa:lttng/ppa
24 sudo apt-get update
25 sudo apt-get install lttng-tools babeltrace maven openjdk-8-jre
26
27Also make sure `mvn -version` reports a `Java version: 1.8` or higher. If it
28does not, you may need to set your `JAVA_HOME` accordingly.
29
30
31Usage
32-----
33
34First you need to `make install` the LTTng-UST git branch you want to test.
35For example:
36
37 git clone git://git.lttng.org/lttng-ust.git
38 cd lttng-ust/
39 (do some modifications, checkout a different branch, etc.)
40 ./bootstrap
41 ./configure --enable-java-agent-all
42 make
43 sudo make install
44
45Then, `cd` back to the directory where you cloned the present git tree, and
46issue a
47
48 mvn clean verify
49
50This will run all the tests on the UST agent that was `make install`'ed. Tests
51will be skipped if they cannot find their required classes or native libraries,
52so make sure the output mentions succesful tests and not skipped ones.
53
54Please make sure you have no `lttng` session active prior to or during the
55tests, or it might interfere with the test runs!
56
7b82be36 57Detailed JUnit test reports will be available under
4821eac9 58`lttng-ust-java-tests-{jul|log4j}/target/failsafe-reports/`
08d409fb
AM
59
60
ca5cfa43
AM
61Setting library paths
62---------------------
63
64By default, the tests will look for the Java and JNI libraries in the default
65locations of `make install` (`/usr/local/lib`, `/usr/local/share/java`, etc.)
66
67If for example, you installed into the `/usr` prefix instead of `/usr/local`,
68you can use the following properties to specify different locations for the
69lttng-ust-agent-java jars:
70
71 mvn clean verify
72 -Dcommon-jar-location=/usr/share/java/lttng-ust-agent-common.jar
73 -Djul-jar-location=/usr/share/java/lttng-ust-agent-jul.jar
74 -Dlog4j-jar-location=/usr/share/java/lttng-ust-agent-log4j.jar
75
76To specify a different locations for the JNI .so libraries, you can set the
77`-Djava.library.path` property on the JVM:
78
79 mvn (...) -DargLine=-Djava.library.path=/usr/lib
80
81Note: do not use `MAVEN_OPTS` to set the library path, since the `argLine`
82property defined in the build will overwrite it.
83
0b7cb727
JR
84Running a single test
85----------------------
86
87This test suite is comprised of integration tests. We use the failsafe
88maven plugin [1]. To run a single test, one can use the test class name and the
89following command:
90
91 mvn clean verify -Dit.test=JulAppContextOrderingIT -DfailIfNoTests=false
92
93The `-DfailIfNoTests=false` argument is necessary otherwise maven will fail on
94the first test set that is empty. See [2] for more info.
95
96
97[1] http://maven.apache.org/surefire/maven-failsafe-plugin/index.html
98[2] http://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.html
99
100Debugging a test
101----------------------
102
103Note that for most tests, the test itself is the traced application.
104The fastest and "easiest" way of putting a breakpoint is to use eclipse.
105
106Download eclipse (for java dev).
107Import a maven project that points to this repo:
108
9a24d281
JRJ
109 File -> Import -> Project -> Select Maven folder -> Select Existing Maven Projects
110 Point the root directory to this repo. Select all projects. Finish
0b7cb727
JR
111
112Setup the Debug Configuration:
9a24d281
JRJ
113
114 Run -> Debug Configurations.
115 Select Remote Java Application.
116 Press the New Configuration button.
117 Give it the name "Remote lttng maven".
118 Select the project and select `lttng-tools-java`
119 Set the port to 5005
120 Go in the Source tab.
121 Click Add -> Java project -> Select all
122 Click Apply
123 Click Close
0b7cb727
JR
124
125Now let's run a single test with debug:
126
9a24d281 127 mvn clean verify -Dit.test=JulAppContextOrderingIT -DfailIfNoTests=false -Dmaven.failsafe.debug
0b7cb727
JR
128
129Wait for:
9a24d281
JRJ
130
131 Listening for transport dt_socket at address: 5005
0b7cb727
JR
132
133Now go back to eclipse:
9a24d281
JRJ
134
135 Navigate to where you want to put a break point. For example, JulAppContextOrderingIT.registerAgent.
136 Ctrl + shift + b can be used to set a tracepoint at the desired line.
0b7cb727
JR
137
138Then attach to the debugger:
9a24d281
JRJ
139
140 Run -> Debug Configurations.
141 Select on the right "Remote lttng maven"
142 Click Debug
0b7cb727
JR
143
144You should hit the breakpoint at some point and from there use steps etc.
145
146If you want to debug lttng-ust, you need to insert a breakpoint at a valid point
147in time for the test and then use gdb to hook yourself to the java process.
148From there debugging is the same as any C application.
964084b4
JRJ
149You will need to ignore SIGSEV from java under gdb:
150
151 handle SIGSEGV nostop noprint pass
ca5cfa43 152
08d409fb
AM
153Running the benchmarks
154----------------------
155
156By default only the unit/integration tests are run. To also run the benchmarks,
157run Maven with the `benchmark` profile, as follows:
158
159 mvn clean verify -Pbenchmark
160
161The benchmark results should be part of the standard output.
162
This page took 0.028002 seconds and 4 git commands to generate.