1 /* |
1 /* |
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
130 * 3) execute with invalid parameter: -XX:NativeMemoryTracking |
130 * 3) execute with invalid parameter: -XX:NativeMemoryTracking |
131 * !) Won't find "NativeMemoryTracking:" |
131 * !) Won't find "NativeMemoryTracking:" |
132 * Code to create env variable not executed. |
132 * Code to create env variable not executed. |
133 * 4) give and invalid value and check to make sure JVM commented |
133 * 4) give and invalid value and check to make sure JVM commented |
134 */ |
134 */ |
135 String launcherPidString = "launcher.pid="; |
|
136 String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_"; |
135 String envVarPidString = "TRACER_MARKER: NativeMemoryTracking: env var is NMT_LEVEL_"; |
137 String NMT_Option_Value = "off"; |
136 String NMT_Option_Value = "off"; |
138 String myClassName = "helloworld"; |
137 String myClassName = "helloworld"; |
139 boolean haveLauncherPid = false; |
|
140 |
138 |
141 // === Run the tests === |
139 // === Run the tests === |
142 // ---Test 1a |
140 // ---Test 1a |
143 tr = doExec(envMap, javaCmd, "-XX:NativeMemoryTracking=" + NMT_Option_Value, |
141 tr = doExec(envMap, javaCmd, "-XX:NativeMemoryTracking=" + NMT_Option_Value, |
144 "-version"); |
142 "-version"); |
159 } |
157 } |
160 // we think we found the pid string. min test, not "". |
158 // we think we found the pid string. min test, not "". |
161 if (envVarPid.length() < 1) { |
159 if (envVarPid.length() < 1) { |
162 System.out.println(tr); |
160 System.out.println(tr); |
163 throw new RuntimeException("Error: env Var Pid in tracking info is empty string"); |
161 throw new RuntimeException("Error: env Var Pid in tracking info is empty string"); |
164 } |
|
165 |
|
166 /* |
|
167 * On Linux, Launcher Tracking will print the PID. Use this info |
|
168 * to validate what we got as the PID in the Launcher itself. |
|
169 * Linux is the only one that prints this, and trying to get it |
|
170 * here for win is awful. So let the linux test make sure we get |
|
171 * the valid pid, and for non-linux, just make sure pid string is |
|
172 * non-zero. |
|
173 */ |
|
174 if (isLinux) { |
|
175 // get what the test says is the launcher pid |
|
176 String launcherPid = null; |
|
177 for (String line : tr.testOutput) { |
|
178 int index = line.indexOf(launcherPidString); |
|
179 if (index >= 0) { |
|
180 int sindex = index + launcherPidString.length(); |
|
181 int tindex = sindex + line.substring(sindex).indexOf("'"); |
|
182 System.out.println("DEBUG INFO: sindex = " + sindex); |
|
183 System.out.println("DEBUG INFO: searching substring: " + line.substring(sindex)); |
|
184 System.out.println("DEBUG INFO: tindex = " + tindex); |
|
185 // DEBUG INFO |
|
186 System.out.println(tr); |
|
187 launcherPid = line.substring(sindex, tindex); |
|
188 break; |
|
189 } |
|
190 } |
|
191 if (launcherPid == null) { |
|
192 System.out.println(tr); |
|
193 throw new RuntimeException("Error: failed to find launcher Pid in launcher tracking info"); |
|
194 } |
|
195 |
|
196 // did we create the env var with the correct pid? |
|
197 if (!launcherPid.equals(envVarPid)) { |
|
198 System.out.println(tr); |
|
199 System.out.println("Error: wrong pid in creating env var"); |
|
200 System.out.println("Error Info: launcherPid = " + launcherPid); |
|
201 System.out.println("Error Info: envVarPid = " + envVarPid); |
|
202 throw new RuntimeException("Error: wrong pid in creating env var"); |
|
203 } |
|
204 } |
162 } |
205 |
163 |
206 // --- Test 1b |
164 // --- Test 1b |
207 if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) { |
165 if (!tr.contains("NativeMemoryTracking: got value " + NMT_Option_Value)) { |
208 System.out.println(tr); |
166 System.out.println(tr); |