Skip to content

Commit 26b5708

Browse files
author
Matthew Donovan
committed
8360882: Tests throw SkippedException when they should fail
Reviewed-by: mullan
1 parent 77a71c5 commit 26b5708

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

test/jdk/sun/security/pkcs11/PKCS11Test.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,12 @@ private static Path fetchNssLib(String osId, Path libraryName) throws IOExceptio
779779
}
780780

781781
private static Path fetchNssLib(Class<?> clazz, Path libraryName) throws IOException {
782-
Path p = ArtifactResolver.fetchOne(clazz);
782+
Path p;
783+
try {
784+
p = ArtifactResolver.fetchOne(clazz);
785+
} catch (IOException exc) {
786+
throw new SkippedException("Could not find NSS", exc);
787+
}
783788
return findNSSLibrary(p, libraryName);
784789
}
785790

test/lib/jdk/test/lib/artifacts/ArtifactResolver.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
package jdk.test.lib.artifacts;
2525

26-
import jtreg.SkippedException;
27-
26+
import java.io.IOException;
2827
import java.nio.file.Path;
2928
import java.util.HashMap;
3029
import java.util.Map;
@@ -90,15 +89,15 @@ public static Path resolve(String name, Map<String, Object> artifactDescription,
9089
* @return the local path to the artifact. If the artifact is a compressed
9190
* file that gets unpacked, this path will point to the root
9291
* directory of the uncompressed file(s).
93-
* @throws SkippedException thrown if the artifact cannot be found
92+
* @throws IOException thrown if the artifact cannot be found
9493
*/
95-
public static Path fetchOne(Class<?> klass) {
94+
public static Path fetchOne(Class<?> klass) throws IOException {
9695
try {
9796
return ArtifactResolver.resolve(klass).entrySet().stream()
9897
.findAny().get().getValue();
9998
} catch (ArtifactResolverException e) {
10099
Artifact artifact = klass.getAnnotation(Artifact.class);
101-
throw new SkippedException("Cannot find the artifact " + artifact.name(), e);
100+
throw new IOException("Cannot find the artifact " + artifact.name(), e);
102101
}
103102
}
104103

test/lib/jdk/test/lib/security/OpensslArtifactFetcher.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
package jdk.test.lib.security;
2525

26+
import java.io.IOException;
2627
import java.nio.file.Path;
2728
import jdk.test.lib.Platform;
2829
import jdk.test.lib.process.ProcessTools;
@@ -49,42 +50,40 @@ public class OpensslArtifactFetcher {
4950
*
5051
* @return openssl binary path of the current version
5152
* @throws SkippedException if a valid version of OpenSSL cannot be found
53+
* or if OpenSSL is not available on the target platform
5254
*/
5355
public static String getOpensslPath() {
5456
String path = getOpensslFromSystemProp(OPENSSL_BUNDLE_VERSION);
5557
if (path != null) {
58+
System.out.println("Using OpenSSL from system property.");
5659
return path;
5760
}
61+
5862
path = getDefaultSystemOpensslPath(OPENSSL_BUNDLE_VERSION);
5963
if (path != null) {
64+
System.out.println("Using OpenSSL from system.");
6065
return path;
6166
}
67+
6268
if (Platform.isX64()) {
6369
if (Platform.isLinux()) {
64-
path = fetchOpenssl(LINUX_X64.class);
70+
return fetchOpenssl(LINUX_X64.class);
6571
} else if (Platform.isOSX()) {
66-
path = fetchOpenssl(MACOSX_X64.class);
72+
return fetchOpenssl(MACOSX_X64.class);
6773
} else if (Platform.isWindows()) {
68-
path = fetchOpenssl(WINDOWS_X64.class);
74+
return fetchOpenssl(WINDOWS_X64.class);
6975
}
7076
} else if (Platform.isAArch64()) {
7177
if (Platform.isLinux()) {
72-
path = fetchOpenssl(LINUX_AARCH64.class);
78+
return fetchOpenssl(LINUX_AARCH64.class);
7379
}
7480
if (Platform.isOSX()) {
75-
path = fetchOpenssl(MACOSX_AARCH64.class);
81+
return fetchOpenssl(MACOSX_AARCH64.class);
7682
}
7783
}
7884

79-
if (!verifyOpensslVersion(path, OPENSSL_BUNDLE_VERSION)) {
80-
String exMsg = "Can't find the version: "
81-
+ OpensslArtifactFetcher.getTestOpensslBundleVersion()
82-
+ " of openssl binary on this machine, please install"
83-
+ " and set openssl path with property 'test.openssl.path'";
84-
throw new SkippedException(exMsg);
85-
} else {
86-
return path;
87-
}
85+
throw new SkippedException(String.format("No OpenSSL %s found for %s/%s",
86+
OPENSSL_BUNDLE_VERSION, Platform.getOsName(), Platform.getOsArch()));
8887
}
8988

9089
private static String getOpensslFromSystemProp(String version) {
@@ -120,9 +119,13 @@ private static boolean verifyOpensslVersion(String path, String version) {
120119
}
121120

122121
private static String fetchOpenssl(Class<?> clazz) {
123-
return ArtifactResolver.fetchOne(clazz)
124-
.resolve("openssl", "bin", "openssl")
125-
.toString();
122+
try {
123+
return ArtifactResolver.fetchOne(clazz)
124+
.resolve("openssl", "bin", "openssl")
125+
.toString();
126+
} catch (IOException exc) {
127+
throw new SkippedException("Could not find openssl", exc);
128+
}
126129
}
127130

128131
// retrieve the provider directory path from <OPENSSL_HOME>/bin/openssl

0 commit comments

Comments
 (0)