xref: /dpdk/app/test/test_fbarray.c (revision a744665d2149ba8707621c1214c798f807ec398e)
1a9de470cSBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2a9de470cSBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
3a9de470cSBruce Richardson  */
4a9de470cSBruce Richardson 
5028669bcSAnatoly Burakov #include <stdbool.h>
6a9de470cSBruce Richardson #include <stdio.h>
7a9de470cSBruce Richardson #include <stdint.h>
8a9de470cSBruce Richardson #include <limits.h>
9a9de470cSBruce Richardson 
10a9de470cSBruce Richardson #include <rte_common.h>
11a9de470cSBruce Richardson #include <rte_debug.h>
12a9de470cSBruce Richardson #include <rte_errno.h>
13a9de470cSBruce Richardson #include <rte_fbarray.h>
14a9de470cSBruce Richardson 
15a9de470cSBruce Richardson #include "test.h"
16a9de470cSBruce Richardson 
17a9de470cSBruce Richardson struct fbarray_testsuite_params {
18a9de470cSBruce Richardson 	struct rte_fbarray arr;
19a9de470cSBruce Richardson 	int start;
20a9de470cSBruce Richardson 	int end;
21a9de470cSBruce Richardson };
22a9de470cSBruce Richardson 
23a9de470cSBruce Richardson static struct fbarray_testsuite_params param;
24*a744665dSAnatoly Burakov static struct fbarray_testsuite_params unaligned;
25a9de470cSBruce Richardson 
26a9de470cSBruce Richardson #define FBARRAY_TEST_ARR_NAME "fbarray_autotest"
27a9de470cSBruce Richardson #define FBARRAY_TEST_LEN 256
28*a744665dSAnatoly Burakov #define FBARRAY_UNALIGNED_TEST_ARR_NAME "fbarray_unaligned_autotest"
29*a744665dSAnatoly Burakov #define FBARRAY_UNALIGNED_TEST_LEN 60
30a9de470cSBruce Richardson #define FBARRAY_TEST_ELT_SZ (sizeof(int))
31a9de470cSBruce Richardson 
autotest_setup(void)32a9de470cSBruce Richardson static int autotest_setup(void)
33a9de470cSBruce Richardson {
34*a744665dSAnatoly Burakov 	int ret;
35*a744665dSAnatoly Burakov 
36*a744665dSAnatoly Burakov 	ret = rte_fbarray_init(&param.arr, FBARRAY_TEST_ARR_NAME,
37a9de470cSBruce Richardson 			FBARRAY_TEST_LEN, FBARRAY_TEST_ELT_SZ);
38*a744665dSAnatoly Burakov 	if (ret) {
39*a744665dSAnatoly Burakov 		printf("Failed to initialize test array\n");
40*a744665dSAnatoly Burakov 		return -1;
41*a744665dSAnatoly Burakov 	}
42*a744665dSAnatoly Burakov 	ret = rte_fbarray_init(&unaligned.arr, FBARRAY_UNALIGNED_TEST_ARR_NAME,
43*a744665dSAnatoly Burakov 			FBARRAY_UNALIGNED_TEST_LEN, FBARRAY_TEST_ELT_SZ);
44*a744665dSAnatoly Burakov 	if (ret) {
45*a744665dSAnatoly Burakov 		printf("Failed to initialize unaligned test array\n");
46*a744665dSAnatoly Burakov 		rte_fbarray_destroy(&param.arr);
47*a744665dSAnatoly Burakov 		return -1;
48*a744665dSAnatoly Burakov 	}
49*a744665dSAnatoly Burakov 	return 0;
50a9de470cSBruce Richardson }
51a9de470cSBruce Richardson 
autotest_teardown(void)52a9de470cSBruce Richardson static void autotest_teardown(void)
53a9de470cSBruce Richardson {
54a9de470cSBruce Richardson 	rte_fbarray_destroy(&param.arr);
55*a744665dSAnatoly Burakov 	rte_fbarray_destroy(&unaligned.arr);
56a9de470cSBruce Richardson }
57a9de470cSBruce Richardson 
init_aligned(void)58*a744665dSAnatoly Burakov static int init_aligned(void)
59a9de470cSBruce Richardson {
60a9de470cSBruce Richardson 	int i;
61a9de470cSBruce Richardson 	for (i = param.start; i <= param.end; i++) {
62a9de470cSBruce Richardson 		if (rte_fbarray_set_used(&param.arr, i))
63a9de470cSBruce Richardson 			return -1;
64a9de470cSBruce Richardson 	}
65a9de470cSBruce Richardson 	return 0;
66a9de470cSBruce Richardson }
67a9de470cSBruce Richardson 
init_unaligned(void)68*a744665dSAnatoly Burakov static int init_unaligned(void)
69*a744665dSAnatoly Burakov {
70*a744665dSAnatoly Burakov 	int i;
71*a744665dSAnatoly Burakov 	for (i = unaligned.start; i <= unaligned.end; i++) {
72*a744665dSAnatoly Burakov 		if (rte_fbarray_set_used(&unaligned.arr, i))
73*a744665dSAnatoly Burakov 			return -1;
74*a744665dSAnatoly Burakov 	}
75*a744665dSAnatoly Burakov 	return 0;
76*a744665dSAnatoly Burakov }
77*a744665dSAnatoly Burakov 
reset_aligned(void)78*a744665dSAnatoly Burakov static void reset_aligned(void)
79a9de470cSBruce Richardson {
80a9de470cSBruce Richardson 	int i;
81a9de470cSBruce Richardson 	for (i = 0; i < FBARRAY_TEST_LEN; i++)
82a9de470cSBruce Richardson 		rte_fbarray_set_free(&param.arr, i);
83*a744665dSAnatoly Burakov 	/* reset param as well */
84*a744665dSAnatoly Burakov 	param.start = -1;
85*a744665dSAnatoly Burakov 	param.end = -1;
86*a744665dSAnatoly Burakov }
87*a744665dSAnatoly Burakov 
reset_unaligned(void)88*a744665dSAnatoly Burakov static void reset_unaligned(void)
89*a744665dSAnatoly Burakov {
90*a744665dSAnatoly Burakov 	int i;
91*a744665dSAnatoly Burakov 	for (i = 0; i < FBARRAY_UNALIGNED_TEST_LEN; i++)
92*a744665dSAnatoly Burakov 		rte_fbarray_set_free(&unaligned.arr, i);
93*a744665dSAnatoly Burakov 	/* reset param as well */
94*a744665dSAnatoly Burakov 	unaligned.start = -1;
95*a744665dSAnatoly Burakov 	unaligned.end = -1;
96*a744665dSAnatoly Burakov 
97a9de470cSBruce Richardson }
98a9de470cSBruce Richardson 
first_msk_test_setup(void)99a9de470cSBruce Richardson static int first_msk_test_setup(void)
100a9de470cSBruce Richardson {
101a9de470cSBruce Richardson 	/* put all within first mask */
102a9de470cSBruce Richardson 	param.start = 3;
103a9de470cSBruce Richardson 	param.end = 10;
104*a744665dSAnatoly Burakov 	return init_aligned();
105a9de470cSBruce Richardson }
106a9de470cSBruce Richardson 
cross_msk_test_setup(void)107a9de470cSBruce Richardson static int cross_msk_test_setup(void)
108a9de470cSBruce Richardson {
109a9de470cSBruce Richardson 	/* put all within second and third mask */
110a9de470cSBruce Richardson 	param.start = 70;
111a9de470cSBruce Richardson 	param.end = 160;
112*a744665dSAnatoly Burakov 	return init_aligned();
113a9de470cSBruce Richardson }
114a9de470cSBruce Richardson 
multi_msk_test_setup(void)115a9de470cSBruce Richardson static int multi_msk_test_setup(void)
116a9de470cSBruce Richardson {
117a9de470cSBruce Richardson 	/* put all within first and last mask */
118a9de470cSBruce Richardson 	param.start = 3;
119a9de470cSBruce Richardson 	param.end = FBARRAY_TEST_LEN - 20;
120*a744665dSAnatoly Burakov 	return init_aligned();
121a9de470cSBruce Richardson }
122a9de470cSBruce Richardson 
last_msk_test_setup(void)123a9de470cSBruce Richardson static int last_msk_test_setup(void)
124a9de470cSBruce Richardson {
125a9de470cSBruce Richardson 	/* put all within last mask */
126a9de470cSBruce Richardson 	param.start = FBARRAY_TEST_LEN - 20;
127a9de470cSBruce Richardson 	param.end = FBARRAY_TEST_LEN - 1;
128*a744665dSAnatoly Burakov 	return init_aligned();
129a9de470cSBruce Richardson }
130a9de470cSBruce Richardson 
full_msk_test_setup(void)131a9de470cSBruce Richardson static int full_msk_test_setup(void)
132a9de470cSBruce Richardson {
133a9de470cSBruce Richardson 	/* fill entire mask */
134a9de470cSBruce Richardson 	param.start = 0;
135a9de470cSBruce Richardson 	param.end = FBARRAY_TEST_LEN - 1;
136*a744665dSAnatoly Burakov 	return init_aligned();
137a9de470cSBruce Richardson }
138a9de470cSBruce Richardson 
lookahead_test_setup(void)1398c03a149SAnatoly Burakov static int lookahead_test_setup(void)
1408c03a149SAnatoly Burakov {
1418c03a149SAnatoly Burakov 	/* set index 64 as used */
1428c03a149SAnatoly Burakov 	param.start = 64;
1438c03a149SAnatoly Burakov 	param.end = 64;
144*a744665dSAnatoly Burakov 	return init_aligned();
1458c03a149SAnatoly Burakov }
1468c03a149SAnatoly Burakov 
lookbehind_test_setup(void)1478e371292SAnatoly Burakov static int lookbehind_test_setup(void)
1488e371292SAnatoly Burakov {
1498e371292SAnatoly Burakov 	/* set index 63 as used */
1508e371292SAnatoly Burakov 	param.start = 63;
1518e371292SAnatoly Burakov 	param.end = 63;
152*a744665dSAnatoly Burakov 	return init_aligned();
153*a744665dSAnatoly Burakov }
154*a744665dSAnatoly Burakov 
unaligned_test_setup(void)155*a744665dSAnatoly Burakov static int unaligned_test_setup(void)
156*a744665dSAnatoly Burakov {
157*a744665dSAnatoly Burakov 	unaligned.start = 0;
158*a744665dSAnatoly Burakov 	/* leave one free bit at the end */
159*a744665dSAnatoly Burakov 	unaligned.end = FBARRAY_UNALIGNED_TEST_LEN - 2;
160*a744665dSAnatoly Burakov 	return init_unaligned();
1618e371292SAnatoly Burakov }
1628e371292SAnatoly Burakov 
test_invalid(void)163a9de470cSBruce Richardson static int test_invalid(void)
164a9de470cSBruce Richardson {
165a9de470cSBruce Richardson 	struct rte_fbarray dummy;
166a9de470cSBruce Richardson 
167a9de470cSBruce Richardson 	/* invalid parameters */
168a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_attach(NULL),
169a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
170a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
171a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_detach(NULL),
172a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
173a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
174a9de470cSBruce Richardson 
175a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_destroy(NULL),
176a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
177a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno valuey\n");
178a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_init(NULL, "fail", 16, 16),
179a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
180a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
181a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_init(&dummy, NULL, 16, 16),
182a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
183a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
184a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_init(&dummy, "fail", 0, 16),
185a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
186a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
187a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_init(&dummy, "fail", 16, 0),
188a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
189a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
190a9de470cSBruce Richardson 	/* len must not be greater than INT_MAX */
191a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(rte_fbarray_init(&dummy, "fail", INT_MAX + 1U, 16),
192a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
193a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
194a9de470cSBruce Richardson 
195a9de470cSBruce Richardson 	TEST_ASSERT_NULL(rte_fbarray_get(NULL, 0),
196a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
197a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
198a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_idx(NULL, 0) < 0,
199a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
200a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
201a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_set_free(NULL, 0),
202a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
203a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
204a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_set_used(NULL, 0),
205a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
206a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
207a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_contig_free(NULL, 0) < 0,
208a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
209a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
210a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_contig_used(NULL, 0) < 0,
211a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
212a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
213a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_rev_contig_free(NULL, 0) < 0,
214a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
215a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
216a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_rev_contig_used(NULL, 0) < 0,
217a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
218a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
219a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_free(NULL, 0) < 0,
220a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
221a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
222a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_used(NULL, 0) < 0,
223a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
224a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
225a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_free(NULL, 0) < 0,
226a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
227a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
228a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_used(NULL, 0) < 0,
229a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
230a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
231a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_free(NULL, 0, 0) < 0,
232a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
233a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
234a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_used(NULL, 0, 0) < 0,
235a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
236a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
237a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_free(NULL, 0, 0) < 0,
238a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
239a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
240a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_used(NULL, 0, 0) < 0,
241a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
242a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
243a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_is_used(NULL, 0) < 0,
244a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
245a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
246a9de470cSBruce Richardson 
247a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_fbarray_init(&dummy, "success",
248a9de470cSBruce Richardson 			FBARRAY_TEST_LEN, 8),
249a9de470cSBruce Richardson 			"Failed to initialize valid fbarray\n");
250a9de470cSBruce Richardson 
251a9de470cSBruce Richardson 	/* test API for handling invalid parameters with a valid fbarray */
252a9de470cSBruce Richardson 	TEST_ASSERT_NULL(rte_fbarray_get(&dummy, FBARRAY_TEST_LEN),
253a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
254a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
255a9de470cSBruce Richardson 
256a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_idx(&dummy, NULL) < 0,
257a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
258a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
259a9de470cSBruce Richardson 
260a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_set_free(&dummy, FBARRAY_TEST_LEN),
261a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
262a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
263a9de470cSBruce Richardson 
264a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_set_used(&dummy, FBARRAY_TEST_LEN),
265a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
266a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
267a9de470cSBruce Richardson 
268a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_contig_free(&dummy, FBARRAY_TEST_LEN) < 0,
269a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
270a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
271a9de470cSBruce Richardson 
272a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_contig_used(&dummy, FBARRAY_TEST_LEN) < 0,
273a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
274a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
275a9de470cSBruce Richardson 
276a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_rev_contig_free(&dummy,
277a9de470cSBruce Richardson 			FBARRAY_TEST_LEN) < 0,
278a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
279a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
280a9de470cSBruce Richardson 
281a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_rev_contig_used(&dummy,
282a9de470cSBruce Richardson 			FBARRAY_TEST_LEN) < 0,
283a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
284a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
285a9de470cSBruce Richardson 
286a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_free(&dummy, FBARRAY_TEST_LEN) < 0,
287a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
288a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
289a9de470cSBruce Richardson 
290a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_used(&dummy, FBARRAY_TEST_LEN) < 0,
291a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
292a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
293a9de470cSBruce Richardson 
294a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_free(&dummy, FBARRAY_TEST_LEN) < 0,
295a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
296a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
297a9de470cSBruce Richardson 
298a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_used(&dummy, FBARRAY_TEST_LEN) < 0,
299a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
300a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
301a9de470cSBruce Richardson 
302a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_free(&dummy,
303a9de470cSBruce Richardson 			FBARRAY_TEST_LEN, 1) < 0,
304a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
305a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
306a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_free(&dummy, 0,
307a9de470cSBruce Richardson 			FBARRAY_TEST_LEN + 1) < 0,
308a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
309a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
310a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_free(&dummy, 0, 0) < 0,
311a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
312a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
313a9de470cSBruce Richardson 
314a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_used(&dummy,
315a9de470cSBruce Richardson 			FBARRAY_TEST_LEN, 1) < 0,
316a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
317a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
318a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_used(&dummy, 0,
319a9de470cSBruce Richardson 			FBARRAY_TEST_LEN + 1) < 0,
320a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
321a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
322a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_used(&dummy, 0, 0) < 0,
323a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
324a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
325a9de470cSBruce Richardson 
326a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_free(&dummy,
327a9de470cSBruce Richardson 			FBARRAY_TEST_LEN, 1) < 0,
328a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
329a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
330a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_free(&dummy, 0,
331a9de470cSBruce Richardson 			FBARRAY_TEST_LEN + 1) < 0,
332a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
333a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
334a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_free(&dummy, 0, 0) < 0,
335a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
336a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
337a9de470cSBruce Richardson 
338a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_used(&dummy,
339a9de470cSBruce Richardson 			FBARRAY_TEST_LEN, 1) < 0,
340a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
341a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
342a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_used(&dummy, 0,
343a9de470cSBruce Richardson 			FBARRAY_TEST_LEN + 1) < 0,
344a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
345a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
346a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_used(&dummy, 0, 0) < 0,
347a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
348a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
349a9de470cSBruce Richardson 
350a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_is_used(&dummy, FBARRAY_TEST_LEN) < 0,
351a9de470cSBruce Richardson 			"Call succeeded with invalid parameters\n");
352a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, EINVAL, "Wrong errno value\n");
353a9de470cSBruce Richardson 
354a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_fbarray_destroy(&dummy),
355a9de470cSBruce Richardson 			"Failed to destroy valid fbarray\n");
356a9de470cSBruce Richardson 
357a9de470cSBruce Richardson 	return TEST_SUCCESS;
358a9de470cSBruce Richardson }
359a9de470cSBruce Richardson 
check_free(void)360a9de470cSBruce Richardson static int check_free(void)
361a9de470cSBruce Richardson {
362a9de470cSBruce Richardson 	const int idx = 0;
363a9de470cSBruce Richardson 	const int last_idx = FBARRAY_TEST_LEN - 1;
364a9de470cSBruce Richardson 
365a9de470cSBruce Richardson 	/* ensure we can find a free spot */
366a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_next_free(&param.arr, idx), idx,
367a9de470cSBruce Richardson 			"Free space not found where expected\n");
368a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(&param.arr, idx, 1), idx,
369a9de470cSBruce Richardson 			"Free space not found where expected\n");
370a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(&param.arr, idx),
371a9de470cSBruce Richardson 			FBARRAY_TEST_LEN,
372a9de470cSBruce Richardson 			"Free space not found where expected\n");
373a9de470cSBruce Richardson 
374a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_free(&param.arr, idx), idx,
375a9de470cSBruce Richardson 			"Free space not found where expected\n");
376a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(&param.arr, idx, 1), idx,
377a9de470cSBruce Richardson 			"Free space not found where expected\n");
378a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(&param.arr, idx), 1,
379a9de470cSBruce Richardson 			"Free space not found where expected\n");
380a9de470cSBruce Richardson 
381a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_free(&param.arr, last_idx),
382a9de470cSBruce Richardson 			last_idx, "Free space not found where expected\n");
383a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(&param.arr, last_idx, 1),
384a9de470cSBruce Richardson 			last_idx, "Free space not found where expected\n");
385a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(&param.arr,
386a9de470cSBruce Richardson 			last_idx), FBARRAY_TEST_LEN,
387a9de470cSBruce Richardson 			"Free space not found where expected\n");
388a9de470cSBruce Richardson 
389a9de470cSBruce Richardson 	/* ensure we can't find any used spots */
390a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_used(&param.arr, idx) < 0,
391a9de470cSBruce Richardson 			"Used space found where none was expected\n");
392a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, ENOENT, "Wrong errno value\n");
393a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_used(&param.arr, idx, 1) < 0,
394a9de470cSBruce Richardson 			"Used space found where none was expected\n");
395a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, ENOENT, "Wrong errno value\n");
396a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(&param.arr, idx), 0,
397a9de470cSBruce Richardson 			"Used space found where none was expected\n");
398a9de470cSBruce Richardson 
399a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_used(&param.arr, last_idx) < 0,
400a9de470cSBruce Richardson 			"Used space found where none was expected\n");
401a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, ENOENT, "Wrong errno value\n");
402a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_prev_n_used(&param.arr, last_idx, 1) < 0,
403a9de470cSBruce Richardson 			"Used space found where none was expected\n");
404a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, ENOENT, "Wrong errno value\n");
405a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(&param.arr,
406a9de470cSBruce Richardson 			last_idx), 0,
407a9de470cSBruce Richardson 			"Used space found where none was expected\n");
408a9de470cSBruce Richardson 
409a9de470cSBruce Richardson 	return 0;
410a9de470cSBruce Richardson }
411a9de470cSBruce Richardson 
check_used_one(void)412a9de470cSBruce Richardson static int check_used_one(void)
413a9de470cSBruce Richardson {
414a9de470cSBruce Richardson 	const int idx = 0;
415a9de470cSBruce Richardson 	const int last_idx = FBARRAY_TEST_LEN - 1;
416a9de470cSBruce Richardson 
417a9de470cSBruce Richardson 	/* check that we can find used spots now */
418a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_next_used(&param.arr, idx), idx,
419a9de470cSBruce Richardson 			"Used space not found where expected\n");
420a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_used(&param.arr, idx, 1), idx,
421a9de470cSBruce Richardson 			"Used space not found where expected\n");
422a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(&param.arr, idx), 1,
423a9de470cSBruce Richardson 			"Used space not found where expected\n");
424a9de470cSBruce Richardson 
425a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_used(&param.arr, last_idx), idx,
426a9de470cSBruce Richardson 			"Used space not found where expected\n");
427a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_used(&param.arr, last_idx, 1),
428a9de470cSBruce Richardson 			idx, "Used space not found where expected\n");
429a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(&param.arr, idx), 1,
430a9de470cSBruce Richardson 			"Used space not found where expected\n");
431a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(&param.arr,
432a9de470cSBruce Richardson 			last_idx), idx,
433a9de470cSBruce Richardson 			"Used space not found where expected\n");
434a9de470cSBruce Richardson 
435a9de470cSBruce Richardson 	/* check if further indices are still free */
436a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_used(&param.arr, idx + 1) < 0,
437a9de470cSBruce Richardson 			"Used space not found where none was expected\n");
438a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, ENOENT, "Wrong errno value\n");
439a9de470cSBruce Richardson 	TEST_ASSERT(rte_fbarray_find_next_n_used(&param.arr, idx + 1, 1) < 0,
440a9de470cSBruce Richardson 			"Used space not found where none was expected\n");
441a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_errno, ENOENT, "Wrong errno value\n");
442a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(&param.arr, idx + 1), 0,
443a9de470cSBruce Richardson 			"Used space not found where none was expected\n");
444a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(&param.arr, idx + 1),
445a9de470cSBruce Richardson 			FBARRAY_TEST_LEN - 1,
446a9de470cSBruce Richardson 			"Used space not found where none was expected\n");
447a9de470cSBruce Richardson 
448a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_used(&param.arr, last_idx), 0,
449a9de470cSBruce Richardson 			"Used space not found where none was expected\n");
450a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_used(&param.arr, last_idx, 1),
451a9de470cSBruce Richardson 			0, "Used space not found where none was expected\n");
452a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(&param.arr,
453a9de470cSBruce Richardson 			last_idx), 0,
454a9de470cSBruce Richardson 			"Used space not found where none was expected\n");
455a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(&param.arr,
456a9de470cSBruce Richardson 			last_idx), FBARRAY_TEST_LEN - 1,
457a9de470cSBruce Richardson 			"Used space not found where none was expected\n");
458a9de470cSBruce Richardson 
459a9de470cSBruce Richardson 	return 0;
460a9de470cSBruce Richardson }
461a9de470cSBruce Richardson 
test_basic(void)462a9de470cSBruce Richardson static int test_basic(void)
463a9de470cSBruce Richardson {
464a9de470cSBruce Richardson 	const int idx = 0;
465a9de470cSBruce Richardson 	int i;
466a9de470cSBruce Richardson 
467a9de470cSBruce Richardson 	/* check array count */
468a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(param.arr.count, 0, "Wrong element count\n");
469a9de470cSBruce Richardson 
470a9de470cSBruce Richardson 	/* ensure we can find a free spot */
471a9de470cSBruce Richardson 	if (check_free())
472a9de470cSBruce Richardson 		return TEST_FAILED;
473a9de470cSBruce Richardson 
474a9de470cSBruce Richardson 	/* check if used */
475a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_is_used(&param.arr, idx), 0,
476a9de470cSBruce Richardson 			"Used space found where not expected\n");
477a9de470cSBruce Richardson 
478a9de470cSBruce Richardson 	/* mark as used */
479a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_fbarray_set_used(&param.arr, idx),
480a9de470cSBruce Richardson 			"Failed to set as used\n");
481a9de470cSBruce Richardson 
482a9de470cSBruce Richardson 	/* check if used again */
483a9de470cSBruce Richardson 	TEST_ASSERT_NOT_EQUAL(rte_fbarray_is_used(&param.arr, idx), 0,
484a9de470cSBruce Richardson 			"Used space not found where expected\n");
485a9de470cSBruce Richardson 
486a9de470cSBruce Richardson 	if (check_used_one())
487a9de470cSBruce Richardson 		return TEST_FAILED;
488a9de470cSBruce Richardson 
489a9de470cSBruce Richardson 	/* check array count */
490a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(param.arr.count, 1, "Wrong element count\n");
491a9de470cSBruce Richardson 
492a9de470cSBruce Richardson 	/* check if getting pointers works for every element */
493a9de470cSBruce Richardson 	for (i = 0; i < FBARRAY_TEST_LEN; i++) {
494a9de470cSBruce Richardson 		void *td = rte_fbarray_get(&param.arr, i);
495a9de470cSBruce Richardson 		TEST_ASSERT_NOT_NULL(td, "Invalid pointer returned\n");
496a9de470cSBruce Richardson 		TEST_ASSERT_EQUAL(rte_fbarray_find_idx(&param.arr, td), i,
497a9de470cSBruce Richardson 				"Wrong index returned\n");
498a9de470cSBruce Richardson 	}
499a9de470cSBruce Richardson 
500a9de470cSBruce Richardson 	/* mark as free */
501a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_fbarray_set_free(&param.arr, idx),
502a9de470cSBruce Richardson 			"Failed to set as free\n");
503a9de470cSBruce Richardson 
504a9de470cSBruce Richardson 	/* check array count */
505a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(param.arr.count, 0, "Wrong element count\n");
506a9de470cSBruce Richardson 
507a9de470cSBruce Richardson 	/* check if used */
508a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_fbarray_is_used(&param.arr, idx), 0,
509a9de470cSBruce Richardson 			"Used space found where not expected\n");
510a9de470cSBruce Richardson 
511a9de470cSBruce Richardson 	if (check_free())
512a9de470cSBruce Richardson 		return TEST_FAILED;
513a9de470cSBruce Richardson 
514*a744665dSAnatoly Burakov 	reset_aligned();
515a9de470cSBruce Richardson 
516a9de470cSBruce Richardson 	return TEST_SUCCESS;
517a9de470cSBruce Richardson }
518a9de470cSBruce Richardson 
test_biggest(struct rte_fbarray * arr,int first,int last)5197353ee73SAnatoly Burakov static int test_biggest(struct rte_fbarray *arr, int first, int last)
5207353ee73SAnatoly Burakov {
5217353ee73SAnatoly Burakov 	int lo_free_space_first, lo_free_space_last, lo_free_space_len;
5227353ee73SAnatoly Burakov 	int hi_free_space_first, hi_free_space_last, hi_free_space_len;
5237353ee73SAnatoly Burakov 	int max_free_space_first, max_free_space_last, max_free_space_len;
5247353ee73SAnatoly Burakov 	int len = last - first + 1;
5257353ee73SAnatoly Burakov 
5267353ee73SAnatoly Burakov 	/* first and last must either be both -1, or both not -1 */
5277353ee73SAnatoly Burakov 	TEST_ASSERT((first == -1) == (last == -1),
5287353ee73SAnatoly Burakov 			"Invalid arguments provided\n");
5297353ee73SAnatoly Burakov 
5307353ee73SAnatoly Burakov 	/* figure out what we expect from the low chunk of free space */
5317353ee73SAnatoly Burakov 	if (first == -1) {
5327353ee73SAnatoly Burakov 		/* special case: if there are no occupied elements at all,
5337353ee73SAnatoly Burakov 		 * consider both free spaces to consume the entire array.
5347353ee73SAnatoly Burakov 		 */
5357353ee73SAnatoly Burakov 		lo_free_space_first = 0;
5367353ee73SAnatoly Burakov 		lo_free_space_last = arr->len - 1;
5377353ee73SAnatoly Burakov 		lo_free_space_len = arr->len;
5387353ee73SAnatoly Burakov 		/* if there's no used space, length should be invalid */
5397353ee73SAnatoly Burakov 		len = -1;
5407353ee73SAnatoly Burakov 	} else if (first == 0) {
5417353ee73SAnatoly Burakov 		/* if occupied items start at 0, there's no free space */
5427353ee73SAnatoly Burakov 		lo_free_space_first = -1;
5437353ee73SAnatoly Burakov 		lo_free_space_last = -1;
5447353ee73SAnatoly Burakov 		lo_free_space_len = 0;
5457353ee73SAnatoly Burakov 	} else {
5467353ee73SAnatoly Burakov 		lo_free_space_first = 0;
5477353ee73SAnatoly Burakov 		lo_free_space_last = first - 1;
5487353ee73SAnatoly Burakov 		lo_free_space_len = lo_free_space_last -
5497353ee73SAnatoly Burakov 				lo_free_space_first + 1;
5507353ee73SAnatoly Burakov 	}
5517353ee73SAnatoly Burakov 
5527353ee73SAnatoly Burakov 	/* figure out what we expect from the high chunk of free space */
5537353ee73SAnatoly Burakov 	if (last == -1) {
5547353ee73SAnatoly Burakov 		/* special case: if there are no occupied elements at all,
5557353ee73SAnatoly Burakov 		 * consider both free spaces to consume the entire array.
5567353ee73SAnatoly Burakov 		 */
5577353ee73SAnatoly Burakov 		hi_free_space_first = 0;
5587353ee73SAnatoly Burakov 		hi_free_space_last = arr->len - 1;
5597353ee73SAnatoly Burakov 		hi_free_space_len = arr->len;
5607353ee73SAnatoly Burakov 		/* if there's no used space, length should be invalid */
5617353ee73SAnatoly Burakov 		len = -1;
5627353ee73SAnatoly Burakov 	} else if (last == ((int)arr->len - 1)) {
5637353ee73SAnatoly Burakov 		/* if occupied items end at array len, there's no free space */
5647353ee73SAnatoly Burakov 		hi_free_space_first = -1;
5657353ee73SAnatoly Burakov 		hi_free_space_last = -1;
5667353ee73SAnatoly Burakov 		hi_free_space_len = 0;
5677353ee73SAnatoly Burakov 	} else {
5687353ee73SAnatoly Burakov 		hi_free_space_first = last + 1;
5697353ee73SAnatoly Burakov 		hi_free_space_last = arr->len - 1;
5707353ee73SAnatoly Burakov 		hi_free_space_len = hi_free_space_last -
5717353ee73SAnatoly Burakov 				hi_free_space_first + 1;
5727353ee73SAnatoly Burakov 	}
5737353ee73SAnatoly Burakov 
5747353ee73SAnatoly Burakov 	/* find which one will be biggest */
5757353ee73SAnatoly Burakov 	if (lo_free_space_len > hi_free_space_len) {
5767353ee73SAnatoly Burakov 		max_free_space_first = lo_free_space_first;
5777353ee73SAnatoly Burakov 		max_free_space_last = lo_free_space_last;
5787353ee73SAnatoly Burakov 		max_free_space_len = lo_free_space_len;
5797353ee73SAnatoly Burakov 	} else {
5807353ee73SAnatoly Burakov 		/* if they are equal, we'll just use the high chunk */
5817353ee73SAnatoly Burakov 		max_free_space_first = hi_free_space_first;
5827353ee73SAnatoly Burakov 		max_free_space_last = hi_free_space_last;
5837353ee73SAnatoly Burakov 		max_free_space_len = hi_free_space_len;
5847353ee73SAnatoly Burakov 	}
5857353ee73SAnatoly Burakov 
5867353ee73SAnatoly Burakov 	/* check used regions - these should produce identical results */
5877353ee73SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_biggest_used(arr, 0), first,
5887353ee73SAnatoly Burakov 			"Used space index is wrong\n");
5897353ee73SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_biggest_used(arr, arr->len - 1),
5907353ee73SAnatoly Burakov 			first,
5917353ee73SAnatoly Burakov 			"Used space index is wrong\n");
5927353ee73SAnatoly Burakov 	/* len may be -1, but function will return error anyway */
5937353ee73SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(arr, first), len,
5947353ee73SAnatoly Burakov 			"Used space length is wrong\n");
5957353ee73SAnatoly Burakov 
5967353ee73SAnatoly Burakov 	/* check if biggest free region is the one we expect to find. It can be
5977353ee73SAnatoly Burakov 	 * -1 if there's no free space - we've made sure we use one or the
5987353ee73SAnatoly Burakov 	 * other, even if both are invalid.
5997353ee73SAnatoly Burakov 	 */
6007353ee73SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_biggest_free(arr, 0),
6017353ee73SAnatoly Burakov 			max_free_space_first,
6027353ee73SAnatoly Burakov 			"Biggest free space index is wrong\n");
6037353ee73SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_rev_biggest_free(arr, arr->len - 1),
6047353ee73SAnatoly Burakov 			max_free_space_first,
6057353ee73SAnatoly Burakov 			"Biggest free space index is wrong\n");
6067353ee73SAnatoly Burakov 
6077353ee73SAnatoly Burakov 	/* if biggest region exists, check its length */
6087353ee73SAnatoly Burakov 	if (max_free_space_first != -1) {
6097353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(arr,
6107353ee73SAnatoly Burakov 					max_free_space_first),
6117353ee73SAnatoly Burakov 				max_free_space_len,
6127353ee73SAnatoly Burakov 				"Biggest free space length is wrong\n");
6137353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(arr,
6147353ee73SAnatoly Burakov 					max_free_space_last),
6157353ee73SAnatoly Burakov 				max_free_space_len,
6167353ee73SAnatoly Burakov 				"Biggest free space length is wrong\n");
6177353ee73SAnatoly Burakov 	}
6187353ee73SAnatoly Burakov 
6197353ee73SAnatoly Burakov 	/* find if we see what we expect to see in the low region. if there is
6207353ee73SAnatoly Burakov 	 * no free space, the function should still match expected value, as
6217353ee73SAnatoly Burakov 	 * we've set it to -1. we're scanning backwards to avoid accidentally
6227353ee73SAnatoly Burakov 	 * hitting the high free space region. if there is no occupied space,
6237353ee73SAnatoly Burakov 	 * there's nothing to do.
6247353ee73SAnatoly Burakov 	 */
6257353ee73SAnatoly Burakov 	if (last != -1) {
6267353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_rev_biggest_free(arr, last),
6277353ee73SAnatoly Burakov 				lo_free_space_first,
6287353ee73SAnatoly Burakov 				"Low free space index is wrong\n");
6297353ee73SAnatoly Burakov 	}
6307353ee73SAnatoly Burakov 
6317353ee73SAnatoly Burakov 	if (lo_free_space_first != -1) {
6327353ee73SAnatoly Burakov 		/* if low free region exists, check its length */
6337353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(arr,
6347353ee73SAnatoly Burakov 					lo_free_space_first),
6357353ee73SAnatoly Burakov 				lo_free_space_len,
6367353ee73SAnatoly Burakov 				"Low free space length is wrong\n");
6377353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(arr,
6387353ee73SAnatoly Burakov 					lo_free_space_last),
6397353ee73SAnatoly Burakov 				lo_free_space_len,
6407353ee73SAnatoly Burakov 				"Low free space length is wrong\n");
6417353ee73SAnatoly Burakov 	}
6427353ee73SAnatoly Burakov 
6437353ee73SAnatoly Burakov 	/* find if we see what we expect to see in the high region. if there is
6447353ee73SAnatoly Burakov 	 * no free space, the function should still match expected value, as
6457353ee73SAnatoly Burakov 	 * we've set it to -1. we're scanning forwards to avoid accidentally
6467353ee73SAnatoly Burakov 	 * hitting the low free space region. if there is no occupied space,
6477353ee73SAnatoly Burakov 	 * there's nothing to do.
6487353ee73SAnatoly Burakov 	 */
6497353ee73SAnatoly Burakov 	if (first != -1) {
6507353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_biggest_free(arr, first),
6517353ee73SAnatoly Burakov 				hi_free_space_first,
6527353ee73SAnatoly Burakov 				"High free space index is wrong\n");
6537353ee73SAnatoly Burakov 	}
6547353ee73SAnatoly Burakov 
6557353ee73SAnatoly Burakov 	/* if high free region exists, check its length */
6567353ee73SAnatoly Burakov 	if (hi_free_space_first != -1) {
6577353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(arr,
6587353ee73SAnatoly Burakov 					hi_free_space_first),
6597353ee73SAnatoly Burakov 				hi_free_space_len,
6607353ee73SAnatoly Burakov 				"High free space length is wrong\n");
6617353ee73SAnatoly Burakov 		TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(arr,
6627353ee73SAnatoly Burakov 					hi_free_space_last),
6637353ee73SAnatoly Burakov 				hi_free_space_len,
6647353ee73SAnatoly Burakov 				"High free space length is wrong\n");
6657353ee73SAnatoly Burakov 	}
6667353ee73SAnatoly Burakov 
6677353ee73SAnatoly Burakov 	return 0;
6687353ee73SAnatoly Burakov }
6697353ee73SAnatoly Burakov 
ensure_correct(struct rte_fbarray * arr,int first,int last,bool used)670a9de470cSBruce Richardson static int ensure_correct(struct rte_fbarray *arr, int first, int last,
671a9de470cSBruce Richardson 		bool used)
672a9de470cSBruce Richardson {
673a9de470cSBruce Richardson 	int i, len = last - first + 1;
674a9de470cSBruce Richardson 	for (i = 0; i < len; i++) {
675a9de470cSBruce Richardson 		int cur = first + i;
676a9de470cSBruce Richardson 		int cur_len = len - i;
677a9de470cSBruce Richardson 
678a9de470cSBruce Richardson 		if (used) {
679a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_contig_used(arr,
680a9de470cSBruce Richardson 					cur), cur_len,
681a9de470cSBruce Richardson 					"Used space length is wrong\n");
682a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(arr,
683a9de470cSBruce Richardson 					last), len,
684a9de470cSBruce Richardson 					"Used space length is wrong\n");
685a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_used(arr,
686a9de470cSBruce Richardson 					cur), i + 1,
687a9de470cSBruce Richardson 					"Used space length is wrong\n");
688a9de470cSBruce Richardson 
689a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_next_used(arr, cur),
690a9de470cSBruce Richardson 					cur,
691a9de470cSBruce Richardson 					"Used space not found where expected\n");
692a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_used(arr,
693a9de470cSBruce Richardson 					cur, 1), cur,
694a9de470cSBruce Richardson 					"Used space not found where expected\n");
695a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_used(arr, cur,
696a9de470cSBruce Richardson 					cur_len), cur,
697a9de470cSBruce Richardson 					"Used space not found where expected\n");
698a9de470cSBruce Richardson 
699a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_prev_used(arr, cur),
700a9de470cSBruce Richardson 					cur,
701a9de470cSBruce Richardson 					"Used space not found where expected\n");
702a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_used(arr,
703a9de470cSBruce Richardson 					last, cur_len), cur,
704a9de470cSBruce Richardson 					"Used space not found where expected\n");
705a9de470cSBruce Richardson 		} else {
706a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_contig_free(arr,
707a9de470cSBruce Richardson 					cur), cur_len,
708a9de470cSBruce Richardson 					"Free space length is wrong\n");
709a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(arr,
710a9de470cSBruce Richardson 					last), len,
711a9de470cSBruce Richardson 					"Free space length is wrong\n");
712a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_rev_contig_free(arr,
713a9de470cSBruce Richardson 					cur), i + 1,
714a9de470cSBruce Richardson 					"Free space length is wrong\n");
715a9de470cSBruce Richardson 
716a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_next_free(arr, cur),
717a9de470cSBruce Richardson 					cur,
718a9de470cSBruce Richardson 					"Free space not found where expected\n");
719a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(arr, cur,
720a9de470cSBruce Richardson 					1), cur,
721a9de470cSBruce Richardson 					"Free space not found where expected\n");
722a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(arr, cur,
723a9de470cSBruce Richardson 					cur_len), cur,
724a9de470cSBruce Richardson 					"Free space not found where expected\n");
725a9de470cSBruce Richardson 
726a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_prev_free(arr, cur),
727a9de470cSBruce Richardson 					cur,
728a9de470cSBruce Richardson 					"Free space not found where expected\n");
729a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(arr,
730a9de470cSBruce Richardson 					last, cur_len), cur,
731a9de470cSBruce Richardson 					"Free space not found where expected\n");
732a9de470cSBruce Richardson 		}
733a9de470cSBruce Richardson 	}
734a9de470cSBruce Richardson 	return 0;
735a9de470cSBruce Richardson }
736a9de470cSBruce Richardson 
test_find(void)737a9de470cSBruce Richardson static int test_find(void)
738a9de470cSBruce Richardson {
739a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL((int)param.arr.count, param.end - param.start + 1,
740a9de470cSBruce Richardson 			"Wrong element count\n");
741a9de470cSBruce Richardson 	/* ensure space is free before start */
742a9de470cSBruce Richardson 	if (ensure_correct(&param.arr, 0, param.start - 1, false))
743a9de470cSBruce Richardson 		return TEST_FAILED;
744a9de470cSBruce Richardson 	/* ensure space is occupied where it's supposed to be */
745a9de470cSBruce Richardson 	if (ensure_correct(&param.arr, param.start, param.end, true))
746a9de470cSBruce Richardson 		return TEST_FAILED;
747a9de470cSBruce Richardson 	/* ensure space after end is free as well */
748a9de470cSBruce Richardson 	if (ensure_correct(&param.arr, param.end + 1, FBARRAY_TEST_LEN - 1,
749a9de470cSBruce Richardson 			false))
750a9de470cSBruce Richardson 		return TEST_FAILED;
7517353ee73SAnatoly Burakov 	/* test if find_biggest API's work correctly */
7527353ee73SAnatoly Burakov 	if (test_biggest(&param.arr, param.start, param.end))
7537353ee73SAnatoly Burakov 		return TEST_FAILED;
754a9de470cSBruce Richardson 	return TEST_SUCCESS;
755a9de470cSBruce Richardson }
756a9de470cSBruce Richardson 
test_find_unaligned(void)757*a744665dSAnatoly Burakov static int test_find_unaligned(void)
758*a744665dSAnatoly Burakov {
759*a744665dSAnatoly Burakov 	TEST_ASSERT_EQUAL((int)unaligned.arr.count, unaligned.end - unaligned.start + 1,
760*a744665dSAnatoly Burakov 			"Wrong element count\n");
761*a744665dSAnatoly Burakov 	/* ensure space is free before start */
762*a744665dSAnatoly Burakov 	if (ensure_correct(&unaligned.arr, 0, unaligned.start - 1, false))
763*a744665dSAnatoly Burakov 		return TEST_FAILED;
764*a744665dSAnatoly Burakov 	/* ensure space is occupied where it's supposed to be */
765*a744665dSAnatoly Burakov 	if (ensure_correct(&unaligned.arr, unaligned.start, unaligned.end, true))
766*a744665dSAnatoly Burakov 		return TEST_FAILED;
767*a744665dSAnatoly Burakov 	/* ensure space after end is free as well */
768*a744665dSAnatoly Burakov 	if (ensure_correct(&unaligned.arr, unaligned.end + 1, FBARRAY_UNALIGNED_TEST_LEN - 1,
769*a744665dSAnatoly Burakov 			false))
770*a744665dSAnatoly Burakov 		return TEST_FAILED;
771*a744665dSAnatoly Burakov 	/* test if find_biggest API's work correctly */
772*a744665dSAnatoly Burakov 	if (test_biggest(&unaligned.arr, unaligned.start, unaligned.end))
773*a744665dSAnatoly Burakov 		return TEST_FAILED;
774*a744665dSAnatoly Burakov 	return TEST_SUCCESS;
775*a744665dSAnatoly Burakov }
776*a744665dSAnatoly Burakov 
test_empty(void)777a9de470cSBruce Richardson static int test_empty(void)
778a9de470cSBruce Richardson {
779a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL((int)param.arr.count, 0, "Wrong element count\n");
780a9de470cSBruce Richardson 	/* ensure space is free */
781a9de470cSBruce Richardson 	if (ensure_correct(&param.arr, 0, FBARRAY_TEST_LEN - 1, false))
782a9de470cSBruce Richardson 		return TEST_FAILED;
7837353ee73SAnatoly Burakov 	/* test if find_biggest API's work correctly */
7847353ee73SAnatoly Burakov 	if (test_biggest(&param.arr, param.start, param.end))
7857353ee73SAnatoly Burakov 		return TEST_FAILED;
786a9de470cSBruce Richardson 	return TEST_SUCCESS;
787a9de470cSBruce Richardson }
788a9de470cSBruce Richardson 
test_lookahead(void)7898c03a149SAnatoly Burakov static int test_lookahead(void)
7908c03a149SAnatoly Burakov {
7918c03a149SAnatoly Burakov 	int ret;
7928c03a149SAnatoly Burakov 
7938c03a149SAnatoly Burakov 	/* run regular test first */
7948c03a149SAnatoly Burakov 	ret = test_find();
7958c03a149SAnatoly Burakov 	if (ret != TEST_SUCCESS)
7968c03a149SAnatoly Burakov 		return ret;
7978c03a149SAnatoly Burakov 
7988c03a149SAnatoly Burakov 	/* test if we can find free chunk while not starting with 0 */
7998c03a149SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(&param.arr, 1, param.start),
8008c03a149SAnatoly Burakov 			param.start + 1, "Free chunk index is wrong\n");
8018c03a149SAnatoly Burakov 	return TEST_SUCCESS;
8028c03a149SAnatoly Burakov }
803a9de470cSBruce Richardson 
test_lookbehind(void)8048e371292SAnatoly Burakov static int test_lookbehind(void)
8058e371292SAnatoly Burakov {
8068e371292SAnatoly Burakov 	int ret, free_len = 2;
8078e371292SAnatoly Burakov 
8088e371292SAnatoly Burakov 	/* run regular test first */
8098e371292SAnatoly Burakov 	ret = test_find();
8108e371292SAnatoly Burakov 	if (ret != TEST_SUCCESS)
8118e371292SAnatoly Burakov 		return ret;
8128e371292SAnatoly Burakov 
8138e371292SAnatoly Burakov 	/* test if we can find free chunk while crossing mask boundary */
8148e371292SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(&param.arr, param.start + 1, free_len),
8158e371292SAnatoly Burakov 			param.start - free_len, "Free chunk index is wrong\n");
8168e371292SAnatoly Burakov 	return TEST_SUCCESS;
8178e371292SAnatoly Burakov }
8188e371292SAnatoly Burakov 
test_lookahead_mask(void)819a344719cSAnatoly Burakov static int test_lookahead_mask(void)
820a344719cSAnatoly Burakov {
821a344719cSAnatoly Burakov 	/*
822a344719cSAnatoly Burakov 	 * There is a certain type of lookahead behavior we want to test here,
823a344719cSAnatoly Burakov 	 * namely masking of bits that were scanned with lookahead but that we
824a344719cSAnatoly Burakov 	 * know do not match our criteria. This is achieved in following steps:
825a344719cSAnatoly Burakov 	 *
826a344719cSAnatoly Burakov 	 *   0. Look for a big enough chunk of free space (say, 62 elements)
827a344719cSAnatoly Burakov 	 *   1. Trigger lookahead by breaking a run somewhere inside mask 0
828a344719cSAnatoly Burakov 	 *      (indices 0-63)
829a344719cSAnatoly Burakov 	 *   2. Fail lookahead by breaking the run somewhere inside mask 1
830a344719cSAnatoly Burakov 	 *      (indices 64-127)
831a344719cSAnatoly Burakov 	 *   3. Ensure that we can still find free space in mask 1 afterwards
832a344719cSAnatoly Burakov 	 */
833a344719cSAnatoly Burakov 
834a344719cSAnatoly Burakov 	/* break run on first mask */
835a344719cSAnatoly Burakov 	rte_fbarray_set_used(&param.arr, 61);
836a344719cSAnatoly Burakov 	/* break run on second mask */
837a344719cSAnatoly Burakov 	rte_fbarray_set_used(&param.arr, 70);
838a344719cSAnatoly Burakov 
839a344719cSAnatoly Burakov 	/* we expect to find free space at 71 */
840a344719cSAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_next_n_free(&param.arr, 0, 62),
841a344719cSAnatoly Burakov 			71, "Free chunk index is wrong\n");
842a344719cSAnatoly Burakov 	return TEST_SUCCESS;
843a344719cSAnatoly Burakov }
844a344719cSAnatoly Burakov 
test_lookbehind_mask(void)8450c6e2781SAnatoly Burakov static int test_lookbehind_mask(void)
8460c6e2781SAnatoly Burakov {
8470c6e2781SAnatoly Burakov 	/*
8480c6e2781SAnatoly Burakov 	 * There is a certain type of lookbehind behavior we want to test here,
8490c6e2781SAnatoly Burakov 	 * namely masking of bits that were scanned with lookbehind but that we
8500c6e2781SAnatoly Burakov 	 * know do not match our criteria. This is achieved in two steps:
8510c6e2781SAnatoly Burakov 	 *
8520c6e2781SAnatoly Burakov 	 *   0. Look for a big enough chunk of free space (say, 62 elements)
8530c6e2781SAnatoly Burakov 	 *   1. Trigger lookbehind by breaking a run somewhere inside mask 2
8540c6e2781SAnatoly Burakov 	 *      (indices 128-191)
8550c6e2781SAnatoly Burakov 	 *   2. Fail lookbehind by breaking the run somewhere inside mask 1
8560c6e2781SAnatoly Burakov 	 *      (indices 64-127)
8570c6e2781SAnatoly Burakov 	 *   3. Ensure that we can still find free space in mask 1 afterwards
8580c6e2781SAnatoly Burakov 	 */
8590c6e2781SAnatoly Burakov 
8600c6e2781SAnatoly Burakov 	/* break run on mask 2 */
8610c6e2781SAnatoly Burakov 	rte_fbarray_set_used(&param.arr, 130);
8620c6e2781SAnatoly Burakov 	/* break run on mask 1 */
8630c6e2781SAnatoly Burakov 	rte_fbarray_set_used(&param.arr, 70);
8640c6e2781SAnatoly Burakov 
8650c6e2781SAnatoly Burakov 	/* start from 190, we expect to find free space at 8 */
8660c6e2781SAnatoly Burakov 	TEST_ASSERT_EQUAL(rte_fbarray_find_prev_n_free(&param.arr, 190, 62),
8670c6e2781SAnatoly Burakov 			8, "Free chunk index is wrong\n");
8680c6e2781SAnatoly Burakov 	return TEST_SUCCESS;
8690c6e2781SAnatoly Burakov }
8700c6e2781SAnatoly Burakov 
871a9de470cSBruce Richardson static struct unit_test_suite fbarray_test_suite = {
872a9de470cSBruce Richardson 	.suite_name = "fbarray autotest",
873a9de470cSBruce Richardson 	.setup = autotest_setup,
874a9de470cSBruce Richardson 	.teardown = autotest_teardown,
875a9de470cSBruce Richardson 	.unit_test_cases = {
876a9de470cSBruce Richardson 		TEST_CASE(test_invalid),
877a9de470cSBruce Richardson 		TEST_CASE(test_basic),
878*a744665dSAnatoly Burakov 		TEST_CASE_ST(first_msk_test_setup, reset_aligned, test_find),
879*a744665dSAnatoly Burakov 		TEST_CASE_ST(cross_msk_test_setup, reset_aligned, test_find),
880*a744665dSAnatoly Burakov 		TEST_CASE_ST(multi_msk_test_setup, reset_aligned, test_find),
881*a744665dSAnatoly Burakov 		TEST_CASE_ST(last_msk_test_setup, reset_aligned, test_find),
882*a744665dSAnatoly Burakov 		TEST_CASE_ST(full_msk_test_setup, reset_aligned, test_find),
883*a744665dSAnatoly Burakov 		/* empty test does not need setup */
884*a744665dSAnatoly Burakov 		TEST_CASE_ST(NULL, reset_aligned, test_empty),
885*a744665dSAnatoly Burakov 		TEST_CASE_ST(lookahead_test_setup, reset_aligned, test_lookahead),
886*a744665dSAnatoly Burakov 		TEST_CASE_ST(lookbehind_test_setup, reset_aligned, test_lookbehind),
887a344719cSAnatoly Burakov 		/* setup for these tests is more complex so do it in test func */
888*a744665dSAnatoly Burakov 		TEST_CASE_ST(NULL, reset_aligned, test_lookahead_mask),
889*a744665dSAnatoly Burakov 		TEST_CASE_ST(NULL, reset_aligned, test_lookbehind_mask),
890*a744665dSAnatoly Burakov 		TEST_CASE_ST(unaligned_test_setup, reset_unaligned, test_find_unaligned),
891a9de470cSBruce Richardson 		TEST_CASES_END()
892a9de470cSBruce Richardson 	}
893a9de470cSBruce Richardson };
894a9de470cSBruce Richardson 
895a9de470cSBruce Richardson static int
test_fbarray(void)896a9de470cSBruce Richardson test_fbarray(void)
897a9de470cSBruce Richardson {
898a9de470cSBruce Richardson 	return unit_test_suite_runner(&fbarray_test_suite);
899a9de470cSBruce Richardson }
900a9de470cSBruce Richardson 
901e0a8442cSBruce Richardson REGISTER_FAST_TEST(fbarray_autotest, true, true, test_fbarray);
902