Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/logging/TestFullNames.java
41152 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 TestFullNames
26
* @summary Ensure proper parsing of unquoted full output names for -Xlog arguments.
27
* @bug 8215398
28
* @modules java.base/jdk.internal.misc
29
* @library /test/lib
30
* @run driver TestFullNames
31
*/
32
33
import java.io.File;
34
import java.nio.file.Path;
35
import java.nio.file.Paths;
36
37
import jdk.test.lib.Asserts;
38
import jdk.test.lib.process.ProcessTools;
39
import jdk.test.lib.process.OutputAnalyzer;
40
41
public class TestFullNames {
42
43
public static void main(String[] args) throws Exception {
44
// Ensure log files can be specified with full path.
45
// On windows, this means that the file name will contain
46
// a colon ('C:\log.txt' for example), which is used to
47
// separate -Xlog: options (-Xlog:tags:filename:decorators).
48
// Try to log to a file in our current directory, using its absolute path.
49
String baseName = "testfile.log";
50
Path filePath = Paths.get(baseName).toAbsolutePath();
51
String fileName = filePath.toString();
52
File file = filePath.toFile();
53
54
// In case the file already exists, attempt to delete it before running the test
55
file.delete();
56
57
// Test full pathnames without quotes.
58
String[] validOutputs = new String[] {
59
"file=" + fileName,
60
fileName
61
};
62
for (String logOutput : validOutputs) {
63
// Run with logging=trace on stdout so that we can verify the log configuration afterwards.
64
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:logging=trace",
65
"-Xlog:all=trace:" + logOutput,
66
"-version");
67
OutputAnalyzer output = new OutputAnalyzer(pb.start());
68
output.shouldHaveExitValue(0);
69
Asserts.assertTrue(file.exists());
70
file.deleteOnExit(); // Clean up after test
71
output.shouldMatch("\\[logging *\\].*" + baseName); // Expect to see the log output listed
72
}
73
}
74
}
75
76
77