From 566b95eedfcda8e4ded8d7a076042be5fb8fb556 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Fri, 22 Aug 2025 21:10:34 +0000 Subject: [PATCH 1/2] 8365983: Tests should throw SkippedException when SCTP not supported --- test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java | 15 ++++++++------- .../com/sun/nio/sctp/SctpChannel/CommUp.java | 15 ++++++++------- .../com/sun/nio/sctp/SctpChannel/Connect.java | 15 ++++++++------- .../com/sun/nio/sctp/SctpChannel/Receive.java | 16 ++++++++-------- .../nio/sctp/SctpChannel/ReceiveIntoDirect.java | 15 ++++++++------- test/jdk/com/sun/nio/sctp/SctpChannel/Send.java | 13 ++++++------- .../com/sun/nio/sctp/SctpChannel/Shutdown.java | 15 ++++++++------- .../nio/sctp/SctpChannel/SocketOptionTests.java | 15 ++++++++------- .../sun/nio/sctp/SctpMultiChannel/Branch.java | 15 ++++++++------- .../sctp/SctpMultiChannel/CloseDescriptors.java | 13 ++++++------- .../com/sun/nio/sctp/SctpMultiChannel/Send.java | 15 ++++++++------- .../nio/sctp/SctpMultiChannel/SendFailed.java | 15 ++++++++------- .../SctpMultiChannel/SocketOptionTests.java | 17 ++++++++++------- .../sun/nio/sctp/SctpServerChannel/Accept.java | 15 ++++++++------- .../SctpServerChannel/NonBlockingAccept.java | 15 ++++++++------- 15 files changed, 118 insertions(+), 106 deletions(-) diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java index 027f31695ae28..2eb11fa74586d 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -48,18 +49,14 @@ import com.sun.nio.sctp.ShutdownNotification; import static java.lang.System.out; +import jtreg.SkippedException; + /** * Tests bind, bindAddress, unbindAddress, getLocalAddress, and * getAllLocalAddresses. */ public class Bind { void test(String[] args) { - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - /* Simply bind tests */ testBind(); @@ -341,6 +338,10 @@ class UnsupportedSocketAddress extends SocketAddress { } void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java b/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java index 8cbe034b00df4..8f155ffaf2dcf 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 6863110 + * @library /test/lib * @summary Newly connected/accepted SctpChannel should fire OP_READ if registered with a Selector * @author chegar */ @@ -49,6 +50,8 @@ import static java.nio.channels.SelectionKey.OP_CONNECT; import static java.nio.channels.SelectionKey.OP_READ; +import jtreg.SkippedException; + public class CommUp { static CountDownLatch acceptLatch = new CountDownLatch(1); static final int TIMEOUT = 10000; @@ -61,12 +64,6 @@ public class CommUp { void test(String[] args) { SocketAddress address = null; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -355,6 +352,10 @@ public HandlerResult handleNotification( void sleep(long millis) { try { Thread.currentThread().sleep(millis); } catch(InterruptedException ie) { unexpected(ie); }} public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java index fccc12a9f067e..fb5f8c8d8f087 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -43,6 +44,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + /** * Tests connect, finishConnect, isConnectionPending, * getRemoteAddresses and association. @@ -50,12 +53,6 @@ public class Connect { void test(String[] args) { - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - doTest(); } @@ -235,6 +232,10 @@ void testCCE(Callable callable) { void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java index 23005bbf849c9..09af1d74d0806 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -48,6 +49,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + public class Receive { /* Latches used to synchronize between the client and server so that * connections without any IO may not be closed without being accepted */ @@ -61,13 +64,6 @@ void test(String[] args) { SocketAddress address = null; Server server; - - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -349,6 +345,10 @@ public HandlerResult handleNotification( void debug(String message) {if(debug) { System.out.println(Thread.currentThread() + " " + message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java b/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java index e7b23d0aaed41..e0c05baf1112c 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 8034181 + * @library /test/lib * @summary SIGBUS in SctpChannelImpl receive * @author chegar */ @@ -45,6 +46,8 @@ import static java.lang.System.err; import static java.nio.charset.StandardCharsets.US_ASCII; +import jtreg.SkippedException; + public class ReceiveIntoDirect { /* suitably small message to NOT overrun small buffers */ final byte[] msgBytes = "Hello".getBytes(US_ASCII); @@ -56,12 +59,6 @@ void test(String[] args) throws IOException { SocketAddress address = null; Server server; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -264,6 +261,10 @@ public HandlerResult handleNotification( void debug(String message) {if(debug) { System.out.println(Thread.currentThread() + " " + message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java index 93e462a1820b9..25c005bf906b2 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -60,12 +61,6 @@ void test(String[] args) { SocketAddress address = null; Server server = null; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -451,6 +446,10 @@ public HandlerResult handleNotification( void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java index 41ba744315c04..79eb603920713 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -43,6 +44,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + public class Shutdown { static CountDownLatch finishedLatch = new CountDownLatch(1); static CountDownLatch sentLatch = new CountDownLatch(1); @@ -51,12 +54,6 @@ void test(String[] args) { SocketAddress address = null; ShutdownServer server = null; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -272,6 +269,10 @@ public HandlerResult handleNotification( void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java b/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java index 052f9999e5708..501d16a976c87 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -43,6 +44,8 @@ import static com.sun.nio.sctp.SctpStandardSocketOptions.*; import static java.lang.System.out; +import jtreg.SkippedException; + public class SocketOptionTests { final String osName = AccessController.doPrivileged( (PrivilegedAction)() -> System.getProperty("os.name")); @@ -66,12 +69,6 @@ void optionalSupport(SctpChannel sc, SctpSocketOption name, } void test(String[] args) { - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - try (SctpChannel sc = SctpChannel.open()) { /* check supported options */ @@ -190,6 +187,10 @@ void sctpPrimaryAddr() throws IOException { void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java index ffd8eb361c337..bbf3dff954fcb 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -48,6 +49,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + public class Branch { /* Latches used to synchronize between the client and server so that * connections without any IO may not be closed without being accepted */ @@ -58,12 +61,6 @@ void test(String[] args) { SocketAddress address = null; Server server = null; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -277,6 +274,10 @@ public HandlerResult handleNotification( void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java index 0834031253242..b4f4a39e6df0c 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 8269481 + * @library /test/lib * @summary Tests that file descriptors are closed * @requires (os.family == "linux") * @run main/othervm CloseDescriptors @@ -38,6 +39,8 @@ import com.sun.nio.sctp.MessageInfo; import com.sun.nio.sctp.SctpMultiChannel; +import jtreg.SkippedException; + public class CloseDescriptors { private static final int NUM = 5; @@ -46,9 +49,7 @@ public class CloseDescriptors { public static void main(String[] args) throws Exception { if (!Util.isSCTPSupported()) { - System.out.println("SCTP protocol is not supported"); - System.out.println("Test cannot be run"); - return; + throw new jtreg.SkippedException("SCTP protocol is not supported"); } List lsofDirs = List.of("/usr/bin", "/usr/sbin"); @@ -57,9 +58,7 @@ public static void main(String[] args) throws Exception { .filter(f -> Files.isExecutable(f)) .findFirst(); if (!lsof.isPresent()) { - System.out.println("Cannot locate lsof in " + lsofDirs); - System.out.println("Test cannot be run"); - return; + throw new jtreg.SkippedException("Cannot locate lsof in " + lsofDirs); } try (ServerSocket ss = new ServerSocket(0)) { diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java index feb914a410e5d..699d8aa01c5ba 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -42,6 +43,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + public class Send { /* Latches used to synchronize between the client and server so that * connections without any IO may not be closed without being accepted */ @@ -52,12 +55,6 @@ void test(String[] args) { SocketAddress address = null; Server server = null; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -355,6 +352,10 @@ public void run() { void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java index 7ebbcfb607956..06d227e7d60b7 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 8067846 + * @library /test/lib * @summary Test for send failed notification */ @@ -35,6 +36,8 @@ import static java.lang.System.out; import static java.nio.ByteBuffer.*; +import jtreg.SkippedException; + public class SendFailed { static final SocketAddress remoteAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 3000); @@ -45,12 +48,6 @@ public class SendFailed { void test(String[] args) throws IOException { SocketAddress address = null; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - System.out.println("remote address: " + remoteAddress); System.out.println("Note, remote address should not be up"); @@ -186,6 +183,10 @@ static void assertSameContent(ByteBuffer bb1, ByteBuffer bb2) { void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message, Object... args) {if(debug) { out.printf(message, args); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java index 2da35d6eda5c0..285a214831c01 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -38,6 +39,8 @@ import java.nio.channels.ClosedChannelException; import com.sun.nio.sctp.AbstractNotificationHandler; import com.sun.nio.sctp.Association; +import com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams; + import com.sun.nio.sctp.AssociationChangeNotification; import com.sun.nio.sctp.AssociationChangeNotification.AssocChangeEvent; import com.sun.nio.sctp.HandlerResult; @@ -51,6 +54,8 @@ import static com.sun.nio.sctp.SctpStandardSocketOptions.*; import static java.lang.System.out; +import jtreg.SkippedException; + public class SocketOptionTests { final String osName = AccessController.doPrivileged( (PrivilegedAction)() -> System.getProperty("os.name")); @@ -74,12 +79,6 @@ void optionalSupport(SctpMultiChannel smc, SctpSocketOption name, } void test(String[] args) { - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - try { SctpMultiChannel smc = SctpMultiChannel.open(); @@ -244,6 +243,10 @@ public HandlerResult handleNotification( void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java b/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java index 99d6e26c93959..91645099c3cf8 100644 --- a/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java +++ b/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -41,6 +42,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + public class Accept { static CountDownLatch acceptLatch = new CountDownLatch(1); static CountDownLatch closeByIntLatch = new CountDownLatch(1); @@ -50,12 +53,6 @@ public class Accept { void test(String[] args) { SocketAddress address = null; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -262,6 +259,10 @@ static class TestSocketAddress extends SocketAddress {} void join(Thread thread, long millis) { try { thread.join(millis); } catch(InterruptedException ie) { unexpected(ie); }} public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} diff --git a/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java b/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java index 49ba4d64b5bcf..d4cf4c04ed85c 100644 --- a/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java +++ b/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* @test * @bug 4927640 + * @library /test/lib * @summary Tests the SCTP protocol implementation * @author chegar */ @@ -42,6 +43,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + public class NonBlockingAccept { static CountDownLatch acceptLatch = new CountDownLatch(1); static final int SEL_TIMEOUT = 10000; @@ -51,12 +54,6 @@ void test(String[] args) { SocketAddress address = null; NonblockingServer server; - if (!Util.isSCTPSupported()) { - out.println("SCTP protocol is not supported"); - out.println("Test cannot be run"); - return; - } - if (args.length == 2) { /* requested to connecct to a specific address */ try { @@ -218,6 +215,10 @@ static class TestSocketAddress extends SocketAddress {} void sleep(long millis) { try { Thread.currentThread().sleep(millis); } catch(InterruptedException ie) { unexpected(ie); }} public static void main(String[] args) throws Throwable { + if (!Util.isSCTPSupported()) { + throw new jtreg.SkippedException("SCTP protocol is not supported"); + } + Class k = new Object(){}.getClass().getEnclosingClass(); try {k.getMethod("instanceMain",String[].class) .invoke( k.newInstance(), (Object) args);} From eb1b137f0bebd9c3cad83678d868c3787810a8e4 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Sat, 23 Aug 2025 10:13:58 +0000 Subject: [PATCH 2/2] Replace "throw new jtreg.SkippedException" ad "throw new SkippedException" --- test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java | 2 +- test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java | 6 ++++-- test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java | 2 +- test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java | 2 +- test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java | 2 +- .../jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java | 2 +- test/jdk/com/sun/nio/sctp/SctpChannel/Send.java | 4 +++- test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java | 2 +- .../jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java | 2 +- test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java | 4 ++-- .../com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java | 4 ++-- test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java | 2 +- test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java | 2 +- .../sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java | 2 +- test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java | 2 +- .../sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java | 2 +- 16 files changed, 23 insertions(+), 19 deletions(-) diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java index 2eb11fa74586d..ff5ca00846c72 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Bind.java @@ -339,7 +339,7 @@ class UnsupportedSocketAddress extends SocketAddress { } void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java b/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java index 0b3ce6ae03926..33b68fafd520a 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java @@ -45,6 +45,8 @@ import com.sun.nio.sctp.SctpChannel; import com.sun.nio.sctp.SctpServerChannel; +import jtreg.SkippedException; + public class CloseDescriptors { private static Selector selector; private static final int LOOP = 10; @@ -54,7 +56,7 @@ public class CloseDescriptors { public static void main(String[] args) throws Exception { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } List lsofDirs = List.of("/usr/bin", "/usr/sbin"); @@ -63,7 +65,7 @@ public static void main(String[] args) throws Exception { .filter(f -> Files.isExecutable(f)) .findFirst(); if (!lsof.isPresent()) { - throw new jtreg.SkippedException("Cannot locate lsof in " + lsofDirs); + throw new SkippedException("Cannot locate lsof in " + lsofDirs); } try (ServerSocket ss = new ServerSocket(0)) { diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java b/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java index 8f155ffaf2dcf..320e556f800c2 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/CommUp.java @@ -353,7 +353,7 @@ public HandlerResult handleNotification( catch(InterruptedException ie) { unexpected(ie); }} public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java index fb5f8c8d8f087..5afa6fe866c44 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Connect.java @@ -233,7 +233,7 @@ void testCCE(Callable callable) { void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java index 09af1d74d0806..48eb413a9ca75 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Receive.java @@ -346,7 +346,7 @@ void debug(String message) {if(debug) { System.out.println(Thread.currentThread() + " " + message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java b/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java index e0c05baf1112c..48d89c34ca4a3 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java @@ -262,7 +262,7 @@ void debug(String message) {if(debug) { System.out.println(Thread.currentThread() + " " + message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java index 25c005bf906b2..35a28f4eb38ab 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Send.java @@ -49,6 +49,8 @@ import static java.lang.System.out; import static java.lang.System.err; +import jtreg.SkippedException; + public class Send { /* Latches used to synchronize between the client and server so that * connections without any IO may not be closed without being accepted */ @@ -447,7 +449,7 @@ public HandlerResult handleNotification( void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java b/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java index 79eb603920713..0891851fe86fd 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/Shutdown.java @@ -270,7 +270,7 @@ public HandlerResult handleNotification( void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java b/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java index 501d16a976c87..857efbb63f5c4 100644 --- a/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java +++ b/test/jdk/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java @@ -188,7 +188,7 @@ void sctpPrimaryAddr() throws IOException { void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java index bbf3dff954fcb..9beb8c74c3ed8 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Branch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -275,7 +275,7 @@ public HandlerResult handleNotification( void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java index b4f4a39e6df0c..fdafec807458e 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/CloseDescriptors.java @@ -49,7 +49,7 @@ public class CloseDescriptors { public static void main(String[] args) throws Exception { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } List lsofDirs = List.of("/usr/bin", "/usr/sbin"); @@ -58,7 +58,7 @@ public static void main(String[] args) throws Exception { .filter(f -> Files.isExecutable(f)) .findFirst(); if (!lsof.isPresent()) { - throw new jtreg.SkippedException("Cannot locate lsof in " + lsofDirs); + throw new SkippedException("Cannot locate lsof in " + lsofDirs); } try (ServerSocket ss = new ServerSocket(0)) { diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java index 699d8aa01c5ba..8fb551dd8f479 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/Send.java @@ -353,7 +353,7 @@ public void run() { void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java index 06d227e7d60b7..a64d4d582703e 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java @@ -184,7 +184,7 @@ static void assertSameContent(ByteBuffer bb1, ByteBuffer bb2) { void debug(String message, Object... args) {if(debug) { out.printf(message, args); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java index 285a214831c01..77942d12cbb6b 100644 --- a/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java +++ b/test/jdk/com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java @@ -244,7 +244,7 @@ public HandlerResult handleNotification( void debug(String message) {if(debug) { System.out.println(message); } } public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java b/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java index 91645099c3cf8..56522a85f6be9 100644 --- a/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java +++ b/test/jdk/com/sun/nio/sctp/SctpServerChannel/Accept.java @@ -260,7 +260,7 @@ static class TestSocketAddress extends SocketAddress {} catch(InterruptedException ie) { unexpected(ie); }} public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass(); diff --git a/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java b/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java index d4cf4c04ed85c..08bfcb60f500a 100644 --- a/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java +++ b/test/jdk/com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java @@ -216,7 +216,7 @@ static class TestSocketAddress extends SocketAddress {} catch(InterruptedException ie) { unexpected(ie); }} public static void main(String[] args) throws Throwable { if (!Util.isSCTPSupported()) { - throw new jtreg.SkippedException("SCTP protocol is not supported"); + throw new SkippedException("SCTP protocol is not supported"); } Class k = new Object(){}.getClass().getEnclosingClass();