Skip to content

Commit 36b185a

Browse files
author
SendaoYan
committed
8359402: Test CloseDescriptors.java should throw SkippedException when there is no lsof/sctp
Reviewed-by: jpai Backport-of: a16d235
1 parent c832f00 commit 36b185a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 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
@@ -26,6 +26,8 @@
2626
* @bug 8238274
2727
* @summary Potential leak file descriptor for SCTP
2828
* @requires (os.family == "linux")
29+
* @library /test/lib
30+
* @build jtreg.SkippedException
2931
* @run main/othervm/timeout=250 CloseDescriptors
3032
*/
3133

@@ -52,9 +54,7 @@ public class CloseDescriptors {
5254

5355
public static void main(String[] args) throws Exception {
5456
if (!Util.isSCTPSupported()) {
55-
System.out.println("SCTP protocol is not supported");
56-
System.out.println("Test cannot be run");
57-
return;
57+
throw new jtreg.SkippedException("SCTP protocol is not supported");
5858
}
5959

6060
List<String> lsofDirs = List.of("/usr/bin", "/usr/sbin");
@@ -63,9 +63,7 @@ public static void main(String[] args) throws Exception {
6363
.filter(f -> Files.isExecutable(f))
6464
.findFirst();
6565
if (!lsof.isPresent()) {
66-
System.out.println("Cannot locate lsof in " + lsofDirs);
67-
System.out.println("Test cannot be run");
68-
return;
66+
throw new jtreg.SkippedException("Cannot locate lsof in " + lsofDirs);
6967
}
7068

7169
try (ServerSocket ss = new ServerSocket(0)) {

0 commit comments

Comments
 (0)