Skeleton dmadevice test cases are part of driver layer. This patch allows test cases to be executed using 'dma_autotest' command in test framework.
Signed-off-by: Chengwen Feng <fengcheng...@huawei.com> --- app/test/meson.build | 3 +++ app/test/test_dmadev.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 app/test/test_dmadev.c diff --git a/app/test/meson.build b/app/test/meson.build index a761168..881cb4f 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -43,6 +43,7 @@ test_sources = files( 'test_debug.c', 'test_distributor.c', 'test_distributor_perf.c', + 'test_dmadev.c', 'test_eal_flags.c', 'test_eal_fs.c', 'test_efd.c', @@ -162,6 +163,7 @@ test_deps = [ 'cmdline', 'cryptodev', 'distributor', + 'dmadev', 'efd', 'ethdev', 'eventdev', @@ -333,6 +335,7 @@ driver_test_names = [ 'cryptodev_sw_mvsam_autotest', 'cryptodev_sw_snow3g_autotest', 'cryptodev_sw_zuc_autotest', + 'dmadev_autotest', 'eventdev_selftest_octeontx', 'eventdev_selftest_sw', 'rawdev_autotest', diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c new file mode 100644 index 0000000..90e8faa --- /dev/null +++ b/app/test/test_dmadev.c @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 HiSilicon Limited. + */ + +#include <rte_common.h> +#include <rte_dev.h> +#include <rte_dmadev.h> +#include <rte_bus_vdev.h> + +#include "test.h" + +static int +test_dmadev_selftest_skeleton(void) +{ + const char *pmd = "dma_skeleton"; + int ret; + + printf("\n### Test dmadev infrastructure using skeleton driver\n"); + rte_vdev_init(pmd, NULL); + ret = rte_dmadev_selftest(rte_dmadev_get_dev_id(pmd)); + rte_vdev_uninit(pmd); + + return ret; +} + +static int +test_dmadev_selftests(void) +{ + const int count = rte_dmadev_count(); + int ret = 0; + int i; + + /* basic sanity on dmadev infrastructure */ + if (test_dmadev_selftest_skeleton() < 0) + return -1; + + /* now run self-test on all dmadevs */ + if (count > 0) + printf("\n### Run selftest on each available dmadev\n"); + for (i = 0; i < RTE_DMADEV_MAX_DEVS; i++) { + if (rte_dmadevices[i].state != RTE_DMADEV_ATTACHED) + continue; + int result = rte_dmadev_selftest(i); + printf("dmadev %u (%s) selftest: %s\n", i, + rte_dmadevices[i].data->dev_name, + result == 0 ? "Passed" : "Failed"); + ret |= result; + } + + return ret; +} + +REGISTER_TEST_COMMAND(dmadev_autotest, test_dmadev_selftests); -- 2.8.1