|
51 | 51 | * with indefinite lengths, which is true unless ZCBOR_CANONICAL Kconfig is not selected. |
52 | 52 | */ |
53 | 53 |
|
| 54 | +/* clang-format off */ |
| 55 | +#define CBOR_SERVICE_MIN \ |
| 56 | + /* Subtypes num: */ \ |
| 57 | + 0x0, \ |
| 58 | + /* TXT entry count: */ \ |
| 59 | + 0x0, \ |
| 60 | + /* String buffer size (service + instance): */ \ |
| 61 | + 0xb, \ |
| 62 | + /* Subtypes' buffer size: */ \ |
| 63 | + 0x0, \ |
| 64 | + /* TXT buffer size: */ \ |
| 65 | + 0x0, \ |
| 66 | + /* Service type: */ \ |
| 67 | + 0x65, SERVICE_TYPE, \ |
| 68 | + /* Service instance: */ \ |
| 69 | + 0x64, SERVICE_INSTANCE, \ |
| 70 | + /* Subtypes: */ \ |
| 71 | + 0x9f, \ |
| 72 | + 0xff, \ |
| 73 | + /* TXT: */ \ |
| 74 | + 0xbf, \ |
| 75 | + 0xff, \ |
| 76 | + /* Other fields: */ \ |
| 77 | + CBOR_UINT16(PORT_1), \ |
| 78 | + CBOR_UINT16(SERVICE_PRIORITY), \ |
| 79 | + CBOR_UINT16(SERVICE_WEIGHT), \ |
| 80 | + CBOR_UINT32(SERVICE_LEASE), \ |
| 81 | + CBOR_UINT32(SERVICE_KEY_LEASE) |
| 82 | +/* clang-format on */ |
| 83 | + |
54 | 84 | /* clang-format off */ |
55 | 85 | #define CBOR_SERVICE \ |
56 | 86 | /* Subtypes num: */ \ |
@@ -118,6 +148,33 @@ static void tc_after(void *f) |
118 | 148 | mock_nrf_rpc_tr_expect_done(); |
119 | 149 | } |
120 | 150 |
|
| 151 | +/* Test serialization of otSrpClientAddService() with the minimal service data */ |
| 152 | +ZTEST(ot_rpc_srp_client, test_otSrpClientAddService_min) |
| 153 | +{ |
| 154 | + otError error; |
| 155 | + otSrpClientService service; |
| 156 | + |
| 157 | + service.mName = MAKE_CSTR(SERVICE_TYPE); |
| 158 | + service.mInstanceName = MAKE_CSTR(SERVICE_INSTANCE); |
| 159 | + service.mSubTypeLabels = NULL; |
| 160 | + service.mTxtEntries = NULL; |
| 161 | + service.mPort = PORT_1; |
| 162 | + service.mPriority = SERVICE_PRIORITY; |
| 163 | + service.mWeight = SERVICE_WEIGHT; |
| 164 | + service.mNumTxtEntries = 0; |
| 165 | + service.mLease = SERVICE_LEASE; |
| 166 | + service.mKeyLease = SERVICE_KEY_LEASE; |
| 167 | + |
| 168 | + /* Test serialization of otSrpClientAddService() */ |
| 169 | + mock_nrf_rpc_tr_expect_add(RPC_CMD(OT_RPC_CMD_SRP_CLIENT_ADD_SERVICE, |
| 170 | + CBOR_UINT32((uintptr_t)&service), CBOR_SERVICE_MIN), |
| 171 | + RPC_RSP(OT_ERROR_NONE)); |
| 172 | + error = otSrpClientAddService(NULL, &service); |
| 173 | + mock_nrf_rpc_tr_expect_done(); |
| 174 | + |
| 175 | + zassert_equal(error, OT_ERROR_NONE); |
| 176 | +} |
| 177 | + |
121 | 178 | /* Test serialization of otSrpClientAddService() followed by otSrpClientClearService() */ |
122 | 179 | ZTEST(ot_rpc_srp_client, test_otSrpClientAddService_otSrpClientClearService) |
123 | 180 | { |
|
0 commit comments