unit: Add unit test for new MIN/MAX macros
Subsystems (2)
PATCH 1/2 unit: Add unit test for new MIN/MAX macros
--- Makefile.am | 4 ++++ unit/test-util.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 unit/test-util.c
Makefile.am +4 -0
@@ -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
unit/test-util.c new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2026 Bastien Nocera <[email protected]> +* +* +*/ + +#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 (); +}
Signature · 1 line
2.53.0
PATCH 2/2 all: Remove redundant MIN/MAX macro definitions
--- client/mgmt.c | 4 ---- mesh/prov-initiator.c | 3 +-- src/device.c | 4 ---- src/gatt-database.c | 4 ---- src/shared/gatt-client.c | 8 -------- src/shared/gatt-helpers.c | 4 ---- src/shared/ringbuf.c | 4 ---- src/shared/uhid.c | 4 ---- src/shared/vcp.h | 8 -------- tools/advtest.c | 3 --- tools/btgatt-server.c | 4 ---- tools/hcitool.c | 4 ---- tools/parser/rfcomm.h | 2 -- 13 files changed, 1 insertion(+), 55 deletions(-)
client/mgmt.c +0 -4
@@ -67,10 +67,6 @@ static struct {static int pending_index =0 ; -#ifndef MIN -#define MIN (x, y) ((x) < (y) ? (x) : (y)) -#endif -static void mgmt_menu_pre_run (const struct bt_shell_menu *menu);#define PROMPT_ON COLOR_BLUE "[mgmt]" COLOR_OFF "> "
mesh/prov-initiator.c +1 -2
@@ -18,6 +18,7 @@#include "src/shared/ad.h" #include "src/shared/ecc.h" +#include "src/shared/util.h" #include "mesh/mesh-defs.h" #include "mesh/util.h"
@@ -34,8 +35,6 @@#include "mesh/agent.h" #include "mesh/error.h" -#define MIN (x, y) ((x) < (y) ? (x) : (y)) -/* Quick size sanity check */ static const uint16_t expected_pdu_size[] = {2 ,/* PROV_INVITE */
src/device.c +0 -4
@@ -72,10 +72,6 @@#define DISCOVERY_TIMER 1#define INVALID_FLAGS 0xff -#ifndef MIN -#define MIN (a, b) ((a) < (b) ? (a) : (b)) -#endif -#define RSSI_THRESHOLD 8#define AUTH_FAILURES_THRESHOLD 3
src/gatt-database.c +0 -4
@@ -54,10 +54,6 @@#define UUID_GATT 0x1801#define UUID_DIS 0x180a -#ifndef MIN -#define MIN (a, b) ((a) < (b) ? (a) : (b)) -#endif -struct gatt_record {struct btd_gatt_database *database;uint32_t handle;
src/shared/gatt-client.c +0 -8
@@ -25,14 +25,6 @@#include <limits.h> #include <sys/uio.h> -#ifndef MAX -#define MAX (a, b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN (a, b) ((a) < (b) ? (a) : (b)) -#endif -#define UUID_BYTES (BT_GATT_UUID_SIZE * sizeof(uint8_t))#define GATT_SVC_UUID 0x1801
src/shared/gatt-helpers.c +0 -4
@@ -20,10 +20,6 @@#include "src/shared/gatt-helpers.h" #include "src/shared/util.h" -#ifndef MIN -#define MIN (a, b) ((a) < (b) ? (a) : (b)) -#endif -struct bt_gatt_result {uint8_t opcode;void *pdu;
src/shared/ringbuf.c +0 -4
@@ -21,10 +21,6 @@#include "src/shared/util.h" #include "src/shared/ringbuf.h" -#ifndef MIN -#define MIN (x,y) ((x)<(y)?(x):(y)) -#endif -struct ringbuf {void *buffer;size_t size;
src/shared/uhid.c +0 -4
@@ -26,10 +26,6 @@#define UHID_DEVICE_FILE "/dev/uhid" -#ifndef MIN -#define MIN (x, y) ((x) < (y) ? (x) : (y)) -#endif -struct uhid_replay {bool active;struct queue *out;
src/shared/vcp.h +0 -8
@@ -23,14 +23,6 @@#define BT_VCP_UNMUTE 0x05#define BT_VCP_MUTE 0x06 -#ifndef MAX -#define MAX (a, b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN (a, b) ((a) < (b) ? (a) : (b)) -#endif -struct bt_vcp ;typedef void (*bt_vcp_destroy_func_t )(void *user_data);
tools/advtest.c +0 -3
@@ -39,9 +39,6 @@"\xe1\x23\x99\xc1\xca\x9a\xc3\x31" #define SCAN_IRK "\xfa\x73\x09\x11\x3f\x03\x37\x0f" \"\xf4\xf9\x93\x1e\xf9\xa3\x63\xa6" -#ifndef MIN -#define MIN (x, y) ((x) < (y) ? (x) : (y)) -#endif static struct mgmt *mgmt;static uint16_t index1 =MGMT_INDEX_NONE ;
tools/btgatt-server.c +0 -4
@@ -48,10 +48,6 @@print_prompt (); \ } while (0) -#ifndef MIN -#define MIN (a, b) ((a) < (b) ? (a) : (b)) -#endif -#define COLOR_OFF "\x1B[0m"#define COLOR_RED "\x1B[0;91m"#define COLOR_GREEN "\x1B[0;92m"
tools/hcitool.c +0 -4
@@ -34,10 +34,6 @@#include "src/oui.h" -#ifndef MIN -#define MIN (a, b) ((a) < (b) ? (a) : (b)) -#endif -/* Unofficial value, might still change */ #define LE_LINK 0x80
tools/parser/rfcomm.h +0 -2
@@ -33,8 +33,6 @@/* Returns the P/F-bit */ #define GET_PF (ctr) (((ctr) >> 4) & 0x1) -#define MIN (a, b) (((a) < (b)) ? (a) : (b)) -/* Endian-swapping macros for structs */ #define swap_long_frame (x) ((x)->h.length.val = le16_to_cpu((x)->h.length.val))#define swap_mcc_long_frame (x) (swap_long_frame(x))
Signature · 1 line
2.53.0
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=1076045
---Test result---
Test Summary:
CheckPatch PENDING 0.37 seconds GitLint PENDING 0.37 seconds BuildEll PASS 19.71 seconds BluezMake PASS 587.57 seconds MakeCheck PASS 18.57 seconds MakeDistcheck PASS 230.57 seconds CheckValgrind PASS 270.86 seconds CheckSmatch WARNING 316.57 seconds bluezmakeextell PASS 163.21 seconds IncrementalBuild PENDING 0.40 seconds ScanBuild PASS 894.90 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:src/shared/gatt-helpers.c:764:31: warning: Variable length array is used.src/shared/gatt-helpers.c:842:31: warning: Variable length array is used.src/shared/gatt-helpers.c:1335:31: warning: Variable length array is used.src/shared/gatt-helpers.c:1366:23: warning: Variable length array is used.src/shared/gatt-helpers.c:764:31: warning: Variable length array is used.src/shared/gatt-helpers.c:842:31: warning: Variable length array is used.src/shared/gatt-helpers.c:1335:31: warning: Variable length array is used.src/shared/gatt-helpers.c:1366:23: warning: Variable length array is used.src/shared/gatt-helpers.c:764:31: warning: Variable length array is used.src/shared/gatt-helpers.c:842:31: warning: Variable length array is used.src/shared/gatt-helpers.c:1335:31: warning: Variable length array is used.src/shared/gatt-helpers.c:1366:23: warning: Variable length array is used.
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
https://github.com/bluez/bluez/pull/2003/checks
---
Regards,
Linux Bluetooth
Hey Luiz,
I believe those 2 patches are also ready for review.
Cheers
Quoted 63 lines · Bastien Nocera
---
Makefile.am | 4 ++++
unit/test-util.c | 34 ++++++++++++++++++++++++++++++++++2 files changed, 38 insertions(+)create mode 100644
unit/test-util.cMakefile.am +0
-0@@ -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)Makefile.am +3
-0+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.cunit/test-util.c new file +34
-0@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2026 Bastien Nocera <[email protected]> +* +* +*/ + +#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 (); +}
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 5 lines · On Wed, 1 Apr 2026 22:45:05 +0200 you wrote:
--- Makefile.am | 4 ++++ unit/test-util.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 unit/test-util.c
Here is the summary with links:
- [BlueZ,1/2] unit: Add unit test for new MIN/MAX macros (no matching commit)
- [BlueZ,2/2] all: Remove redundant MIN/MAX macro definitions
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=73c6943f0636
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html