mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8360882: Tests throw SkippedException when they should fail
Reviewed-by: mullan
This commit is contained in:
parent
77a71c5b09
commit
26b5708c47
@ -779,7 +779,12 @@ public abstract class PKCS11Test {
|
||||
}
|
||||
|
||||
private static Path fetchNssLib(Class<?> clazz, Path libraryName) throws IOException {
|
||||
Path p = ArtifactResolver.fetchOne(clazz);
|
||||
Path p;
|
||||
try {
|
||||
p = ArtifactResolver.fetchOne(clazz);
|
||||
} catch (IOException exc) {
|
||||
throw new SkippedException("Could not find NSS", exc);
|
||||
}
|
||||
return findNSSLibrary(p, libraryName);
|
||||
}
|
||||
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
|
||||
package jdk.test.lib.artifacts;
|
||||
|
||||
import jtreg.SkippedException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -90,15 +89,15 @@ public class ArtifactResolver {
|
||||
* @return the local path to the artifact. If the artifact is a compressed
|
||||
* file that gets unpacked, this path will point to the root
|
||||
* directory of the uncompressed file(s).
|
||||
* @throws SkippedException thrown if the artifact cannot be found
|
||||
* @throws IOException thrown if the artifact cannot be found
|
||||
*/
|
||||
public static Path fetchOne(Class<?> klass) {
|
||||
public static Path fetchOne(Class<?> klass) throws IOException {
|
||||
try {
|
||||
return ArtifactResolver.resolve(klass).entrySet().stream()
|
||||
.findAny().get().getValue();
|
||||
} catch (ArtifactResolverException e) {
|
||||
Artifact artifact = klass.getAnnotation(Artifact.class);
|
||||
throw new SkippedException("Cannot find the artifact " + artifact.name(), e);
|
||||
throw new IOException("Cannot find the artifact " + artifact.name(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
package jdk.test.lib.security;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
@ -49,42 +50,40 @@ public class OpensslArtifactFetcher {
|
||||
*
|
||||
* @return openssl binary path of the current version
|
||||
* @throws SkippedException if a valid version of OpenSSL cannot be found
|
||||
* or if OpenSSL is not available on the target platform
|
||||
*/
|
||||
public static String getOpensslPath() {
|
||||
String path = getOpensslFromSystemProp(OPENSSL_BUNDLE_VERSION);
|
||||
if (path != null) {
|
||||
System.out.println("Using OpenSSL from system property.");
|
||||
return path;
|
||||
}
|
||||
|
||||
path = getDefaultSystemOpensslPath(OPENSSL_BUNDLE_VERSION);
|
||||
if (path != null) {
|
||||
System.out.println("Using OpenSSL from system.");
|
||||
return path;
|
||||
}
|
||||
|
||||
if (Platform.isX64()) {
|
||||
if (Platform.isLinux()) {
|
||||
path = fetchOpenssl(LINUX_X64.class);
|
||||
return fetchOpenssl(LINUX_X64.class);
|
||||
} else if (Platform.isOSX()) {
|
||||
path = fetchOpenssl(MACOSX_X64.class);
|
||||
return fetchOpenssl(MACOSX_X64.class);
|
||||
} else if (Platform.isWindows()) {
|
||||
path = fetchOpenssl(WINDOWS_X64.class);
|
||||
return fetchOpenssl(WINDOWS_X64.class);
|
||||
}
|
||||
} else if (Platform.isAArch64()) {
|
||||
if (Platform.isLinux()) {
|
||||
path = fetchOpenssl(LINUX_AARCH64.class);
|
||||
return fetchOpenssl(LINUX_AARCH64.class);
|
||||
}
|
||||
if (Platform.isOSX()) {
|
||||
path = fetchOpenssl(MACOSX_AARCH64.class);
|
||||
return fetchOpenssl(MACOSX_AARCH64.class);
|
||||
}
|
||||
}
|
||||
|
||||
if (!verifyOpensslVersion(path, OPENSSL_BUNDLE_VERSION)) {
|
||||
String exMsg = "Can't find the version: "
|
||||
+ OpensslArtifactFetcher.getTestOpensslBundleVersion()
|
||||
+ " of openssl binary on this machine, please install"
|
||||
+ " and set openssl path with property 'test.openssl.path'";
|
||||
throw new SkippedException(exMsg);
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
throw new SkippedException(String.format("No OpenSSL %s found for %s/%s",
|
||||
OPENSSL_BUNDLE_VERSION, Platform.getOsName(), Platform.getOsArch()));
|
||||
}
|
||||
|
||||
private static String getOpensslFromSystemProp(String version) {
|
||||
@ -120,9 +119,13 @@ public class OpensslArtifactFetcher {
|
||||
}
|
||||
|
||||
private static String fetchOpenssl(Class<?> clazz) {
|
||||
return ArtifactResolver.fetchOne(clazz)
|
||||
.resolve("openssl", "bin", "openssl")
|
||||
.toString();
|
||||
try {
|
||||
return ArtifactResolver.fetchOne(clazz)
|
||||
.resolve("openssl", "bin", "openssl")
|
||||
.toString();
|
||||
} catch (IOException exc) {
|
||||
throw new SkippedException("Could not find openssl", exc);
|
||||
}
|
||||
}
|
||||
|
||||
// retrieve the provider directory path from <OPENSSL_HOME>/bin/openssl
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user