* [BlueZ, v1] unit: Add test for sdp_xml_parse_record()
@ 2026-08-05 13:52 Bastien Nocera
2026-08-05 16:17 ` [BlueZ,v1] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Bastien Nocera @ 2026-08-05 13:52 UTC (permalink / raw)
To: linux-bluetooth
This adds 2 example XML files from other repositories, under a fair use
license exception.
---
Makefile.am | 10 ++
unit/sdp-xml/Bluetooth_HID-sdp_record.xml | 123 ++++++++++++++++++++++
unit/sdp-xml/qt-SerialPortSDPRecord.xml | 57 ++++++++++
unit/test-sdp-xml.c | 69 ++++++++++++
4 files changed, 259 insertions(+)
create mode 100644 unit/sdp-xml/Bluetooth_HID-sdp_record.xml
create mode 100644 unit/sdp-xml/qt-SerialPortSDPRecord.xml
create mode 100644 unit/test-sdp-xml.c
diff --git a/Makefile.am b/Makefile.am
index 19c468d3a504..1c62ee66bdce 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -637,6 +637,16 @@ unit_test_sdp_SOURCES = unit/test-sdp.c \
unit_test_sdp_LDADD = lib/libbluetooth-internal.la \
src/libshared-glib.la $(GLIB_LIBS)
+unit_tests += unit/test-sdp-xml
+
+unit_test_sdp_xml_SOURCES = unit/test-sdp-xml.c \
+ src/sdp-xml.c src/sdp-xml.h \
+ src/log.h src/log.c
+unit_test_sdp_xml_LDADD = lib/libbluetooth-internal.la \
+ src/libshared-glib.la $(GLIB_LIBS)
+unit_test_sdp_xml_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) -DTOP_SRCDIR=\""$(srcdir)"\"
+unit_test_sdp_xml_CPPFLAGS = -I$(srcdir)/lib
+
unit_tests += unit/test-avdtp
unit_test_avdtp_SOURCES = unit/test-avdtp.c \
diff --git a/unit/sdp-xml/Bluetooth_HID-sdp_record.xml b/unit/sdp-xml/Bluetooth_HID-sdp_record.xml
new file mode 100644
index 000000000000..687b0b15b520
--- /dev/null
+++ b/unit/sdp-xml/Bluetooth_HID-sdp_record.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+
+ From: https://github.com/AnesBenmerzoug/Bluetooth_HID/blob/master/sdp_record.xml
+ A description of these fields can be found in the following links:
+ http://www.bluecove.org/bluecove/apidocs/javax/bluetooth/ServiceRecord.html
+ https://www.bluetooth.com/specifications/assigned-numbers/service-discovery
+
+ -->
+
+<record>
+ <attribute id="0x0001"> <!-- Service Class ID List -->
+ <sequence>
+ <uuid value="0x1124" /> <!-- Human Interface Device -->
+ </sequence>
+ </attribute>
+ <attribute id="0x0004"> <!-- Protocol Descriptor List -->
+ <sequence>
+ <sequence>
+ <uuid value="0x0100" /> <!-- L2CAP -->
+ <uint16 value="0x0011" /> <!-- HIDP -->
+ </sequence>
+ <sequence>
+ <uuid value="0x0011" /> <!-- HIDP -->
+ </sequence>
+ </sequence>
+ </attribute>
+ <attribute id="0x0005"> <!-- Browse Group List -->
+ <sequence>
+ <uuid value="0x1002" />
+ </sequence>
+ </attribute>
+ <attribute id="0x0006"> <!-- Language Based Attribute ID List -->
+ <sequence>
+ <uint16 value="0x656e" /> <!-- code_ISO639 -->
+ <uint16 value="0x006a" /> <!-- encoding -->
+ <uint16 value="0x0100" /> <!-- base_offset -->
+ </sequence>
+ </attribute>
+ <attribute id="0x0009"> <!-- Bluetooth Profile Descriptor List -->
+ <sequence>
+ <sequence>
+ <uuid value="0x1124" /> <!-- Human Interface Device -->
+ <uint16 value="0x0100" /> <!-- L2CAP -->
+ </sequence>
+ </sequence>
+ </attribute>
+ <attribute id="0x000d"> <!-- Additional Protocol Descriptor Lists -->
+ <sequence>
+ <sequence>
+ <sequence>
+ <uuid value="0x0100" /> <!-- L2CAP -->
+ <uint16 value="0x0013" />
+ </sequence>
+ <sequence>
+ <uuid value="0x0011" /> <!-- HIDP -->
+ </sequence>
+ </sequence>
+ </sequence>
+ </attribute>
+ <attribute id="0x0100">
+ <text value="Bluetooth_Keyboard/Mouse" />
+ </attribute>
+ <attribute id="0x0101">
+ <text value="USB > BT Keyboard/Mouse" />
+ </attribute>
+ <attribute id="0x0102">
+ <text value="Raspberry Pi 3" />
+ </attribute>
+ <attribute id="0x0200">
+ <uint16 value="0x0100" />
+ </attribute>
+ <attribute id="0x0201">
+ <uint16 value="0x0111" />
+ </attribute>
+ <attribute id="0x0202">
+ <uint8 value="0x40" />
+ </attribute>
+ <attribute id="0x0203">
+ <uint8 value="0x00" />
+ </attribute>
+ <attribute id="0x0204">
+ <boolean value="false" />
+ </attribute>
+ <attribute id="0x0205">
+ <boolean value="false" />
+ </attribute>
+ <attribute id="0x0206">
+ <sequence>
+ <sequence>
+ <uint8 value="0x22" />
+ <text encoding="hex" value="05010906A1018501A100050719E029E71500250175019508810295017508810195087508150025650507190029658100C0C005010902A10185020901A1000509190129031500250175019503810275059501810105010930093109381581257F750895038106C0C0"/>
+ </sequence>
+ </sequence>
+ </attribute>
+ <attribute id="0x0207">
+ <sequence>
+ <sequence>
+ <uint16 value="0x0409" />
+ <uint16 value="0x0100" />
+ </sequence>
+ </sequence>
+ </attribute>
+ <attribute id="0x020b">
+ <uint16 value="0x0100" />
+ </attribute>
+ <attribute id="0x020c">
+ <uint16 value="0x0c80" />
+ </attribute>
+ <attribute id="0x020d">
+ <boolean value="true" />
+ </attribute>
+ <attribute id="0x020e">
+ <boolean value="false" />
+ </attribute>
+ <attribute id="0x020f">
+ <uint16 value="0x0640" />
+ </attribute>
+ <attribute id="0x0210">
+ <uint16 value="0x0320" />
+ </attribute>
+</record>
diff --git a/unit/sdp-xml/qt-SerialPortSDPRecord.xml b/unit/sdp-xml/qt-SerialPortSDPRecord.xml
new file mode 100644
index 000000000000..1f62ccf11a41
--- /dev/null
+++ b/unit/sdp-xml/qt-SerialPortSDPRecord.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ This is an XML file describing an SDP service record for a Serial Port
+ service.
+
+ You can use the linux sdptool command to create a file like this for
+ publishing your Bluetooth services. See the "Creating a Bluetooth service"
+ tutorial for more details.
+
+ From: https://radekp.github.io/qtmoko/api/bluetooth-bluetoothservice-serialportsdprecord-xml.html
+-->
+
+ <record>
+ <attribute id="0x0001">
+ <sequence>
+ <uuid value="0x1101" />
+ </sequence>
+ </attribute>
+ <attribute id="0x0004">
+ <sequence>
+ <sequence>
+ <uuid value="0x0100" />
+ </sequence>
+ <sequence>
+ <uuid value="0x0003" />
+ <uint8 value="0x05" />
+ </sequence>
+ </sequence>
+ </attribute>
+ <attribute id="0x0005">
+ <sequence>
+ <uuid value="0x1002" />
+ </sequence>
+ </attribute>
+ <attribute id="0x0006">
+ <sequence>
+ <uint16 value="0x656e" />
+ <uint16 value="0x006a" />
+ <uint16 value="0x0100" />
+ </sequence>
+ </attribute>
+ <attribute id="0x0009">
+ <sequence>
+ <sequence>
+ <uuid value="0x1101" />
+ <uint16 value="0x0100" />
+ </sequence>
+ </sequence>
+ </attribute>
+ <attribute id="0x0100">
+ <text value="Serial Port" />
+ </attribute>
+ <attribute id="0x0101">
+ <text value="COM Port" />
+ </attribute>
+ </record>
diff --git a/unit/test-sdp-xml.c b/unit/test-sdp-xml.c
new file mode 100644
index 000000000000..bdb10fa5831b
--- /dev/null
+++ b/unit/test-sdp-xml.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2026 Intel Corporation. All rights reserved.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+
+#include "bluetooth/sdp.h"
+#include "bluetooth/sdp_lib.h"
+
+#include "src/shared/util.h"
+#include "src/shared/tester.h"
+#include "src/log.h"
+#include "src/sdp-xml.h"
+
+static void parse_xml(gconstpointer data, gsize len)
+{
+ sdp_record_t *rec = NULL;
+
+ rec = sdp_xml_parse_record(data, len);
+ if (rec) {
+ tester_test_passed();
+ sdp_record_free(rec);
+ } else {
+ tester_test_failed();
+ }
+}
+
+static void parse_xml_for_filename(gconstpointer data)
+{
+ const char *filename = (const char *) data;
+ char *path = NULL;
+ GError *error = NULL;
+ char *contents = NULL;
+ gsize len;
+
+ path = g_build_filename(TOP_SRCDIR, "unit", "sdp-xml", filename, NULL);
+ if (!g_file_get_contents(path, &contents, &len, &error)) {
+ g_warning("Can't load file '%s': %s", path, error->message);
+ g_free(path);
+ g_error_free(error);
+ tester_test_failed();
+ }
+ parse_xml(contents, len);
+ g_free(contents);
+ g_free(path);
+}
+
+#define DEFINE_TEST(fname) \
+ tester_add("/" fname, fname, NULL, parse_xml_for_filename, NULL);
+
+int main(int argc, char *argv[])
+{
+ tester_init(&argc, &argv);
+
+ DEFINE_TEST("Bluetooth_HID-sdp_record.xml");
+ DEFINE_TEST("qt-SerialPortSDPRecord.xml");
+
+ return tester_run();
+}
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* RE: [BlueZ,v1] unit: Add test for sdp_xml_parse_record()
2026-08-05 13:52 [BlueZ, v1] unit: Add test for sdp_xml_parse_record() Bastien Nocera
@ 2026-08-05 16:17 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-08-05 16:17 UTC (permalink / raw)
To: linux-bluetooth, hadess
[-- Attachment #1: Type: text/plain, Size: 2531 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1140838
---Test result---
Test Summary:
CheckPatch FAIL 0.37 seconds
GitLint PASS 0.21 seconds
BuildEll PASS 20.67 seconds
BluezMake PASS 604.70 seconds
MakeCheck PASS 19.60 seconds
MakeDistcheck FAIL 145.92 seconds
CheckValgrind PASS 232.61 seconds
CheckSmatch PASS 315.29 seconds
bluezmakeextell PASS 103.05 seconds
IncrementalBuild PASS 619.01 seconds
ScanBuild PASS 1000.29 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v1] unit: Add test for sdp_xml_parse_record()
WARNING:LONG_LINE: line length of 81 exceeds 80 columns
#341: FILE: unit/test-sdp-xml.c:58:
+#define DEFINE_TEST(fname) \
WARNING:TRAILING_SEMICOLON: macros should not use a trailing semicolon
#341: FILE: unit/test-sdp-xml.c:58:
+#define DEFINE_TEST(fname) \
+ tester_add("/" fname, fname, NULL, parse_xml_for_filename, NULL);
/github/workspace/src/patch/14732439.patch total: 0 errors, 2 warnings, 265 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/patch/14732439.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: MakeDistcheck - FAIL
Desc: Run Bluez Make Distcheck
Output:
../../test-driver: line 107: 53104 Aborted (core dumped) "$@" > $log_file 2>&1
make[4]: *** [Makefile:10329: test-suite.log] Error 1
make[3]: *** [Makefile:10437: check-TESTS] Error 2
make[2]: *** [Makefile:10915: check-am] Error 2
make[1]: *** [Makefile:10917: check] Error 2
make: *** [Makefile:10838: distcheck] Error 1
https://github.com/bluez/bluez/pull/2378
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-05 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 13:52 [BlueZ, v1] unit: Add test for sdp_xml_parse_record() Bastien Nocera
2026-08-05 16:17 ` [BlueZ,v1] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox