test/mbuf: add unit test cases
[dpdk.git] / app / test / test_rawdev.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017 NXP
3  */
4 #include <rte_common.h>
5 #include <rte_mbuf.h>
6 #include <rte_malloc.h>
7 #include <rte_memcpy.h>
8 #include <rte_dev.h>
9 #include <rte_rawdev.h>
10 #include <rte_bus_vdev.h>
11
12 #include "test.h"
13
14 static int
15 test_rawdev_selftest_impl(const char *pmd, const char *opts)
16 {
17         rte_vdev_init(pmd, opts);
18         return rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd));
19 }
20
21 static int
22 test_rawdev_selftest_skeleton(void)
23 {
24         return test_rawdev_selftest_impl("rawdev_skeleton", "");
25 }
26
27 REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftest_skeleton);
28
29 static int
30 test_rawdev_selftest_ioat(void)
31 {
32         const int count = rte_rawdev_count();
33         int i;
34
35         for (i = 0; i < count; i++) {
36                 struct rte_rawdev_info info = { .dev_private = NULL };
37                 if (rte_rawdev_info_get(i, &info) == 0 &&
38                                 strstr(info.driver_name, "ioat") != NULL)
39                         return rte_rawdev_selftest(i) == 0 ?
40                                         TEST_SUCCESS : TEST_FAILED;
41         }
42
43         printf("No IOAT rawdev found, skipping tests\n");
44         return TEST_SKIPPED;
45 }
46
47 REGISTER_TEST_COMMAND(ioat_rawdev_autotest, test_rawdev_selftest_ioat);