1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2017 NXP 3 */ 4 5 #include "test.h" 6 7 #include <rte_common.h> 8 #include <rte_mbuf.h> 9 #include <rte_malloc.h> 10 #include <rte_memcpy.h> 11 #include <rte_dev.h> 12 13 #ifdef RTE_EXEC_ENV_WINDOWS 14 static int 15 test_rawdev_selftests(void) 16 { 17 printf("rawdev not supported on Windows, skipping test\n"); 18 return TEST_SKIPPED; 19 } 20 #else 21 22 #include <rte_rawdev.h> 23 #include <rte_bus_vdev.h> 24 25 static int 26 test_rawdev_selftest_impl(const char *pmd, const char *opts) 27 { 28 int ret; 29 30 printf("\n### Test rawdev infrastructure using skeleton driver\n"); 31 rte_vdev_init(pmd, opts); 32 ret = rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd)); 33 rte_vdev_uninit(pmd); 34 return ret; 35 } 36 37 static int 38 test_rawdev_selftest_skeleton(void) 39 { 40 return test_rawdev_selftest_impl("rawdev_skeleton", ""); 41 } 42 43 static int 44 test_rawdev_selftests(void) 45 { 46 const int count = rte_rawdev_count(); 47 int ret = 0; 48 int i; 49 50 /* basic sanity on rawdev infrastructure */ 51 if (test_rawdev_selftest_skeleton() < 0) 52 return -1; 53 54 /* now run self-test on all rawdevs */ 55 if (count > 0) 56 printf("\n### Run selftest on each available rawdev\n"); 57 for (i = 0; i < count; i++) { 58 int result = rte_rawdev_selftest(i); 59 printf("Rawdev %u (%s) selftest: %s\n", i, 60 rte_rawdevs[i].name, 61 result == 0 ? "Passed" : "Failed"); 62 ret |= result; 63 } 64 65 return ret; 66 } 67 68 #endif /* !RTE_EXEC_ENV_WINDOWS */ 69 70 REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftests); 71