Skip to content

Commit

Permalink
1. Just catch the IOException here when getting the FileStore and ski…
Browse files Browse the repository at this point in the history
…p the test instead of checking for specific exception messages. 2. Throw a org.testng.SkipException instead print and return
  • Loading branch information
sendaoYan committed Jul 25, 2024
1 parent 8931deb commit 9c7946f
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions test/jdk/java/lang/invoke/lambda/LogGeneratedClassesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/*
* @test
* @bug 8023524 8304846 8335150
* @bug 8023524 8304846
* @requires vm.flagless
* @library /test/lib/
* @library /java/nio/file
Expand All @@ -48,6 +48,7 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.SkipException;

import static java.nio.file.attribute.PosixFilePermissions.*;
import static jdk.test.lib.process.ProcessTools.*;
Expand Down Expand Up @@ -212,22 +213,12 @@ public void testDumpDirNotWritable() throws Exception {
try {
fs = Files.getFileStore(Paths.get("."));
} catch (IOException e) {
if (e.getMessage().contains("Mount point not found")) {
// We would like to skip the test with a cause with
// throw new SkipException("Mount point not found");
// but jtreg will report failure so we just pass the test
// which we can look at if jtreg changed its behavior
System.out.println("Mount point not found. Skipping testDumpDirNotWritable test.");
return;
} else {
throw e;
}
e.printStackTrace();
throw new SkipException("WARNING: IOException occur. Skipping testDumpDirNotWritable test.");
}
if (!fs.supportsFileAttributeView(PosixFileAttributeView.class)) {
// No easy way to setup readonly directory without POSIX
// Same as above, return instead of throw SkipException("Posix not supported")
System.out.println("WARNING: POSIX is not supported. Skipping testDumpDirNotWritable test.");
return;
throw new SkipException("WARNING: POSIX is not supported. Skipping testDumpDirNotWritable test.");
}

Path testDir = Path.of("readOnly");
Expand All @@ -239,8 +230,7 @@ public void testDumpDirNotWritable() throws Exception {
if (isWriteableDirectory(dumpDir)) {
// Skipping the test: it's allowed to write into read-only directory
// (e.g. current user is super user).
System.out.println("WARNING: The dump directory is writeable. Skipping testDumpDirNotWritable test.");
return;
throw new SkipException("WARNING: The dump directory is writeable. Skipping testDumpDirNotWritable test.");
}

ProcessBuilder pb = createLimitedTestJavaProcessBuilder(
Expand Down

0 comments on commit 9c7946f

Please sign in to comment.