On 2014-12-12 17:33, Stuart Haslam wrote:
> This is primarily sunny day basic functional testing, all tests are
> single threaded.
>
> On platforms other than linux-generic testing will be performend using
> the "loop" interface by default.
>
> For linux-generic, since we don't have a working "loop" device, a
> wrapper script is run that attempts to create a pair of virtual
> Ethernet interfaces for testing. If creating the interfaces fails
> the test is skipped and "make check" reports it as such.
>
> Signed-off-by: Stuart Haslam <[email protected]>
> ---
> Updates in v2:
>
> - now based on the updated packet and buffer pool APIs, so depends on;
>
> http://lists.linaro.org/pipermail/lng-odp/2014-December/006336.html
> http://lists.linaro.org/pipermail/lng-odp/2014-December/006337.html
>
> - removed USE_MACADDR_HACK as the API is now available
>
> - more graceful handling for some types of failure
>
> Notes:
>
> There are a couple of test failures against current linux-generic.
>
> - Packets get lost, apply this to resolve;
>
> http://lists.linaro.org/pipermail/lng-odp/2014-December/006383.html
>
> - the test for odp_pktio_inq_remdef() is failing, but that's genuinely
> broken, fix pending.
>
> test/validation/.gitignore | 1 +
> test/validation/Makefile.am | 9 +-
> test/validation/odp_pktio.c | 489
> ++++++++++++++++++++++++++++++++++++++++++
> test/validation/odp_pktio_run | 126 +++++++++++
> 4 files changed, 623 insertions(+), 2 deletions(-)
> create mode 100644 test/validation/odp_pktio.c
> create mode 100755 test/validation/odp_pktio_run
>
> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
> index 32834ae..c727223 100644
> --- a/test/validation/.gitignore
> +++ b/test/validation/.gitignore
> @@ -5,3 +5,4 @@ odp_queue
> odp_crypto
> odp_schedule
> odp_shm
> +odp_pktio
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index d0b5426..71f89c7 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -2,11 +2,14 @@ include $(top_srcdir)/test/Makefile.inc
>
> AM_CFLAGS += -I$(srcdir)/common
> AM_LDFLAGS += -static
> +AM_CFLAGS += -I$(CUNIT_PATH)/include
> +AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit
These two lines are not needed.
> +AM_TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform}
>
> if ODP_CUNIT_ENABLED
> -TESTS = ${bin_PROGRAMS}
> +TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run
> check_PROGRAMS = ${bin_PROGRAMS}
> -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule
> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio
> odp_init_LDFLAGS = $(AM_LDFLAGS)
> odp_queue_LDFLAGS = $(AM_LDFLAGS)
> odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
> @@ -15,6 +18,7 @@ odp_shm_CFLAGS = $(AM_CFLAGS)
> odp_shm_LDFLAGS = $(AM_LDFLAGS)
> odp_schedule_CFLAGS = $(AM_CFLAGS)
> odp_schedule_LDFLAGS = $(AM_LDFLAGS)
> +odp_pktio_LDFLAGS = $(AM_LDFLAGS)
> endif
>
> dist_odp_init_SOURCES = odp_init.c
> @@ -25,6 +29,7 @@ dist_odp_crypto_SOURCES =
> crypto/odp_crypto_test_async_inp.c \
> odp_crypto.c common/odp_cunit_common.c
> dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
> dist_odp_schedule_SOURCES = odp_schedule.c common/odp_cunit_common.c
> +dist_odp_pktio_SOURCES = odp_pktio.c common/odp_cunit_common.c
>
> #For Linux generic the unimplemented crypto API functions break the
> #regression TODO: https://bugs.linaro.org/show_bug.cgi?id=975
> diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
> new file mode 100644
> index 0000000..0ba9938
> --- /dev/null
> +++ b/test/validation/odp_pktio.c
> @@ -0,0 +1,489 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier: BSD-3-Clause
> + */
[...]
> +
> +static void pktio_test_txrx(odp_queue_type_t q_type, int num_pkts)
> +{
> + int ret, i, if_b;
> + pktio_info_t pktios[MAX_NUM_IFACES];
> + pktio_info_t *io;
> +
> + /* create pktios and associate input/output queues */
> + for (i = 0; i < num_ifaces; ++i) {
> + io = &pktios[i];
> +
> + io->name = iface_name[i];
> + io->id = create_pktio(iface_name[i]);
> + if (io->id == ODP_PKTIO_INVALID) {
> + CU_FAIL("failed to open iface");
> + return;
> + }
> + create_inq(io->id);
> + io->outq = odp_pktio_outq_getdef(io->id);
> + if (q_type == ODP_QUEUE_TYPE_POLL)
> + io->inq = odp_pktio_inq_getdef(io->id);
> + else
> + io->inq = ODP_QUEUE_INVALID;
> + }
> +
> + /* if we have two interfaces then send through one and receive on
> + * another but if there's only one assume it's a loopback */
> + if_b = (num_ifaces == 1) ? 0 : 1;
> + pktio_txrx_multi(&pktios[0], &pktios[if_b], num_pkts);
> +
> + for (i = 0; i < num_ifaces; ++i) {
> + ret = odp_pktio_close(pktios[i].id);
> + CU_ASSERT(ret == 0);
> + }
> +}
> +
> +static void test_odp_pktio_poll_queue(void)
> +{
> + pktio_test_txrx(ODP_QUEUE_TYPE_POLL, 1);
> +}
> +
> +static void test_odp_pktio_poll_multi(void)
> +{
> + pktio_test_txrx(ODP_QUEUE_TYPE_POLL, 4);
> +}
Maybe we should use QUEUE_MULTI_MAX instead of 4?
> +
> +static void test_odp_pktio_sched_queue(void)
> +{
> + pktio_test_txrx(ODP_QUEUE_TYPE_SCHED, 1);
> +}
> +
> +static void test_odp_pktio_sched_multi(void)
> +{
> + pktio_test_txrx(ODP_QUEUE_TYPE_SCHED, 4);
> +}
> +
> +static void test_odp_pktio_open(void)
> +{
> + odp_pktio_t pktio[2];
> + int i;
> +
> + for (i = 0; i < 2; ++i) {
Maybe add a comment here that you want to test the sequence of open and
close...
> + pktio[i] = create_pktio(iface_name[0]);
> + CU_ASSERT(pktio[i] != ODP_PKTIO_INVALID);
> +
> + CU_ASSERT(odp_pktio_close(pktio[i]) == 0);
> + }
> +
> + pktio[0] = odp_pktio_open("nothere", default_pkt_pool);
> + CU_ASSERT(pktio[0] == ODP_PKTIO_INVALID);
> +}
> +
> +static void test_odp_pktio_inq(void)
> +{
> + int res;
> + odp_pktio_t pktio;
> +
> + pktio = create_pktio(iface_name[0]);
> + CU_ASSERT(pktio != ODP_PKTIO_INVALID);
> +
> + CU_ASSERT(create_inq(pktio) == 0);
> +
> + res = odp_pktio_inq_remdef(pktio);
> + CU_ASSERT(res == 0);
> +
> + CU_ASSERT(odp_pktio_close(pktio) == 0);
> +}
> +
> +static void test_odp_pktio_outq(void)
> +{
> + odp_queue_t testq;
> +
> + testq = odp_pktio_outq_getdef(ODP_PKTIO_INVALID);
> + CU_ASSERT(testq == ODP_QUEUE_INVALID);
> +}
> +
> +static void test_odp_pktio_close(void)
> +{
> + int res;
> +
> + res = odp_pktio_close(ODP_PKTIO_INVALID);
> + CU_ASSERT_EQUAL(res, -1);
> +}
> +
> +static int init_pktio_suite(void)
> +{
> + iface_name[0] = getenv("ODP_PKTIO_IF0");
> + iface_name[1] = getenv("ODP_PKTIO_IF1");
> + num_ifaces = 1;
> +
> + if (!iface_name[0]) {
> + printf("No interfaces specified, using default \"loop\".\n");
> + iface_name[0] = "loop";
> + } else if (!iface_name[1]) {
> + printf("Using loopback interface: %s\n", iface_name[0]);
> + } else {
> + num_ifaces = 2;
> + printf("Using paired interfaces: %s %s\n",
> + iface_name[0], iface_name[1]);
> + }
> +
> + if (default_pool_create() != 0) {
> + fprintf(stderr, "error: failed to create default pool\n");
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +CU_TestInfo pktio_tests[] = {
> + {"pktio open", test_odp_pktio_open},
> + {"pktio close", test_odp_pktio_close},
> + {"pktio inq", test_odp_pktio_inq},
> + {"pktio outq", test_odp_pktio_outq},
> + {"pktio poll queues", test_odp_pktio_poll_queue},
> + {"pktio poll multi", test_odp_pktio_poll_multi},
> + {"pktio sched queues", test_odp_pktio_sched_queue},
> + {"pktio sched multi", test_odp_pktio_sched_multi},
> + CU_TEST_INFO_NULL
> +};
> +
> +CU_SuiteInfo odp_testsuites[] = {
> + {"odp_pktio", init_pktio_suite, NULL, NULL, NULL, pktio_tests},
Think we need a matching destroy_pktio_suite
Cheers,
Anders
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp