diff mbox series

[testsuite,1/2] tests/extended_socket_class: make Bluetooth support optional

Message ID 20220413164810.2122305-2-omosnace@redhat.com (mailing list archive)
State Accepted
Delegated to: Ondrej Mosnáček
Headers show
Series Make SCTP and Bluetooth support optional | expand

Commit Message

Ondrej Mosnacek April 13, 2022, 4:48 p.m. UTC
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.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 tests/extended_socket_class/test | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/tests/extended_socket_class/test b/tests/extended_socket_class/test
index 6e334d1..022993d 100755
--- a/tests/extended_socket_class/test
+++ b/tests/extended_socket_class/test
@@ -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(