Skip to content

Commit da8e41a

Browse files
committed
8365623: test/jdk/sun/security/pkcs11/tls/ tests skipped without skip exception
Reviewed-by: syan, rhalade
1 parent 561c544 commit da8e41a

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

‎test/jdk/sun/security/pkcs11/tls/TestKeyMaterial.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
3535
import java.io.BufferedReader;
3636
import java.nio.file.Files;
3737
import java.nio.file.Paths;
38-
import java.security.InvalidAlgorithmParameterException;
3938
import java.security.Provider;
4039
import java.security.ProviderException;
4140
import java.util.Arrays;
@@ -45,6 +44,7 @@
4544
import javax.crypto.spec.IvParameterSpec;
4645
import javax.crypto.spec.SecretKeySpec;
4746

47+
import jtreg.SkippedException;
4848
import sun.security.internal.spec.TlsKeyMaterialParameterSpec;
4949
import sun.security.internal.spec.TlsKeyMaterialSpec;
5050

@@ -60,8 +60,7 @@ public static void main(String[] args) throws Exception {
6060
@Override
6161
public void main(Provider provider) throws Exception {
6262
if (provider.getService("KeyGenerator", "SunTlsKeyMaterial") == null) {
63-
System.out.println("Provider does not support algorithm, skipping");
64-
return;
63+
throw new SkippedException("Provider does not support algorithm, skipping");
6564
}
6665

6766
try (BufferedReader reader = Files.newBufferedReader(

‎test/jdk/sun/security/pkcs11/tls/TestKeyMaterialChaCha20.java‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import javax.crypto.SecretKey;
3636
import java.security.Provider;
3737
import java.security.NoSuchAlgorithmException;
38+
39+
import jtreg.SkippedException;
3840
import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
3941
import sun.security.internal.spec.TlsMasterSecretParameterSpec;
4042
import sun.security.internal.spec.TlsKeyMaterialParameterSpec;
@@ -52,20 +54,17 @@ public void main(Provider provider) throws Exception {
5254
try {
5355
kg1 = KeyGenerator.getInstance("SunTlsRsaPremasterSecret", provider);
5456
} catch (Exception e) {
55-
System.out.println("Skipping, SunTlsRsaPremasterSecret KeyGenerator not supported");
56-
return;
57+
throw new SkippedException("Skipping, SunTlsRsaPremasterSecret KeyGenerator not supported");
5758
}
5859
try {
5960
kg2 = KeyGenerator.getInstance("SunTls12MasterSecret", provider);
6061
} catch (Exception e) {
61-
System.out.println("Skipping, SunTls12MasterSecret KeyGenerator not supported");
62-
return;
62+
throw new SkippedException("Skipping, SunTls12MasterSecret KeyGenerator not supported");
6363
}
6464
try {
6565
kg3 = KeyGenerator.getInstance("SunTls12KeyMaterial", provider);
6666
} catch (Exception e) {
67-
System.out.println("Skipping, SunTls12KeyMaterial KeyGenerator not supported");
68-
return;
67+
throw new SkippedException("Skipping, SunTls12KeyMaterial KeyGenerator not supported");
6968
}
7069

7170
kg1.init(new TlsRsaPremasterSecretParameterSpec(0x0303, 0x0303));

‎test/jdk/sun/security/pkcs11/tls/TestMasterSecret.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,8 @@
4242
import javax.crypto.KeyGenerator;
4343
import javax.crypto.SecretKey;
4444
import javax.crypto.spec.SecretKeySpec;
45+
46+
import jtreg.SkippedException;
4547
import sun.security.internal.interfaces.TlsMasterSecret;
4648
import sun.security.internal.spec.TlsMasterSecretParameterSpec;
4749

@@ -56,8 +58,7 @@ public static void main(String[] args) throws Exception {
5658
@Override
5759
public void main(Provider provider) throws Exception {
5860
if (provider.getService("KeyGenerator", "SunTlsMasterSecret") == null) {
59-
System.out.println("Not supported by provider, skipping");
60-
return;
61+
throw new SkippedException("Not supported by provider, skipping");
6162
}
6263

6364
try (BufferedReader reader = Files.newBufferedReader(

‎test/jdk/sun/security/pkcs11/tls/TestPRF.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,8 @@
4040
import javax.crypto.KeyGenerator;
4141
import javax.crypto.SecretKey;
4242
import javax.crypto.spec.SecretKeySpec;
43+
44+
import jtreg.SkippedException;
4345
import sun.security.internal.spec.TlsPrfParameterSpec;
4446

4547
public class TestPRF extends PKCS11Test {
@@ -53,8 +55,7 @@ public static void main(String[] args) throws Exception {
5355
@Override
5456
public void main(Provider provider) throws Exception {
5557
if (provider.getService("KeyGenerator", "SunTlsPrf") == null) {
56-
System.out.println("Provider does not support algorithm, skipping");
57-
return;
58+
throw new SkippedException("Provider does not support algorithm, skipping");
5859
}
5960

6061
try (BufferedReader reader = Files.newBufferedReader(

‎test/jdk/sun/security/pkcs11/tls/TestPremaster.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,8 @@
3636
import java.security.InvalidAlgorithmParameterException;
3737
import javax.crypto.KeyGenerator;
3838
import javax.crypto.SecretKey;
39+
40+
import jtreg.SkippedException;
3941
import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
4042

4143
public class TestPremaster extends PKCS11Test {
@@ -48,8 +50,7 @@ public static void main(String[] args) throws Exception {
4850
public void main(Provider provider) throws Exception {
4951
if (provider.getService(
5052
"KeyGenerator", "SunTlsRsaPremasterSecret") == null) {
51-
System.out.println("Not supported by provider, skipping");
52-
return;
53+
throw new SkippedException("Not supported by provider, skipping");
5354
}
5455
KeyGenerator kg;
5556
kg = KeyGenerator.getInstance("SunTlsRsaPremasterSecret", provider);
@@ -87,8 +88,7 @@ private static void test(KeyGenerator kg,
8788
} catch (InvalidAlgorithmParameterException iape) {
8889
// S12 removed support for SSL v3.0
8990
if (clientVersion == 0x300 || serverVersion == 0x300) {
90-
System.out.println("Skip testing SSLv3 due to no support");
91-
return;
91+
throw new SkippedException("Skip testing SSLv3 due to no support");
9292
}
9393
// unexpected, pass it up
9494
throw iape;

‎test/jdk/sun/security/pkcs11/tls/fips/FipsModeTLS.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import javax.net.ssl.TrustManagerFactory;
7272

7373
import jdk.test.lib.security.SecurityUtils;
74+
import jtreg.SkippedException;
7475
import sun.security.internal.spec.TlsMasterSecretParameterSpec;
7576
import sun.security.internal.spec.TlsPrfParameterSpec;
7677
import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
@@ -94,12 +95,11 @@ public static void main(String[] args) throws Exception {
9495
try {
9596
initialize();
9697
} catch (Exception e) {
97-
System.out.println("Test skipped: failure during" +
98-
" initialization");
9998
if (enableDebug) {
10099
System.out.println(e);
101100
}
102-
return;
101+
throw new SkippedException("Test skipped: failure during" +
102+
" initialization");
103103
}
104104

105105
if (shouldRun()) {
@@ -112,8 +112,8 @@ public static void main(String[] args) throws Exception {
112112

113113
System.out.println("Test PASS - OK");
114114
} else {
115-
System.out.println("Test skipped: TLS 1.2 mechanisms" +
116-
" not supported by current SunPKCS11 back-end");
115+
throw new SkippedException("Test skipped: TLS 1.2 mechanisms" +
116+
" not supported by current SunPKCS11 back-end");
117117
}
118118
}
119119

0 commit comments

Comments
 (0)