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

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

 



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@xxxxxxxxxx>
---
 tests/extended_socket_class/test | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

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(
-- 
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