You need to sign in or sign up before continuing.
提交 bf3ca964 编写于 作者: J jbachorik

8230448: [test] JFRSecurityTestSuite.java is failing on Windows

Reviewed-by: neugens
上级 eb332e67
...@@ -63,9 +63,13 @@ import jdk.jfr.Name; ...@@ -63,9 +63,13 @@ import jdk.jfr.Name;
import jdk.jfr.Recording; import jdk.jfr.Recording;
import jdk.jfr.ValueDescriptor; import jdk.jfr.ValueDescriptor;
import jdk.test.lib.Platform;
/* /*
* @test * @test
* @requires (jdk.version.major >= 8) * @requires (jdk.version.major >= 8)
* @library /lib /
* @key jfr
* @run main/othervm/timeout=30 -XX:+FlightRecorder -XX:StartFlightRecording JFRSecurityTestSuite * @run main/othervm/timeout=30 -XX:+FlightRecorder -XX:StartFlightRecording JFRSecurityTestSuite
* @author Martin Balao (mbalao@redhat.com) * @author Martin Balao (mbalao@redhat.com)
*/ */
...@@ -77,6 +81,7 @@ public class JFRSecurityTestSuite { ...@@ -77,6 +81,7 @@ public class JFRSecurityTestSuite {
private static String failureMessage = null; private static String failureMessage = null;
private static Path jfrTmpDirPath = null; private static Path jfrTmpDirPath = null;
private static Path recFilePath = null; private static Path recFilePath = null;
private static String protectedLocationPath;
interface F { interface F {
void call() throws Exception; void call() throws Exception;
...@@ -136,6 +141,8 @@ public class JFRSecurityTestSuite { ...@@ -136,6 +141,8 @@ public class JFRSecurityTestSuite {
jfrTmpDirPath = Files.createTempDirectory("jfr_test"); jfrTmpDirPath = Files.createTempDirectory("jfr_test");
try { try {
setProtectedLocation();
File recFile = new File(jfrTmpDirPath.toString(), "rec"); File recFile = new File(jfrTmpDirPath.toString(), "rec");
recFile.createNewFile(); recFile.createNewFile();
recFilePath = recFile.toPath(); recFilePath = recFile.toPath();
...@@ -219,10 +226,19 @@ public class JFRSecurityTestSuite { ...@@ -219,10 +226,19 @@ public class JFRSecurityTestSuite {
} }
} }
private static void doInConstrainedEnvironment() throws Throwable { private static void setProtectedLocation() {
if (Platform.isWindows()) {
final String testPath = "/etc"; protectedLocationPath = System.getenv("%WINDIR%");
if (protectedLocationPath == null) {
// fallback
protectedLocationPath = "c:\\windows";
}
} else {
protectedLocationPath = "/etc";
}
}
private static void doInConstrainedEnvironment() throws Throwable {
checkNoDirectAccess(); checkNoDirectAccess();
assertPermission(() -> { assertPermission(() -> {
...@@ -258,8 +274,8 @@ public class JFRSecurityTestSuite { ...@@ -258,8 +274,8 @@ public class JFRSecurityTestSuite {
}, FlightRecorderPermission.class, "registerEvent", true); }, FlightRecorderPermission.class, "registerEvent", true);
assertPermission(() -> { assertPermission(() -> {
Configuration.create(Paths.get(testPath)); Configuration.create(Paths.get(protectedLocationPath));
}, FilePermission.class, testPath, false); }, FilePermission.class, protectedLocationPath, false);
assertPermission(() -> { assertPermission(() -> {
EventFactory.create(new ArrayList<AnnotationElement>(), EventFactory.create(new ArrayList<AnnotationElement>(),
...@@ -280,12 +296,12 @@ public class JFRSecurityTestSuite { ...@@ -280,12 +296,12 @@ public class JFRSecurityTestSuite {
}, FlightRecorderPermission.class, "accessFlightRecorder", false); }, FlightRecorderPermission.class, "accessFlightRecorder", false);
assertPermission(() -> { assertPermission(() -> {
new RecordingFile(Paths.get(testPath)); new RecordingFile(Paths.get(protectedLocationPath));
}, FilePermission.class, testPath, false); }, FilePermission.class, protectedLocationPath, false);
assertPermission(() -> { assertPermission(() -> {
RecordingFile.readAllEvents(Paths.get(testPath)); RecordingFile.readAllEvents(Paths.get(protectedLocationPath));
}, FilePermission.class, testPath, false); }, FilePermission.class, protectedLocationPath, false);
assertPermission(() -> { assertPermission(() -> {
EventType.getEventType(MyEvent2.class); EventType.getEventType(MyEvent2.class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册