[PATCH testsuite 2/2] tests: check more thoroughly for SCTP support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1. Add SCTP support checking also to extended_socket_class test, where
   it was missing previously.
2. Attempt to explicitly load the 'sctp' module as part of the check to
   ensure that SCTP support is activated and detected also when it is
   excluded from autoloading (as is the case e.g. on RHEL 8+).

Signed-off-by: Ondrej Mosnacek <omosnace@xxxxxxxxxx>
---
 tests/extended_socket_class/test | 77 ++++++++++++++++++--------------
 tests/sctp/test                  |  4 +-
 2 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/tests/extended_socket_class/test b/tests/extended_socket_class/test
index 022993d..86c706b 100755
--- a/tests/extended_socket_class/test
+++ b/tests/extended_socket_class/test
@@ -3,14 +3,22 @@
 use Test;
 
 BEGIN {
-    $test_count     = 14;
+    $test_count     = 6;
     $test_bluetooth = 0;
+    $test_sctp      = 0;
+
+    # check if SCTP is enabled
+    if ( system("modprobe sctp 2>/dev/null && checksctp 2>/dev/null") eq 0 ) {
+        $test_count += 8;
+        $test_sctp = 1;
+    }
 
     # check if Bluetooth is supported (commonly disabled e.g. on s390x)
     if ( system("modprobe bluetooth 2>/dev/null") eq 0 ) {
         $test_count += 2;
         $test_bluetooth = 1;
     }
+
     plan tests => $test_count;
 }
 
@@ -46,53 +54,56 @@ ok($result);
 # Restore to the kernel defaults - no one allowed to create ICMP sockets.
 system("echo 1 0 > /proc/sys/net/ipv4/ping_group_range");
 
-# Verify that test_sctp_socket_t can create an IPv4 stream SCTP socket.
-$result = system(
-    "runcon -t test_sctp_socket_t -- $basedir/sockcreate inet stream sctp 2>&1"
-);
-ok( $result, 0 );
+if ($test_sctp) {
 
-# Verify that test_no_sctp_socket_t cannot create an IPv4 stream SCTP socket.
-$result = system(
+    # Verify that test_sctp_socket_t can create an IPv4 stream SCTP socket.
+    $result = system(
+"runcon -t test_sctp_socket_t -- $basedir/sockcreate inet stream sctp 2>&1"
+    );
+    ok( $result, 0 );
+
+   # Verify that test_no_sctp_socket_t cannot create an IPv4 stream SCTP socket.
+    $result = system(
 "runcon -t test_no_sctp_socket_t -- $basedir/sockcreate inet stream sctp 2>&1"
-);
-ok($result);
+    );
+    ok($result);
 
-# Verify that test_sctp_socket_t can create an IPv4 seqpacket SCTP socket.
-$result = system(
+    # Verify that test_sctp_socket_t can create an IPv4 seqpacket SCTP socket.
+    $result = system(
 "runcon -t test_sctp_socket_t -- $basedir/sockcreate inet seqpacket sctp 2>&1"
-);
-ok( $result, 0 );
+    );
+    ok( $result, 0 );
 
 # Verify that test_no_sctp_socket_t cannot create an IPv4 seqpacket SCTP socket.
-$result = system(
+    $result = system(
 "runcon -t test_no_sctp_socket_t -- $basedir/sockcreate inet seqpacket sctp 2>&1"
-);
-ok($result);
+    );
+    ok($result);
 
-# Verify that test_sctp_socket_t can create an IPv6 stream SCTP socket.
-$result = system(
-    "runcon -t test_sctp_socket_t -- $basedir/sockcreate inet6 stream sctp 2>&1"
-);
-ok( $result, 0 );
+    # Verify that test_sctp_socket_t can create an IPv6 stream SCTP socket.
+    $result = system(
+"runcon -t test_sctp_socket_t -- $basedir/sockcreate inet6 stream sctp 2>&1"
+    );
+    ok( $result, 0 );
 
-# Verify that test_no_sctp_socket_t cannot create an IPv6 stream SCTP socket.
-$result = system(
+   # Verify that test_no_sctp_socket_t cannot create an IPv6 stream SCTP socket.
+    $result = system(
 "runcon -t test_no_sctp_socket_t -- $basedir/sockcreate inet6 stream sctp 2>&1"
-);
-ok($result);
+    );
+    ok($result);
 
-# Verify that test_sctp_socket_t can create an IPv6 seqpacket SCTP socket.
-$result = system(
+    # Verify that test_sctp_socket_t can create an IPv6 seqpacket SCTP socket.
+    $result = system(
 "runcon -t test_sctp_socket_t -- $basedir/sockcreate inet6 seqpacket sctp 2>&1"
-);
-ok( $result, 0 );
+    );
+    ok( $result, 0 );
 
 # Verify that test_no_sctp_socket_t cannot create an IPv6 seqpacket SCTP socket.
-$result = system(
+    $result = system(
 "runcon -t test_no_sctp_socket_t -- $basedir/sockcreate inet6 seqpacket sctp 2>&1"
-);
-ok($result);
+    );
+    ok($result);
+}
 
 if ($test_bluetooth) {
 
diff --git a/tests/sctp/test b/tests/sctp/test
index 0f017e8..1258de4 100755
--- a/tests/sctp/test
+++ b/tests/sctp/test
@@ -28,8 +28,8 @@ BEGIN {
         $v = " ";
     }
 
-    # check if sctp enabled
-    if ( system("checksctp 2> /dev/null") != 0 ) {
+    # check if SCTP is enabled
+    if ( system("modprobe sctp 2>/dev/null && checksctp 2>/dev/null") != 0 ) {
         plan skip_all => "SCTP not supported";
     }
     else {
-- 
2.35.1




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux