MCPcopy Create free account
hub / github.com/F-Stack/f-stack / __test_add_invalid

Function __test_add_invalid

dpdk/app/test/test_ipsec_sad.c:152–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152static int32_t
153__test_add_invalid(int ipv6, union rte_ipsec_sad_key *tuple)
154{
155 int status;
156 struct rte_ipsec_sad *sad = NULL;
157 struct rte_ipsec_sad_conf config;
158 uint64_t tmp;
159 void *sa = &tmp;
160
161 /* sad == NULL*/
162 status = rte_ipsec_sad_add(NULL, tuple,
163 RTE_IPSEC_SAD_SPI_DIP_SIP, sa);
164 RTE_TEST_ASSERT(status < 0,
165 "Call succeeded with invalid parameters\n");
166
167 config.max_sa[RTE_IPSEC_SAD_SPI_ONLY] = MAX_SA;
168 config.max_sa[RTE_IPSEC_SAD_SPI_DIP] = MAX_SA;
169 config.max_sa[RTE_IPSEC_SAD_SPI_DIP_SIP] = MAX_SA;
170 config.socket_id = SOCKET_ID_ANY;
171 config.flags = 0;
172 if (ipv6)
173 config.flags = RTE_IPSEC_SAD_FLAG_IPV6;
174
175 sad = rte_ipsec_sad_create(__func__, &config);
176 RTE_TEST_ASSERT_NOT_NULL(sad, "Failed to create SAD\n");
177
178 /* key == NULL*/
179 status = rte_ipsec_sad_add(sad, NULL, RTE_IPSEC_SAD_SPI_DIP_SIP, sa);
180 RTE_TEST_ASSERT(status < 0,
181 "Call succeeded with invalid parameters\n");
182
183 /* len is incorrect*/
184 status = rte_ipsec_sad_add(sad, tuple,
185 RTE_IPSEC_SAD_SPI_DIP_SIP + 1, sa);
186 RTE_TEST_ASSERT(status < 0,
187 "Call succeeded with invalid parameters\n");
188
189 /* sa == NULL*/
190 status = rte_ipsec_sad_add(sad, tuple,
191 RTE_IPSEC_SAD_SPI_DIP_SIP, NULL);
192 RTE_TEST_ASSERT(status < 0,
193 "Call succeeded with invalid parameters\n");
194
195 /* sa is not aligned*/
196 status = rte_ipsec_sad_add(sad, tuple,
197 RTE_IPSEC_SAD_SPI_DIP_SIP, (void *)((uint8_t *)sa + 1));
198 RTE_TEST_ASSERT(status < 0,
199 "Call succeeded with invalid parameters\n");
200
201 rte_ipsec_sad_destroy(sad);
202
203 return TEST_SUCCESS;
204}
205
206/*
207 * Check that rte_ipsec_sad_add fails gracefully

Callers 1

test_add_invalidFunction · 0.85

Calls 3

rte_ipsec_sad_addFunction · 0.85
rte_ipsec_sad_createFunction · 0.85
rte_ipsec_sad_destroyFunction · 0.85

Tested by

no test coverage detected