Make SCTP and Bluetooth support optional
cover Make SCTP and Bluetooth support optional
SCTP support is already partially auto-detected - improve it to be more robust. Bluetooth is often disabled on architectures where it couldn't be used, so add checks for it and skip relevant subtests if it's disabled.
Ondrej Mosnacek (2):
tests/extended_socket_class: make Bluetooth support optional
tests: check more thoroughly for SCTP support
tests/extended_socket_class/test | 107 +++++++++++++++++++------------ tests/sctp/test | 4 +- 2 files changed, 68 insertions(+), 43 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/2 tests/extended_socket_class: make Bluetooth support optional
CONFIG_BT is commonly disabled on some architectures due to lack of relevant HW - for example s390x on Fedora/RHEL and aarch64 on RHEL. Make the testsuite work without it to make testing easier in such environments.
--- tests/extended_socket_class/test | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)
tests/extended_socket_class/test +23 -9
@@ -1,7 +1,18 @@ #!/usr/bin/perl use Test; -BEGIN { plan tests => 16 } + +BEGIN { + $test_count = 14; + $test_bluetooth = 0; + + # 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; +} $basedir = $0; $basedir =~ s|(.*)/[^/]*|$1|;
@@ -83,17 +94,20 @@ $result = system( ); ok($result); -# Verify that test_bluetooth_socket_t can create a Bluetooth socket. -$result = system( +if ($test_bluetooth) { + + # Verify that test_bluetooth_socket_t can create a Bluetooth socket. + $result = system( "runcon -t test_bluetooth_socket_t -- $basedir/sockcreate bluetooth stream default 2>&1" -); -ok( $result, 0 ); + ); + ok( $result, 0 ); -# Verify that test_no_bluetooth_socket_t cannot create a Bluetooth socket. -$result = system( + # Verify that test_no_bluetooth_socket_t cannot create a Bluetooth socket. + $result = system( "runcon -t test_no_bluetooth_socket_t -- $basedir/sockcreate bluetooth stream default 2>&1" -); -ok($result); + ); + ok($result); +} # Verify that test_alg_socket_t can create a Crypto API socket. $result = system(
Signature · 1 line
2.35.1
PATCH 2/2 tests: check more thoroughly for SCTP support
In reply to Ondrej Mosnacek1. 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+).
--- tests/extended_socket_class/test | 77 ++++++++++++++++++-------------- tests/sctp/test | 4 +- 2 files changed, 46 insertions(+), 35 deletions(-)
tests/extended_socket_class/test +44 -33
@@ -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) {
tests/sctp/test +2 -2
@@ -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 {
Signature · 1 line
2.35.1
Ondrej Mosnacek
AppliedQuoted 9 lines · Ondrej Mosnacek
SCTP support is already partially auto-detected - improve it to be more robust. Bluetooth is often disabled on architectures where it couldn't be used, so add checks for it and skip relevant subtests if it's disabled.
Ondrej Mosnacek (2):
tests/extended_socket_class: make Bluetooth support optional
tests: check more thoroughly for SCTP support
Quoted 6 lines
tests/extended_socket_class/test | 107 +++++++++++++++++++------------ tests/sctp/test | 4 +- 2 files changed, 68 insertions(+), 43 deletions(-)--
2.35.1
Applied.
Signature · 3 lines
Ondrej Mosnacek Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.