Don't duplicate PDU data used in a few gatt-client test cases.
---
unit/test-gatt.c | 146 +++++++++++++------------------------------------------
1 file changed, 34 insertions(+), 112 deletions(-)
diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 4d5d7ea..9917ec9 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -114,6 +114,36 @@ struct context {
#define define_test_client(name, function, bt_services, test_step, args...)\
define_test(name, function, CLIENT, NULL, bt_services, test_step, args)
+#define SERVICE_DATA_1_PDU \
+ raw_pdu(0x02, 0x00, 0x02), \
+ raw_pdu(0x03, 0x00, 0x02), \
+ raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28), \
+ raw_pdu(0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x01, 0x18),\
+ raw_pdu(0x10, 0x05, 0x00, 0xff, 0xff, 0x00, 0x28), \
+ raw_pdu(0x11, 0x06, 0x05, 0x00, 0x08, 0x00, 0x0d, 0x18),\
+ raw_pdu(0x10, 0x09, 0x00, 0xff, 0xff, 0x00, 0x28), \
+ raw_pdu(0x01, 0x10, 0x09, 0x00, 0x0a), \
+ raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28), \
+ raw_pdu(0x01, 0x10, 0x01, 0x00, 0x0a), \
+ raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x02, 0x28), \
+ raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a), \
+ raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x02, 0x28), \
+ raw_pdu(0x01, 0x08, 0x05, 0x00, 0x0a), \
+ raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x03, 0x28), \
+ raw_pdu(0x09, 0x07, 0x02, 0x00, 0x02, 0x03, 0x00, 0x00, \
+ 0x2a), \
+ raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28), \
+ raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a), \
+ raw_pdu(0x04, 0x04, 0x00, 0x04, 0x00), \
+ raw_pdu(0x05, 0x01, 0x04, 0x00, 0x01, 0x29), \
+ raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x03, 0x28), \
+ raw_pdu(0x09, 0x07, 0x06, 0x00, 0x02, 0x07, 0x00, 0x29, \
+ 0x2a), \
+ raw_pdu(0x08, 0x07, 0x00, 0x08, 0x00, 0x03, 0x28), \
+ raw_pdu(0x01, 0x08, 0x07, 0x00, 0x0a), \
+ raw_pdu(0x04, 0x08, 0x00, 0x08, 0x00), \
+ raw_pdu(0x05, 0x01, 0x08, 0x00, 0x01, 0x29)
+
static bt_uuid_t uuid_16 = {
.type = BT_UUID16,
.value.u16 = 0x1800
@@ -689,133 +719,25 @@ int main(int argc, char *argv[])
define_test_client("/TP/GAR/CL/BV-01-C", test_client, service_data_1,
&test_read_1,
- raw_pdu(0x02, 0x00, 0x02),
- raw_pdu(0x03, 0x00, 0x02),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x01, 0x18),
- raw_pdu(0x10, 0x05, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x05, 0x00, 0x08, 0x00, 0x0d, 0x18),
- raw_pdu(0x10, 0x09, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x01, 0x10, 0x09, 0x00, 0x0a),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28),
- raw_pdu(0x01, 0x10, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x05, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x02, 0x00, 0x02, 0x03, 0x00, 0x00,
- 0x2a),
- raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
- raw_pdu(0x04, 0x04, 0x00, 0x04, 0x00),
- raw_pdu(0x05, 0x01, 0x04, 0x00, 0x01, 0x29),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x06, 0x00, 0x02, 0x07, 0x00, 0x29,
- 0x2a),
- raw_pdu(0x08, 0x07, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x07, 0x00, 0x0a),
- raw_pdu(0x04, 0x08, 0x00, 0x08, 0x00),
- raw_pdu(0x05, 0x01, 0x08, 0x00, 0x01, 0x29),
+ SERVICE_DATA_1_PDU,
raw_pdu(0x0a, 0x03, 0x00),
raw_pdu(0x0b, 0x01, 0x02, 0x03));
define_test_client("/TP/GAR/CL/BI-01-C", test_client, service_data_1,
&test_read_2,
- raw_pdu(0x02, 0x00, 0x02),
- raw_pdu(0x03, 0x00, 0x02),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x01, 0x18),
- raw_pdu(0x10, 0x05, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x05, 0x00, 0x08, 0x00, 0x0d, 0x18),
- raw_pdu(0x10, 0x09, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x01, 0x10, 0x09, 0x00, 0x0a),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28),
- raw_pdu(0x01, 0x10, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x05, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x02, 0x00, 0x02, 0x03, 0x00, 0x00,
- 0x2a),
- raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
- raw_pdu(0x04, 0x04, 0x00, 0x04, 0x00),
- raw_pdu(0x05, 0x01, 0x04, 0x00, 0x01, 0x29),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x06, 0x00, 0x02, 0x07, 0x00, 0x29,
- 0x2a),
- raw_pdu(0x08, 0x07, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x07, 0x00, 0x0a),
- raw_pdu(0x04, 0x08, 0x00, 0x08, 0x00),
- raw_pdu(0x05, 0x01, 0x08, 0x00, 0x01, 0x29),
+ SERVICE_DATA_1_PDU,
raw_pdu(0x0a, 0x00, 0x00),
raw_pdu(0x01, 0x0a, 0x00, 0x00, 0x01));
define_test_client("/TP/GAR/CL/BI-02-C", test_client, service_data_1,
&test_read_3,
- raw_pdu(0x02, 0x00, 0x02),
- raw_pdu(0x03, 0x00, 0x02),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x01, 0x18),
- raw_pdu(0x10, 0x05, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x05, 0x00, 0x08, 0x00, 0x0d, 0x18),
- raw_pdu(0x10, 0x09, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x01, 0x10, 0x09, 0x00, 0x0a),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28),
- raw_pdu(0x01, 0x10, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x05, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x02, 0x00, 0x02, 0x03, 0x00, 0x00,
- 0x2a),
- raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
- raw_pdu(0x04, 0x04, 0x00, 0x04, 0x00),
- raw_pdu(0x05, 0x01, 0x04, 0x00, 0x01, 0x29),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x06, 0x00, 0x02, 0x07, 0x00, 0x29,
- 0x2a),
- raw_pdu(0x08, 0x07, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x07, 0x00, 0x0a),
- raw_pdu(0x04, 0x08, 0x00, 0x08, 0x00),
- raw_pdu(0x05, 0x01, 0x08, 0x00, 0x01, 0x29),
+ SERVICE_DATA_1_PDU,
raw_pdu(0x0a, 0x03, 0x00),
raw_pdu(0x01, 0x0a, 0x03, 0x00, 0x02));
define_test_client("/TP/GAR/CL/BI-03-C", test_client, service_data_1,
&test_read_4,
- raw_pdu(0x02, 0x00, 0x02),
- raw_pdu(0x03, 0x00, 0x02),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x01, 0x18),
- raw_pdu(0x10, 0x05, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x11, 0x06, 0x05, 0x00, 0x08, 0x00, 0x0d, 0x18),
- raw_pdu(0x10, 0x09, 0x00, 0xff, 0xff, 0x00, 0x28),
- raw_pdu(0x01, 0x10, 0x09, 0x00, 0x0a),
- raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28),
- raw_pdu(0x01, 0x10, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x02, 0x28),
- raw_pdu(0x01, 0x08, 0x05, 0x00, 0x0a),
- raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x02, 0x00, 0x02, 0x03, 0x00, 0x00,
- 0x2a),
- raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
- raw_pdu(0x04, 0x04, 0x00, 0x04, 0x00),
- raw_pdu(0x05, 0x01, 0x04, 0x00, 0x01, 0x29),
- raw_pdu(0x08, 0x05, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x06, 0x00, 0x02, 0x07, 0x00, 0x29,
- 0x2a),
- raw_pdu(0x08, 0x07, 0x00, 0x08, 0x00, 0x03, 0x28),
- raw_pdu(0x01, 0x08, 0x07, 0x00, 0x0a),
- raw_pdu(0x04, 0x08, 0x00, 0x08, 0x00),
- raw_pdu(0x05, 0x01, 0x08, 0x00, 0x01, 0x29),
+ SERVICE_DATA_1_PDU,
raw_pdu(0x0a, 0x03, 0x00),
raw_pdu(0x01, 0x0a, 0x03, 0x00, 0x08));
--
1.9.3