Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/attach/RemovingUnixDomainSocketTest.java
41149 views
1
/*
2
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 8225193
27
* @requires os.family != "windows"
28
* @library /test/lib
29
* @run main RemovingUnixDomainSocketTest
30
*/
31
32
import java.io.File;
33
import java.io.IOException;
34
import java.nio.file.Path;
35
import java.util.concurrent.TimeUnit;
36
37
import jdk.test.lib.Utils;
38
import jdk.test.lib.apps.LingeredApp;
39
import jdk.test.lib.JDKToolLauncher;
40
import jdk.test.lib.process.OutputAnalyzer;
41
import jdk.test.lib.process.ProcessTools;
42
43
public class RemovingUnixDomainSocketTest {
44
45
// timeout (in seconds)
46
private static final long timeout = Utils.adjustTimeout(60);
47
48
private static void runJCmd(long pid) throws InterruptedException, IOException {
49
JDKToolLauncher jcmd = JDKToolLauncher.createUsingTestJDK("jcmd");
50
jcmd.addVMArgs(Utils.getFilteredTestJavaOpts("-showversion"));
51
jcmd.addToolArg(Long.toString(pid));
52
jcmd.addToolArg("VM.version");
53
54
ProcessBuilder pb = new ProcessBuilder(jcmd.getCommand());
55
Process jcmdProc = pb.start();
56
57
OutputAnalyzer out = new OutputAnalyzer(jcmdProc);
58
59
if (!jcmdProc.waitFor(timeout, TimeUnit.SECONDS)) {
60
log("jcmd is still running after " + timeout + " seconds, terminating...");
61
jcmdProc.destroy();
62
jcmdProc.waitFor();
63
}
64
65
log("jcmd stdout: [" + out.getStdout() + "];\n" +
66
"jcmd stderr: [" + out.getStderr() + "]\n" +
67
"jcmd exitValue = " + out.getExitValue());
68
69
out.shouldHaveExitValue(0);
70
out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
71
}
72
73
public static void main(String... args) throws Exception {
74
LingeredApp app = null;
75
try {
76
app = LingeredApp.startApp();
77
78
// Access to Attach Listener
79
runJCmd(app.getPid());
80
81
// Remove unix domain socket file
82
File sockFile = Path.of(System.getProperty("java.io.tmpdir"),
83
".java_pid" + app.getPid())
84
.toFile();
85
log("Remove " + sockFile.toString());
86
sockFile.delete();
87
88
// Access to Attach Listener again
89
runJCmd(app.getPid());
90
} finally {
91
LingeredApp.stopApp(app);
92
}
93
}
94
95
static void log(Object s) {
96
System.out.println(String.valueOf(s));
97
}
98
}
99
100