From: Bastien Nocera <hadess@hadess.net>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/2] unit: Add unit test for new MIN/MAX macros
Date: Wed, 1 Apr 2026 22:45:05 +0200 [thread overview]
Message-ID: <20260401204527.148077-1-hadess@hadess.net> (raw)
---
Makefile.am | 4 ++++
unit/test-util.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
create mode 100644 unit/test-util.c
diff --git a/Makefile.am b/Makefile.am
index 2cfb884f1851..d9de71d587d8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -696,6 +696,10 @@ unit_test_lib_SOURCES = unit/test-lib.c
unit_test_lib_LDADD = src/libshared-glib.la \
lib/libbluetooth-internal.la $(GLIB_LIBS)
+unit_tests += unit/test-util
+unit_test_util_LDADD = src/libshared-glib.la \
+ lib/libbluetooth-internal.la $(GLIB_LIBS)
+
unit_tests += unit/test-gatt
unit_test_gatt_SOURCES = unit/test-gatt.c
diff --git a/unit/test-util.c b/unit/test-util.c
new file mode 100644
index 000000000000..8ab16cc083ba
--- /dev/null
+++ b/unit/test-util.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2026 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ */
+
+#include <assert.h>
+
+#include "src/shared/util.h"
+#include "src/shared/tester.h"
+
+/* XXX glib.h must not be included, or it will clobber the
+ * MIN/MAX macros */
+
+static void test_min_max(const void *data)
+{
+ assert(MIN(3, 4) == 3);
+ assert(MAX(3, 4) == 4);
+ tester_test_passed();
+}
+
+int main(int argc, char *argv[])
+{
+ tester_init(&argc, &argv);
+
+ tester_add("/util/min_max", NULL, NULL,
+ test_min_max, NULL);
+
+ return tester_run();
+}
--
2.53.0
next reply other threads:[~2026-04-01 20:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 20:45 Bastien Nocera [this message]
2026-04-01 20:45 ` [PATCH BlueZ 2/2] all: Remove redundant MIN/MAX macro definitions Bastien Nocera
2026-04-01 22:06 ` [BlueZ,1/2] unit: Add unit test for new MIN/MAX macros bluez.test.bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260401204527.148077-1-hadess@hadess.net \
--to=hadess@hadess.net \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox