mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8319678: Several tests from corelibs areas ignore VM flags
Reviewed-by: naoto, jpai
This commit is contained in:
parent
63684cd183
commit
2e3682a7f2
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,15 +23,13 @@
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
|
||||
import static java.lang.System.err;
|
||||
import static java.lang.System.out;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -85,7 +83,7 @@ class UncaughtExceptionsTest {
|
||||
@MethodSource("testCases")
|
||||
void test(String className, int exitValue, String stdOutMatch, String stdErrMatch) throws Throwable {
|
||||
String cmd = "UncaughtExitSimulator$" + className;
|
||||
ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(cmd);
|
||||
ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder(cmd);
|
||||
OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(processBuilder);
|
||||
outputAnalyzer.shouldHaveExitValue(exitValue);
|
||||
outputAnalyzer.stderrShouldMatch(stdErrMatch);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,7 +55,7 @@ public class LoaderLeakTest {
|
||||
}
|
||||
|
||||
private void runJavaProcessExpectSuccessExitCode(String ... command) throws Throwable {
|
||||
var processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(command)
|
||||
var processBuilder = ProcessTools.createTestJavaProcessBuilder(command)
|
||||
.directory(Paths.get(Utils.TEST_CLASSES).toFile());
|
||||
ProcessTools.executeCommand(processBuilder).shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,13 +25,13 @@
|
||||
* @test
|
||||
* @summary The RMI benchmark test. This java class is used to run the test
|
||||
* under JTREG.
|
||||
* @library ../../../../testlibrary ../../
|
||||
* @library ../../../../testlibrary ../../ /test/lib
|
||||
* @modules java.desktop
|
||||
* java.rmi/sun.rmi.registry
|
||||
* java.rmi/sun.rmi.server
|
||||
* java.rmi/sun.rmi.transport
|
||||
* java.rmi/sun.rmi.transport.tcp
|
||||
* @build TestLibrary bench.BenchInfo bench.HtmlReporter bench.Util
|
||||
* @build TestLibrary bench.BenchInfo bench.HtmlReporter bench.Util jdk.test.lib.process.ProcessTools
|
||||
* bench.Benchmark bench.Reporter bench.XmlReporter bench.ConfigFormatException
|
||||
* bench.Harness bench.TextReporter bench.rmi.BenchServer
|
||||
* bench.rmi.DoubleArrayCalls bench.rmi.LongCalls bench.rmi.ShortCalls
|
||||
@ -51,19 +51,12 @@
|
||||
|
||||
package bench.rmi;
|
||||
|
||||
import bench.ConfigFormatException;
|
||||
import bench.Harness;
|
||||
import bench.HtmlReporter;
|
||||
import bench.Reporter;
|
||||
import bench.TextReporter;
|
||||
import bench.XmlReporter;
|
||||
import static bench.rmi.Main.OutputFormat.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.rmi.AlreadyBoundException;
|
||||
@ -77,6 +70,18 @@ import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import bench.ConfigFormatException;
|
||||
import bench.Harness;
|
||||
import bench.HtmlReporter;
|
||||
import bench.Reporter;
|
||||
import bench.TextReporter;
|
||||
import bench.XmlReporter;
|
||||
import static bench.rmi.Main.OutputFormat.HTML;
|
||||
import static bench.rmi.Main.OutputFormat.TEXT;
|
||||
import static bench.rmi.Main.OutputFormat.XML;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
/**
|
||||
* RMI/Serialization benchmark tests.
|
||||
*/
|
||||
@ -234,13 +239,6 @@ public class Main {
|
||||
//Setup for client mode, server will fork client process
|
||||
//after its initiation.
|
||||
List<String> clientProcessStr = new ArrayList<>();
|
||||
clientProcessStr.add(System.getProperty("test.jdk") +
|
||||
File.separator + "bin" + File.separator + "java");
|
||||
String classpath = System.getProperty("java.class.path");
|
||||
if (classpath != null) {
|
||||
clientProcessStr.add("-cp");
|
||||
clientProcessStr.add(classpath);
|
||||
}
|
||||
clientProcessStr.add("-Djava.security.policy=" + TEST_SRC_PATH + "policy.all");
|
||||
clientProcessStr.add("-Djava.security.manager=allow");
|
||||
clientProcessStr.add("-Dtest.src=" + TEST_SRC_PATH);
|
||||
@ -276,20 +274,13 @@ public class Main {
|
||||
}
|
||||
|
||||
try {
|
||||
Process client = new ProcessBuilder(clientProcessStr).
|
||||
inheritIO().start();
|
||||
try {
|
||||
client.waitFor();
|
||||
int exitValue = client.exitValue();
|
||||
if (0 != exitValue) {
|
||||
die("Error: error happened in client process, exitValue = " + exitValue);
|
||||
}
|
||||
} finally {
|
||||
client.destroyForcibly();
|
||||
}
|
||||
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(clientProcessStr);
|
||||
OutputAnalyzer outputAnalyzer = ProcessTools.executeProcess(pb);
|
||||
System.out.println(outputAnalyzer.getOutput());
|
||||
outputAnalyzer.shouldHaveExitValue(0);
|
||||
} catch (IOException ex) {
|
||||
die("Error: Unable start client process, ex=" + ex.getMessage());
|
||||
} catch (InterruptedException ex) {
|
||||
} catch (Exception ex) {
|
||||
die("Error: Error happening to client process, ex=" + ex.getMessage());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,6 +24,8 @@
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import tests.Helper;
|
||||
import tests.JImageGenerator;
|
||||
|
||||
@ -32,12 +34,12 @@ import tests.JImageGenerator;
|
||||
* @summary Tests whether a custom Hijrah configuration properties file works correctly
|
||||
* @bug 8187987
|
||||
* @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g)
|
||||
* @library /tools/lib
|
||||
* @library /tools/lib /test/lib
|
||||
* @enablePreview
|
||||
* @modules java.base/jdk.internal.jimage
|
||||
* jdk.jlink/jdk.tools.jimage
|
||||
* jdk.compiler
|
||||
* @build HijrahConfigCheck tests.*
|
||||
* @build HijrahConfigCheck tests.* jdk.test.lib.compiler.CompilerUtils jdk.test.lib.process.ProcessTools
|
||||
* @run main/othervm -Xmx1g HijrahConfigTest
|
||||
*/
|
||||
public class HijrahConfigTest {
|
||||
@ -66,13 +68,7 @@ public class HijrahConfigTest {
|
||||
|
||||
// Run tests
|
||||
Path launcher = outputPath.resolve("bin").resolve("java");
|
||||
ProcessBuilder builder = new ProcessBuilder(
|
||||
launcher.toAbsolutePath().toString(), "-ea", "-esa", "HijrahConfigCheck");
|
||||
Process p = builder.inheritIO().start();
|
||||
p.waitFor();
|
||||
int exitValue = p.exitValue();
|
||||
if (exitValue != 0) {
|
||||
throw new RuntimeException("HijrahConfigTest failed. Exit value: " + exitValue);
|
||||
}
|
||||
OutputAnalyzer analyzer = ProcessTools.executeCommand(launcher.toAbsolutePath().toString(), "-ea", "-esa", "HijrahConfigCheck");
|
||||
analyzer.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,23 +21,38 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.naming.Context;
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.SequenceInputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import javax.naming.Context;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -45,6 +60,9 @@ import static java.util.Collections.singletonMap;
|
||||
* @summary Examines different ways JNDI providers can hook up themselves and
|
||||
* become available. Each case mimics the most straightforward way of
|
||||
* executing scenarios.
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.process.ProcessTools
|
||||
* @run main InitialContextTest
|
||||
*/
|
||||
public class InitialContextTest {
|
||||
|
||||
@ -243,9 +261,13 @@ public class InitialContextTest {
|
||||
|
||||
private static void jar(Path jarName, Path jarRoot) {
|
||||
String jar = getJDKTool("jar");
|
||||
ProcessBuilder p = new ProcessBuilder(jar, "cf", jarName.toString(),
|
||||
"-C", jarRoot.toString(), ".");
|
||||
quickFail(run(p));
|
||||
String [] commands = {jar, "cf", jarName.toString(),"-C", jarRoot.toString(), "."};
|
||||
try {
|
||||
OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(commands);
|
||||
outputAnalyzer.shouldHaveExitValue(0);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void javac(Path compilationOutput, Path... sourceFiles) {
|
||||
@ -256,22 +278,18 @@ public class InitialContextTest {
|
||||
commands.addAll(paths.stream()
|
||||
.map(Path::toString)
|
||||
.collect(Collectors.toList()));
|
||||
quickFail(run(new ProcessBuilder(commands)));
|
||||
}
|
||||
|
||||
private static void quickFail(Result r) {
|
||||
if (r.exitValue != 0)
|
||||
throw new RuntimeException(r.output);
|
||||
try {
|
||||
OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(commands.toArray(new String[commands.size()]));
|
||||
outputAnalyzer.shouldHaveExitValue(0);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static Result java(Map<String, String> properties,
|
||||
Collection<Path> classpath,
|
||||
String classname) {
|
||||
|
||||
String java = getJDKTool("java");
|
||||
|
||||
List<String> commands = new ArrayList<>();
|
||||
commands.add(java);
|
||||
commands.addAll(properties.entrySet()
|
||||
.stream()
|
||||
.map(e -> "-D" + e.getKey() + "=" + e.getValue())
|
||||
@ -283,35 +301,14 @@ public class InitialContextTest {
|
||||
commands.add("-cp");
|
||||
commands.add(cp);
|
||||
commands.add(classname);
|
||||
|
||||
return run(new ProcessBuilder(commands));
|
||||
}
|
||||
|
||||
private static Result run(ProcessBuilder b) {
|
||||
Process p = null;
|
||||
try {
|
||||
p = b.start();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(
|
||||
format("Couldn't start process '%s'", b.command()), e);
|
||||
}
|
||||
|
||||
String output;
|
||||
try {
|
||||
output = toString(p.getInputStream(), p.getErrorStream());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(
|
||||
format("Couldn't read process output '%s'", b.command()), e);
|
||||
}
|
||||
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(commands);
|
||||
|
||||
try {
|
||||
p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(
|
||||
format("Process hasn't finished '%s'", b.command()), e);
|
||||
OutputAnalyzer outputAnalyzer = ProcessTools.executeProcess(pb);
|
||||
return new Result(outputAnalyzer.getExitValue(), outputAnalyzer.getOutput());
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
return new Result(p.exitValue(), output);
|
||||
}
|
||||
|
||||
private static String getJDKTool(String name) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,19 @@
|
||||
/* @test
|
||||
* @bug 4359123
|
||||
* @summary Test loading of classes with # in the path
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.process.ProcessTools
|
||||
* @run main EscapePath
|
||||
*/
|
||||
import java.io.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class EscapePath {
|
||||
|
||||
@ -75,14 +86,19 @@ public class EscapePath {
|
||||
fos.close();
|
||||
}
|
||||
|
||||
private static void invokeJava() throws Exception {
|
||||
String command = System.getProperty("java.home") +
|
||||
File.separator + "bin" + File.separator +
|
||||
"java -classpath " + "a#b/ Hello";
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
p.waitFor();
|
||||
int result = p.exitValue();
|
||||
if (result != 0)
|
||||
throw new RuntimeException("Path encoding failure.");
|
||||
private static void invokeJava() {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
commands.add("-classpath");
|
||||
commands.add("a#b");
|
||||
commands.add("Hello");
|
||||
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(commands);
|
||||
|
||||
try {
|
||||
OutputAnalyzer outputAnalyzer = ProcessTools.executeProcess(pb);
|
||||
outputAnalyzer.shouldHaveExitValue(0);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user