[PATCH BlueZ v9 08/15] unit: Run test-bap tests concurrently

Bastien Nocera
2026-04-24T09:13:42Z

---
meson.build | 2 +-
unit/meson.build | 25 ++++++++++++++++++++++---
unit/unittest_list.sh | 15 +++++++++++++++
3 files changed, 38 insertions(+), 4 deletions(-)
create mode 100644 unit/unittest_list.sh

diff --git a/meson.build b/meson.build
index f716eae1f063..586b69459d8a 100644
--- a/meson.build
+++ b/meson.build
@@ -285,6 +285,7 @@ endif
if rst2man.found()
subdir('doc')
endif
+sh = find_program('sh', required: true)
if get_option('tests').allowed()
subdir('test')
subdir('unit')
@@ -292,7 +293,6 @@ endif

# Fix permissions on install
install = find_program('install')
-sh = find_program('sh')
if get_option('daemon').enabled()
meson.add_install_script(sh, '-c', 'install -dm755 ${DESTDIR}/' + configdir)
endif
diff --git a/unit/meson.build b/unit/meson.build
index c8198574147d..1bd3b7a85992 100644
--- a/unit/meson.build
+++ b/unit/meson.build
@@ -7,7 +7,6 @@ tests1 = [
[ 'test-avrcp.c', '../src/log.c', 'avctp.c', 'avrcp-lib.c' ],
[ 'test-lib.c' ],
[ 'test-gatt.c' ],
- [ 'test-bap.c' ],
[ 'test-micp.c' ],
[ 'test-bass.c' ],
[ 'test-vcp.c' ],
@@ -39,6 +38,26 @@ foreach t: tests1
endforeach

tests2 = [
+ [ 'test-bap.c' ],
+]
+
+unittest_list = find_program('unittest_list.sh')
+
+foreach t: tests2
+ test_name = t[0].substring(0, -2)
+ exe = executable(test_name,
+ sources: t,
+ dependencies: [ libshared_glib_dep, libbluetooth_internal_dep ],
+ )
+
+ r = run_command(sh, unittest_list, t, check: true)
+ unit_tests = r.stdout().strip().split(' ')
+ foreach ut: unit_tests
+ test(ut, exe, args: [ '-p', ut ])
+ endforeach
+endforeach
+
+tests3 = [
[ 'test-textfile.c', '../src/textfile.c' ],
[ 'test-crc.c', '../monitor/crc.c' ],
[ 'test-crypto.c' ],
@@ -54,7 +73,7 @@ tests2 = [
]

if ical_dep.found()
- tests2 += [
+ tests3 += [
[ 'test-gobex.c', 'util.c', gobex_sources ],
[ 'test-gobex-packet.c', 'util.c', gobex_sources ],
[ 'test-gobex-header.c', 'util.c', gobex_sources ],
@@ -63,7 +82,7 @@ if ical_dep.found()
]
endif

-foreach t: tests2
+foreach t: tests3
test_name = t[0].substring(0, -2)
exe = executable(test_name,
sources: t,
diff --git a/unit/unittest_list.sh b/unit/unittest_list.sh
new file mode 100644
index 000000000000..c478edc9d3e4
--- /dev/null
+++ b/unit/unittest_list.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if [ $# -lt 1 ] ; then
+ echo "Usage: $0 FILE..."
+ exit 1
+fi
+
+TESTS=$(grep '^[[:space:]]*define_test[_a-z]*("' $* | cut -d \" -f 2 | cut -d " " -f 1)
+if [ -z "$TESTS" ] ; then
+ TESTS=$(grep '^[[:space:]]*tester_add("' $* | cut -d \" -f 2 | cut -d " " -f 1)
+fi
+if [ -z "$TESTS" ] ; then
+ TESTS=$(grep '^[[:space:]]*g_test_add_*func("' $* | cut -d \" -f 2 | cut -d " " -f 1)
+fi
+echo $TESTS
--
2.53.0