diff options
author | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-09-08 16:23:35 +0100 |
---|---|---|
committer | Zoltan Kiss <zoltan.kiss@linaro.org> | 2015-09-08 16:24:15 +0100 |
commit | 6d5e99291a6e62bae7dc8154077ec7bbe98ad4fb (patch) | |
tree | 08e1a7f3ec4ae943a2ccd6cfb3d89b094e6bcf4b /test | |
parent | 48c8a71416f0112a4c075e948efa3092b9fe4dcd (diff) | |
parent | 45259bf4d4b0390d8baad03e942c0f49206643e6 (diff) |
Merge odp.git's master to update to 1.3.0.0
Diffstat (limited to 'test')
50 files changed, 878 insertions, 206 deletions
diff --git a/test/README b/test/README index 64bf03b0c..857c36627 100644 --- a/test/README +++ b/test/README @@ -6,8 +6,7 @@ SPDX-License-Identifier: BSD-3-Clause Files in test/validation directory are intended to be terse checks that help ensure that the ODP API Implementations all perform identically and to specification. Tests inside the validation directory shall be platform -independent. However, they may need platform dependent environment -configuration. +independent. To run valgrind on the executables do: $ ./bootstrap @@ -15,8 +14,3 @@ $ ./configure --enable-test-vald --enable-valgrind $ cd test/validation $ make check-valgrind -Some tests scripts, like pktio require ODP_PLATFORM variable to be exported to load -platform specific env files. 'make check' defines that variable automatically, -and package will put all required files at the same place as tests binaries. But if -you run tests manually from odp source code then you need it to be defined, like: -export ODP_PLATFROM=linux-generic. diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am index ae2973e8d..721615bc5 100644 --- a/test/performance/Makefile.am +++ b/test/performance/Makefile.am @@ -27,3 +27,5 @@ noinst_HEADERS = \ dist_odp_atomic_SOURCES = odp_atomic.c dist_odp_scheduling_SOURCES = odp_scheduling.c dist_odp_pktio_perf_SOURCES = odp_pktio_perf.c + +EXTRA_DIST = $(TESTSCRIPTS) diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 157df3b17..64fc1b2aa 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -109,6 +109,8 @@ typedef struct { /** Global pointer to args */ static args_t *gbl_args; +/** Global barrier to synchronize main and workers */ +static odp_barrier_t barrier; /* helper funcs */ static inline odp_queue_t lookup_dest_q(odp_packet_t pkt); @@ -136,6 +138,7 @@ static void *pktio_queue_thread(void *arg) thr = odp_thread_id(); printf("[%02i] QUEUE mode\n", thr); + odp_barrier_wait(&barrier); /* Loop packets */ while (!exit_threads) { @@ -219,6 +222,7 @@ static void *pktio_ifburst_thread(void *arg) gbl_args->appl.if_names[src_idx], gbl_args->appl.if_names[dst_idx], odp_pktio_to_u64(pktio_src), odp_pktio_to_u64(pktio_dst)); + odp_barrier_wait(&barrier); /* Loop packets */ while (!exit_threads) { @@ -271,8 +275,16 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, odp_queue_t inq_def; odp_pktio_t pktio; int ret; + odp_pktio_param_t pktio_param; - pktio = odp_pktio_open(dev, pool); + memset(&pktio_param, 0, sizeof(pktio_param)); + + if (mode == APPL_MODE_PKT_BURST) + pktio_param.in_mode = ODP_PKTIN_MODE_RECV; + else + pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; + + pktio = odp_pktio_open(dev, pool, &pktio_param); if (pktio == ODP_PKTIO_INVALID) { LOG_ERR("Error: failed to open %s\n", dev); return ODP_PKTIO_INVALID; @@ -285,9 +297,10 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, if (mode == APPL_MODE_PKT_BURST) return pktio; + odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; - qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; + qparam.sched.group = ODP_SCHED_GROUP_ALL; snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def", odp_pktio_to_u64(pktio)); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; @@ -316,13 +329,16 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, * @param timeout Number of seconds for stats calculation * */ -static void print_speed_stats(int num_workers, stats_t **thr_stats, +static int print_speed_stats(int num_workers, stats_t **thr_stats, int duration, int timeout) { uint64_t pkts, pkts_prev = 0, pps, drops, maximum_pps = 0; int i, elapsed = 0; int loop_forever = (duration == 0); + /* Wait for all threads to be ready*/ + odp_barrier_wait(&barrier); + do { pkts = 0; drops = 0; @@ -347,7 +363,8 @@ static void print_speed_stats(int num_workers, stats_t **thr_stats, printf("TEST RESULT: %" PRIu64 " maximum packets per second.\n", maximum_pps); - return; + + return pkts > 100 ? 0 : -1; } /** @@ -364,6 +381,7 @@ int main(int argc, char *argv[]) odp_cpumask_t cpumask; char cpumaskstr[ODP_CPUMASK_STR_SIZE]; odp_pool_param_t params; + int ret; /* Init ODP before calling anything else */ if (odp_init_global(NULL, NULL)) { @@ -419,7 +437,7 @@ int main(int argc, char *argv[]) } /* Create packet pool */ - memset(¶ms, 0, sizeof(params)); + odp_pool_param_init(¶ms); params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; params.pkt.len = SHM_PKT_POOL_BUF_SIZE; params.pkt.num = SHM_PKT_POOL_SIZE/SHM_PKT_POOL_BUF_SIZE; @@ -438,6 +456,14 @@ int main(int argc, char *argv[]) pool, gbl_args->appl.mode); if (gbl_args->pktios[i] == ODP_PKTIO_INVALID) exit(EXIT_FAILURE); + + ret = odp_pktio_start(gbl_args->pktios[i]); + if (ret) { + LOG_ERR("Error: unable to start %s\n", + gbl_args->appl.if_names[i]); + exit(EXIT_FAILURE); + } + } gbl_args->pktios[i] = ODP_PKTIO_INVALID; @@ -445,6 +471,8 @@ int main(int argc, char *argv[]) stats_t **stats = calloc(1, sizeof(stats_t) * num_workers); + odp_barrier_init(&barrier, num_workers + 1); + /* Create worker threads */ cpu = odp_cpumask_first(&cpumask); for (i = 0; i < num_workers; ++i) { @@ -467,8 +495,8 @@ int main(int argc, char *argv[]) cpu = odp_cpumask_next(&cpumask, cpu); } - print_speed_stats(num_workers, stats, gbl_args->appl.time, - gbl_args->appl.accuracy); + ret = print_speed_stats(num_workers, stats, gbl_args->appl.time, + gbl_args->appl.accuracy); free(stats); exit_threads = 1; @@ -479,7 +507,7 @@ int main(int argc, char *argv[]) free(gbl_args->appl.if_str); printf("Exit\n\n"); - return 0; + return ret; } /** @@ -688,7 +716,6 @@ static void usage(char *progname) " -h, --help Display help and exit.\n\n" " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" - " ODP_PKTIO_DISABLE_SOCKET_BASIC\n" " can be used to advanced pkt I/O selection for linux-generic\n" "\n", NO_PATH(progname), NO_PATH(progname) ); diff --git a/test/performance/odp_l2fwd_run b/test/performance/odp_l2fwd_run index e89bec8a5..e0c61e7e6 100755 --- a/test/performance/odp_l2fwd_run +++ b/test/performance/odp_l2fwd_run @@ -59,9 +59,13 @@ run_l2fwd() (odp_generator${EXEEXT} -I $IF0 \ --srcip 192.168.0.1 --dstip 192.168.0.2 -m u 2>&1 > /dev/null) \ 2>&1 > /dev/null & + GEN_PID=$! echo "Run odp_l2fwd -i $IF1,$IF2 -m 0 -t 30 -c 2" odp_l2fwd${EXEEXT} -i $IF1,$IF2 -m 0 -t 30 -c 2 + ret=$? + + kill ${GEN_PID} cleanup_pktio_env if [ $? -ne 0 ]; then @@ -69,7 +73,7 @@ run_l2fwd() exit $TEST_SKIPPED fi - exit 0 + exit $ret } case "$1" in diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 08f13b628..709becfa3 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -123,6 +123,8 @@ typedef struct { odp_pktio_t pktio_rx; pkt_rx_stats_t rx_stats[ODP_CONFIG_MAX_THREADS]; pkt_tx_stats_t tx_stats[ODP_CONFIG_MAX_THREADS]; + uint8_t src_mac[ODPH_ETHADDR_LEN]; + uint8_t dst_mac[ODPH_ETHADDR_LEN]; } test_globals_t; /* Status of max rate search */ @@ -169,7 +171,6 @@ static odp_packet_t pktio_create_packet(void) uint32_t offset; pkt_head_t pkt_hdr; size_t payload_len; - uint8_t mac[ODPH_ETHADDR_LEN] = {0}; payload_len = sizeof(pkt_hdr) + gbl_args->args.pkt_len; @@ -186,8 +187,8 @@ static odp_packet_t pktio_create_packet(void) offset = 0; odp_packet_l2_offset_set(pkt, offset); eth = (odph_ethhdr_t *)buf; - memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN); - memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN); + memcpy(eth->src.addr, gbl_args->src_mac, ODPH_ETHADDR_LEN); + memcpy(eth->dst.addr, gbl_args->dst_mac, ODPH_ETHADDR_LEN); eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); /* IP */ @@ -441,7 +442,7 @@ static void *run_thread_rx(void *arg) else stats->s.rx_ignore++; } - odp_buffer_free(odp_buffer_from_event(ev[i])); + odp_event_free(ev[i]); } if (n_ev == 0 && odp_atomic_load_u32(&shutdown)) break; @@ -681,14 +682,15 @@ static int run_test(void) return ret; } -static odp_pktio_t create_pktio(const char *iface) +static odp_pktio_t create_pktio(const char *iface, int schedule) { odp_pool_t pool; odp_pktio_t pktio; char pool_name[ODP_POOL_NAME_LEN]; odp_pool_param_t params; + odp_pktio_param_t pktio_param; - memset(¶ms, 0, sizeof(params)); + odp_pool_param_init(¶ms); params.pkt.len = PKT_HDR_LEN + gbl_args->args.pkt_len; params.pkt.seg_len = params.pkt.len; params.pkt.num = PKT_BUF_NUM; @@ -699,7 +701,14 @@ static odp_pktio_t create_pktio(const char *iface) if (pool == ODP_POOL_INVALID) return ODP_PKTIO_INVALID; - pktio = odp_pktio_open(iface, pool); + memset(&pktio_param, 0, sizeof(pktio_param)); + + if (schedule) + pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; + else + pktio_param.in_mode = ODP_PKTIN_MODE_POLL; + + pktio = odp_pktio_open(iface, pool, &pktio_param); return pktio; } @@ -709,9 +718,11 @@ static int test_init(void) odp_pool_param_t params; odp_queue_param_t qparam; odp_queue_t inq_def; + const char *iface; + int schedule; char inq_name[ODP_QUEUE_NAME_LEN]; - memset(¶ms, 0, sizeof(params)); + odp_pool_param_init(¶ms); params.pkt.len = PKT_HDR_LEN + gbl_args->args.pkt_len; params.pkt.seg_len = params.pkt.len; params.pkt.num = PKT_BUF_NUM; @@ -724,12 +735,22 @@ static int test_init(void) odp_atomic_init_u32(&ip_seq, 0); odp_atomic_init_u32(&shutdown, 0); + iface = gbl_args->args.ifaces[0]; + schedule = gbl_args->args.schedule; + /* create pktios and associate input/output queues */ - gbl_args->pktio_tx = create_pktio(gbl_args->args.ifaces[0]); - if (gbl_args->args.num_ifaces > 1) - gbl_args->pktio_rx = create_pktio(gbl_args->args.ifaces[1]); - else + gbl_args->pktio_tx = create_pktio(iface, schedule); + if (gbl_args->args.num_ifaces > 1) { + iface = gbl_args->args.ifaces[1]; + gbl_args->pktio_rx = create_pktio(iface, schedule); + } else { gbl_args->pktio_rx = gbl_args->pktio_tx; + } + + odp_pktio_mac_addr(gbl_args->pktio_tx, gbl_args->src_mac, + ODPH_ETHADDR_LEN); + odp_pktio_mac_addr(gbl_args->pktio_rx, gbl_args->dst_mac, + ODPH_ETHADDR_LEN); if (gbl_args->pktio_rx == ODP_PKTIO_INVALID || gbl_args->pktio_tx == ODP_PKTIO_INVALID) { @@ -738,9 +759,10 @@ static int test_init(void) } /* create and associate an input queue for the RX side */ + odp_queue_param_init(&qparam); qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_NONE; - qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; + qparam.sched.group = ODP_SCHED_GROUP_ALL; snprintf(inq_name, sizeof(inq_name), "inq-pktio-%" PRIu64, odp_pktio_to_u64(gbl_args->pktio_rx)); @@ -755,6 +777,12 @@ static int test_init(void) if (odp_pktio_inq_setdef(gbl_args->pktio_rx, inq_def) != 0) return -1; + if (odp_pktio_start(gbl_args->pktio_tx) != 0) + return -1; + if (gbl_args->args.num_ifaces > 1 && + odp_pktio_start(gbl_args->pktio_rx)) + return -1; + return 0; } @@ -781,7 +809,7 @@ static int destroy_inq(odp_pktio_t pktio) ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); if (ev != ODP_EVENT_INVALID) - odp_buffer_free(odp_buffer_from_event(ev)); + odp_event_free(ev); else break; } diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 8d388ff55..2a7e531fa 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -69,7 +69,6 @@ typedef struct { static void clear_sched_queues(void) { odp_event_t ev; - odp_buffer_t buf; while (1) { ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); @@ -77,8 +76,7 @@ static void clear_sched_queues(void) if (ev == ODP_EVENT_INVALID) break; - buf = odp_buffer_from_event(ev); - odp_buffer_free(buf); + odp_event_free(ev); } } @@ -345,7 +343,7 @@ static int test_schedule_single(const char *str, int thr, odp_queue_t queue; uint64_t t1, t2, cycles, ns; uint32_t i; - uint32_t tot = 0; + uint32_t tot; if (create_queue(thr, msg_pool, prio)) return -1; @@ -421,11 +419,11 @@ static int test_schedule_many(const char *str, int thr, { odp_event_t ev; odp_queue_t queue; - uint64_t t1 = 0; - uint64_t t2 = 0; + uint64_t t1; + uint64_t t2; uint64_t cycles, ns; uint32_t i; - uint32_t tot = 0; + uint32_t tot; if (create_queues(thr, msg_pool, prio)) return -1; @@ -498,8 +496,8 @@ static int test_schedule_multi(const char *str, int thr, { odp_event_t ev[MULTI_BUFS_MAX]; odp_queue_t queue; - uint64_t t1 = 0; - uint64_t t2 = 0; + uint64_t t1; + uint64_t t2; uint64_t cycles, ns; int i, j; int num; @@ -919,6 +917,7 @@ int main(int argc, char *argv[]) * Create message pool */ + odp_pool_param_init(¶ms); params.buf.size = sizeof(test_message_t); params.buf.align = 0; params.buf.num = MSG_POOL_SIZE/sizeof(test_message_t); @@ -959,9 +958,10 @@ int main(int argc, char *argv[]) name[6] = '0' + i/10; name[7] = '0' + i - 10*(i/10); + odp_queue_param_init(¶m); param.sched.prio = i; param.sched.sync = ODP_SCHED_SYNC_ATOMIC; - param.sched.group = ODP_SCHED_GROUP_DEFAULT; + param.sched.group = ODP_SCHED_GROUP_ALL; for (j = 0; j < QUEUES_PER_PRIO; j++) { name[9] = '0' + j/10; diff --git a/test/validation/README b/test/validation/README new file mode 100644 index 000000000..2d0c258a1 --- /dev/null +++ b/test/validation/README @@ -0,0 +1,50 @@ +Copyright (c) 2015, Linaro Limited +All rights reserved. + +SPDX-License-Identifier: BSD-3-Clause + + +To add tests in here, please observe the following rules: + +1. Tests should be placed in the directory of the module they belong to. + + +2. Test under test/validation/... should be platform agnostic, i.e. + -they should be written in plain C only + -they may only used Clib functions, C_UNIT functions and of course ODP + functions. + -they should be expected to pass on all ODP implementation + + Tests that do not follow these rules should be placed in the platform + specific test area (currently platform/<platform>/test*) + + +3. If a new ODP API module is created, please update the Makefile.am and + the odptest.h file + + +4. Respect the following name convention for the names exported in the library: + + * Tests, i.e. functions which are used in CUNIT test suites are named: + *<Module>_test_* + + * Test arrays, i.e. arrays of CU_TestInfo, listing the test functions + belonging to a suite, are called: + <Module>_suite[_*] + where the possible suffix can be used if many suites are declared. + + * CUNIT suite init and termination functions are called: + <Module>_suite[_*]_init() and <Module>_suite[_*]_term() + respectively. + + * Suite arrays, i.e. arrays of CU_SuiteInfo used in executables are called: + <Module>_suites[_*] + where the possible suffix identifies the executable using it, if many. + + * Main executable function(s), are called: + <Module>_main[_*]* + where the possible suffix identifies the executable using it + + * Init/term function for the whole executable are called: + <Module>_init + <Module>_term diff --git a/test/validation/buffer/Makefile.am b/test/validation/buffer/Makefile.am index e1b1233cd..05da40bb9 100644 --- a/test/validation/buffer/Makefile.am +++ b/test/validation/buffer/Makefile.am @@ -6,3 +6,5 @@ libbuffer_la_SOURCES = buffer.c bin_PROGRAMS = buffer_main$(EXEEXT) dist_buffer_main_SOURCES = buffer_main.c buffer_main_LDADD = libbuffer.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = buffer.h diff --git a/test/validation/buffer/buffer.c b/test/validation/buffer/buffer.c index 52585b95a..c62938d0a 100644 --- a/test/validation/buffer/buffer.c +++ b/test/validation/buffer/buffer.c @@ -8,9 +8,6 @@ #include "odp_cunit_common.h" #include "buffer.h" -/* Helper macro for CU_TestInfo initialization */ -#define _CU_TEST_INFO(test_func) {#test_func, test_func} - static odp_pool_t raw_pool; static odp_buffer_t raw_buffer = ODP_BUFFER_INVALID; static const size_t raw_buffer_size = 1500; diff --git a/test/validation/classification/Makefile.am b/test/validation/classification/Makefile.am index ba468faf7..7ab1dd902 100644 --- a/test/validation/classification/Makefile.am +++ b/test/validation/classification/Makefile.am @@ -8,3 +8,5 @@ libclassification_la_SOURCES = odp_classification_basic.c \ bin_PROGRAMS = classification_main$(EXEEXT) dist_classification_main_SOURCES = classification_main.c classification_main_LDADD = libclassification.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = classification.h odp_classification_testsuites.h diff --git a/test/validation/classification/odp_classification_basic.c b/test/validation/classification/odp_classification_basic.c index 79c775e1c..3ae012879 100644 --- a/test/validation/classification/odp_classification_basic.c +++ b/test/validation/classification/odp_classification_basic.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include <odp_cunit_common.h> #include "odp_classification_testsuites.h" #include "classification.h" diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index 0e0c4eb6d..9e8ac1be3 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -178,7 +178,7 @@ static int destroy_inq(odp_pktio_t pktio) ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); if (ev != ODP_EVENT_INVALID) - odp_buffer_free(odp_buffer_from_event(ev)); + odp_event_free(ev); else break; } @@ -278,6 +278,7 @@ int classification_suite_init(void) char queuename[ODP_QUEUE_NAME_LEN]; int i; int ret; + odp_pktio_param_t pktio_param; memset(¶m, 0, sizeof(param)); param.pkt.seg_len = SHM_PKT_BUF_SIZE; @@ -295,7 +296,10 @@ int classification_suite_init(void) if (pool_default == ODP_POOL_INVALID) return -1; - pktio_loop = odp_pktio_open("loop", pool_default); + memset(&pktio_param, 0, sizeof(pktio_param)); + pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; + + pktio_loop = odp_pktio_open("loop", pool_default, &pktio_param); if (pktio_loop == ODP_PKTIO_INVALID) { ret = odp_pool_destroy(pool_default); if (ret) @@ -304,7 +308,7 @@ int classification_suite_init(void) } qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; - qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; + qparam.sched.group = ODP_SCHED_GROUP_ALL; sprintf(queuename, "%s", "inq_loop"); inq_def = odp_queue_create(queuename, @@ -321,6 +325,13 @@ int classification_suite_init(void) queue_list[i] = ODP_QUEUE_INVALID; odp_atomic_init_u32(&seq, 0); + + ret = odp_pktio_start(pktio_loop); + if (ret) { + fprintf(stderr, "unable to start loop\n"); + return -1; + } + return 0; } @@ -407,6 +418,7 @@ void configure_cls_pmr_chain(void) retval = odp_cos_set_queue(cos_list[CLS_PMR_CHAIN_DST], queue_list[CLS_PMR_CHAIN_DST]); + CU_ASSERT(retval == 0); parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask); pmr_list[CLS_PMR_CHAIN_SRC] = odp_pmr_create(ODP_PMR_SIP_ADDR, &addr, diff --git a/test/validation/classification/odp_classification_testsuites.h b/test/validation/classification/odp_classification_testsuites.h index f603f3004..37c019d65 100644 --- a/test/validation/classification/odp_classification_testsuites.h +++ b/test/validation/classification/odp_classification_testsuites.h @@ -11,9 +11,6 @@ #include <CUnit/CUnit.h> #include <CUnit/Basic.h> -/* Helper macro for CU_TestInfo initialization */ -#define _CU_TEST_INFO(test_func) {#test_func, test_func} - extern CU_TestInfo classification_suite[]; extern CU_TestInfo classification_suite_basic[]; diff --git a/test/validation/common/Makefile.am b/test/validation/common/Makefile.am index 2cb0956a1..fd41fb428 100644 --- a/test/validation/common/Makefile.am +++ b/test/validation/common/Makefile.am @@ -9,3 +9,5 @@ libcpumask_common_la_SOURCES = mask_common.c libthrmask_common_la_SOURCES = mask_common.c libthrmask_common_la_CFLAGS = $(AM_CFLAGS) -DTEST_THRMASK + +EXTRA_DIST = mask_common.h odp_cunit_common.h diff --git a/test/validation/common/mask_common.c b/test/validation/common/mask_common.c index fce7725bb..9b1a23f46 100644 --- a/test/validation/common/mask_common.c +++ b/test/validation/common/mask_common.c @@ -145,6 +145,7 @@ MASK_TESTFUNC(to_from_str) str_sz = _odp_mask_to_str(&mask, buf_out, stringlen(TEST_MASK_0) + 1); + CU_ASSERT(str_sz == (int32_t)stringlen(TEST_MASK_0) + 1); CU_ASSERT_NSTRING_EQUAL(buf_out, TEST_MASK_0, stringlen(TEST_MASK_0) + 1); diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h index 7c2a9dd89..6cafaaaa7 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -21,6 +21,9 @@ /* the function, called by module main(), to run the testsuites: */ int odp_cunit_run(CU_SuiteInfo testsuites[]); +/* the macro used to have test names (strings) matching function symbols */ +#define _CU_TEST_INFO(test_func) {#test_func, test_func} + typedef struct { uint32_t foo; uint32_t bar; diff --git a/test/validation/cpumask/Makefile.am b/test/validation/cpumask/Makefile.am index 795d9ffc8..5a05c7ab9 100644 --- a/test/validation/cpumask/Makefile.am +++ b/test/validation/cpumask/Makefile.am @@ -7,3 +7,5 @@ libcpumask_la_LIBADD = $(LIBCPUMASK_COMMON) bin_PROGRAMS = cpumask_main$(EXEEXT) dist_cpumask_main_SOURCES = cpumask_main.c cpumask_main_LDADD = libcpumask.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = cpumask.h diff --git a/test/validation/cpumask/cpumask.c b/test/validation/cpumask/cpumask.c index 029baadf6..6d57028e3 100644 --- a/test/validation/cpumask/cpumask.c +++ b/test/validation/cpumask/cpumask.c @@ -73,24 +73,24 @@ void cpumask_test_odp_cpumask_def(void) } CU_TestInfo cpumask_suite[] = { - {"odp_cpumask_to/from_str()", cpumask_test_odp_cpumask_to_from_str}, - {"odp_cpumask_equal()", cpumask_test_odp_cpumask_equal}, - {"odp_cpumask_zero()", cpumask_test_odp_cpumask_zero}, - {"odp_cpumask_set()", cpumask_test_odp_cpumask_set}, - {"odp_cpumask_clr()", cpumask_test_odp_cpumask_clr}, - {"odp_cpumask_isset()", cpumask_test_odp_cpumask_isset}, - {"odp_cpumask_count()", cpumask_test_odp_cpumask_count}, - {"odp_cpumask_and()", cpumask_test_odp_cpumask_and}, - {"odp_cpumask_or()", cpumask_test_odp_cpumask_or}, - {"odp_cpumask_xor()", cpumask_test_odp_cpumask_xor}, - {"odp_cpumask_copy()", cpumask_test_odp_cpumask_copy}, - {"odp_cpumask_first()", cpumask_test_odp_cpumask_first}, - {"odp_cpumask_last()", cpumask_test_odp_cpumask_last}, - {"odp_cpumask_next()", cpumask_test_odp_cpumask_next}, - {"odp_cpumask_setall()", cpumask_test_odp_cpumask_setall}, - {"odp_cpumask_def_control()", cpumask_test_odp_cpumask_def_control}, - {"odp_cpumask_def_worker()", cpumask_test_odp_cpumask_def_worker}, - {"odp_cpumask_def()", cpumask_test_odp_cpumask_def}, + _CU_TEST_INFO(cpumask_test_odp_cpumask_to_from_str), + _CU_TEST_INFO(cpumask_test_odp_cpumask_equal), + _CU_TEST_INFO(cpumask_test_odp_cpumask_zero), + _CU_TEST_INFO(cpumask_test_odp_cpumask_set), + _CU_TEST_INFO(cpumask_test_odp_cpumask_clr), + _CU_TEST_INFO(cpumask_test_odp_cpumask_isset), + _CU_TEST_INFO(cpumask_test_odp_cpumask_count), + _CU_TEST_INFO(cpumask_test_odp_cpumask_and), + _CU_TEST_INFO(cpumask_test_odp_cpumask_or), + _CU_TEST_INFO(cpumask_test_odp_cpumask_xor), + _CU_TEST_INFO(cpumask_test_odp_cpumask_copy), + _CU_TEST_INFO(cpumask_test_odp_cpumask_first), + _CU_TEST_INFO(cpumask_test_odp_cpumask_last), + _CU_TEST_INFO(cpumask_test_odp_cpumask_next), + _CU_TEST_INFO(cpumask_test_odp_cpumask_setall), + _CU_TEST_INFO(cpumask_test_odp_cpumask_def_control), + _CU_TEST_INFO(cpumask_test_odp_cpumask_def_worker), + _CU_TEST_INFO(cpumask_test_odp_cpumask_def), CU_TEST_INFO_NULL, }; diff --git a/test/validation/crypto/Makefile.am b/test/validation/crypto/Makefile.am index 6c7a94ba1..ee04d3444 100644 --- a/test/validation/crypto/Makefile.am +++ b/test/validation/crypto/Makefile.am @@ -7,3 +7,5 @@ libcrypto_la_SOURCES = crypto.c \ bin_PROGRAMS = crypto_main$(EXEEXT) dist_crypto_main_SOURCES = crypto_main.c crypto_main_LDADD = libcrypto.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = crypto.h odp_crypto_test_inp.h test_vectors.h test_vectors_len.h diff --git a/test/validation/crypto/odp_crypto_test_inp.c b/test/validation/crypto/odp_crypto_test_inp.c index 90fe8d039..187a04c28 100644 --- a/test/validation/crypto/odp_crypto_test_inp.c +++ b/test/validation/crypto/odp_crypto_test_inp.c @@ -6,6 +6,7 @@ #include <odp.h> #include <CUnit/Basic.h> +#include <odp_cunit_common.h> #include "test_vectors.h" #include "odp_crypto_test_inp.h" #include "crypto.h" @@ -132,7 +133,6 @@ cleanup: * operation for 3DES_CBC algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -#define ASYNC_INP_ENC_ALG_3DES_CBC "ENC_ALG_3DES_CBC" void crypto_test_enc_alg_3des_cbc(void) { odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, @@ -165,7 +165,6 @@ void crypto_test_enc_alg_3des_cbc(void) /* This test verifies the correctness of encode (plaintext -> ciphertext) * operation for 3DES_CBC algorithm. IV for the operation is the operation IV. * */ -#define ASYNC_INP_ENC_ALG_3DES_CBC_OVR_IV "ENC_ALG_3DES_CBC_OVR_IV" void crypto_test_enc_alg_3des_cbc_ovr_iv(void) { odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, @@ -199,7 +198,6 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -#define ASYNC_INP_DEC_ALG_3DES_CBC "DEC_ALG_3DES_CBC" void crypto_test_dec_alg_3des_cbc(void) { odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, @@ -234,7 +232,6 @@ void crypto_test_dec_alg_3des_cbc(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -#define ASYNC_INP_DEC_ALG_3DES_CBC_OVR_IV "DEC_ALG_3DES_CBC_OVR_IV" void crypto_test_dec_alg_3des_cbc_ovr_iv(void) { odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, @@ -270,7 +267,6 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -#define ASYNC_INP_ALG_HMAC_MD5 "ALG_HMAC_MD5" void crypto_test_alg_hmac_md5(void) { odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, @@ -324,12 +320,10 @@ int crypto_suite_async_init(void) } CU_TestInfo crypto_suite[] = { - {ASYNC_INP_ENC_ALG_3DES_CBC, crypto_test_enc_alg_3des_cbc }, - {ASYNC_INP_DEC_ALG_3DES_CBC, crypto_test_dec_alg_3des_cbc }, - {ASYNC_INP_ENC_ALG_3DES_CBC_OVR_IV, - crypto_test_enc_alg_3des_cbc_ovr_iv }, - {ASYNC_INP_DEC_ALG_3DES_CBC_OVR_IV, - crypto_test_dec_alg_3des_cbc_ovr_iv }, - {ASYNC_INP_ALG_HMAC_MD5, crypto_test_alg_hmac_md5 }, + _CU_TEST_INFO(crypto_test_enc_alg_3des_cbc), + _CU_TEST_INFO(crypto_test_dec_alg_3des_cbc), + _CU_TEST_INFO(crypto_test_enc_alg_3des_cbc_ovr_iv), + _CU_TEST_INFO(crypto_test_dec_alg_3des_cbc_ovr_iv), + _CU_TEST_INFO(crypto_test_alg_hmac_md5), CU_TEST_INFO_NULL, }; diff --git a/test/validation/errno/Makefile.am b/test/validation/errno/Makefile.am index ab3ef8878..44575d971 100644 --- a/test/validation/errno/Makefile.am +++ b/test/validation/errno/Makefile.am @@ -6,3 +6,5 @@ liberrno_la_SOURCES = errno.c bin_PROGRAMS = errno_main$(EXEEXT) dist_errno_main_SOURCES = errno_main.c errno_main_LDADD = liberrno.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = errno.h diff --git a/test/validation/errno/errno.c b/test/validation/errno/errno.c index 9b6b125aa..c4f4aabee 100644 --- a/test/validation/errno/errno.c +++ b/test/validation/errno/errno.c @@ -20,7 +20,7 @@ void errno_test_odp_errno_sunny_day(void) } CU_TestInfo errno_suite[] = { - {"sunny day", errno_test_odp_errno_sunny_day}, + _CU_TEST_INFO(errno_test_odp_errno_sunny_day), CU_TEST_INFO_NULL, }; diff --git a/test/validation/init/Makefile.am b/test/validation/init/Makefile.am index a54e29aea..51cb4adb2 100644 --- a/test/validation/init/Makefile.am +++ b/test/validation/init/Makefile.am @@ -12,3 +12,5 @@ dist_init_main_ok_SOURCES = init_main_ok.c init_main_abort_LDADD = libinit.la $(LIBCUNIT_COMMON) $(LIBODP) init_main_log_LDADD = libinit.la $(LIBCUNIT_COMMON) $(LIBODP) init_main_ok_LDADD = libinit.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = init.h diff --git a/test/validation/init/init.c b/test/validation/init/init.c index 12aa554b8..ee4483cb7 100644 --- a/test/validation/init/init.c +++ b/test/validation/init/init.c @@ -38,7 +38,7 @@ void init_test_odp_init_global_replace_abort(void) } CU_TestInfo init_suite_abort[] = { - {"replace abort", init_test_odp_init_global_replace_abort}, + _CU_TEST_INFO(init_test_odp_init_global_replace_abort), CU_TEST_INFO_NULL, }; @@ -83,7 +83,7 @@ void init_test_odp_init_global_replace_log(void) } CU_TestInfo init_suite_log[] = { - {"replace log", init_test_odp_init_global_replace_log}, + _CU_TEST_INFO(init_test_odp_init_global_replace_log), CU_TEST_INFO_NULL, }; @@ -131,7 +131,7 @@ void init_test_odp_init_global(void) } CU_TestInfo init_suite_ok[] = { - {"test_odp_init_global", init_test_odp_init_global}, + _CU_TEST_INFO(init_test_odp_init_global), CU_TEST_INFO_NULL, }; diff --git a/test/validation/packet/Makefile.am b/test/validation/packet/Makefile.am index 7ba7a477b..9c783d5b7 100644 --- a/test/validation/packet/Makefile.am +++ b/test/validation/packet/Makefile.am @@ -6,3 +6,5 @@ libpacket_la_SOURCES = packet.c bin_PROGRAMS = packet_main$(EXEEXT) dist_packet_main_SOURCES = packet_main.c packet_main_LDADD = libpacket.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = packet.h diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c index 99a67458d..97ffd14fe 100644 --- a/test/validation/packet/packet.c +++ b/test/validation/packet/packet.c @@ -10,9 +10,6 @@ #include "odp_cunit_common.h" #include "packet.h" -/* Helper macro for CU_TestInfo initialization */ -#define _CU_TEST_INFO(test_func) {#test_func, test_func} - #define PACKET_BUF_LEN ODP_CONFIG_PACKET_SEG_LEN_MIN /* Reserve some tailroom for tests */ #define PACKET_TAILROOM_RESERVE 4 diff --git a/test/validation/pktio/Makefile.am b/test/validation/pktio/Makefile.am index 86127a18e..37efeaae8 100644 --- a/test/validation/pktio/Makefile.am +++ b/test/validation/pktio/Makefile.am @@ -6,3 +6,5 @@ libpktio_la_SOURCES = pktio.c bin_PROGRAMS = pktio_main$(EXEEXT) dist_pktio_main_SOURCES = pktio_main.c pktio_main_LDADD = libpktio.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = pktio.h diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 5eb7a56bd..5c0799bdf 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -47,6 +47,12 @@ typedef struct ODP_PACKED { uint32be_t magic; } pkt_tail_t; +/** Run mode */ +typedef enum { + PKT_POOL_UNSEGMENTED, + PKT_POOL_SEGMENTED, +} pkt_segmented_e +; /** size of transmitted packets */ static uint32_t packet_len = PKT_LEN_NORMAL; @@ -56,8 +62,27 @@ odp_pool_t default_pkt_pool = ODP_POOL_INVALID; /** sequence number of IP packets */ odp_atomic_u32_t ip_seq; +/** Type of pool segmentation */ +pkt_segmented_e pool_segmentation = PKT_POOL_UNSEGMENTED; + odp_pool_t pool[MAX_NUM_IFACES] = {ODP_POOL_INVALID, ODP_POOL_INVALID}; +static void set_pool_len(odp_pool_param_t *params) +{ + switch (pool_segmentation) { + case PKT_POOL_SEGMENTED: + /* Force segment to minimum size */ + params->pkt.seg_len = 0; + params->pkt.len = PKT_BUF_SIZE; + break; + case PKT_POOL_UNSEGMENTED: + default: + params->pkt.seg_len = PKT_BUF_SIZE; + params->pkt.len = PKT_BUF_SIZE; + break; + } +} + static void pktio_pkt_set_macs(odp_packet_t pkt, pktio_info_t *src, pktio_info_t *dst) { @@ -109,6 +134,9 @@ static uint32_t pktio_pkt_seq(odp_packet_t pkt) pkt_head_t head; pkt_tail_t tail; + if (pkt == ODP_PACKET_INVALID) + return -1; + off = odp_packet_l4_offset(pkt); if (off == ODP_PACKET_OFFSET_INVALID) return TEST_SEQ_INVALID; @@ -203,28 +231,39 @@ static int pktio_fixup_checksums(odp_packet_t pkt) static int default_pool_create(void) { odp_pool_param_t params; + char pool_name[ODP_POOL_NAME_LEN]; if (default_pkt_pool != ODP_POOL_INVALID) return -1; memset(¶ms, 0, sizeof(params)); - params.pkt.seg_len = PKT_BUF_SIZE; - params.pkt.len = PKT_BUF_SIZE; + set_pool_len(¶ms); params.pkt.num = PKT_BUF_NUM; params.type = ODP_POOL_PACKET; - default_pkt_pool = odp_pool_create("pkt_pool_default", ¶ms); + snprintf(pool_name, sizeof(pool_name), + "pkt_pool_default_%d", pool_segmentation); + default_pkt_pool = odp_pool_create(pool_name, ¶ms); if (default_pkt_pool == ODP_POOL_INVALID) return -1; return 0; } -static odp_pktio_t create_pktio(const char *iface, int num) +static odp_pktio_t create_pktio(const char *iface, odp_queue_type_t q_type, + int num) { odp_pktio_t pktio; + odp_pktio_param_t pktio_param; + + memset(&pktio_param, 0, sizeof(pktio_param)); + + if (q_type == ODP_QUEUE_TYPE_POLL) + pktio_param.in_mode = ODP_PKTIN_MODE_POLL; + else + pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; - pktio = odp_pktio_open(iface, pool[num]); + pktio = odp_pktio_open(iface, pool[num], &pktio_param); if (pktio == ODP_PKTIO_INVALID) pktio = odp_pktio_lookup(iface); CU_ASSERT(pktio != ODP_PKTIO_INVALID); @@ -242,7 +281,7 @@ static int create_inq(odp_pktio_t pktio, odp_queue_type_t qtype) qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; - qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; + qparam.sched.group = ODP_SCHED_GROUP_ALL; snprintf(inq_name, sizeof(inq_name), "inq-pktio-%" PRIu64, odp_pktio_to_u64(pktio)); @@ -283,7 +322,7 @@ static int destroy_inq(odp_pktio_t pktio) ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT); if (ev != ODP_EVENT_INVALID) - odp_buffer_free(odp_buffer_from_event(ev)); + odp_event_free(ev); else break; } @@ -315,15 +354,17 @@ static odp_packet_t wait_for_packet(odp_queue_t queue, uint64_t start, now, diff; odp_event_t ev; odp_packet_t pkt = ODP_PACKET_INVALID; + uint64_t wait; start = odp_time_cycles(); + wait = odp_schedule_wait_time(ns); do { if (queue != ODP_QUEUE_INVALID && odp_queue_type(queue) == ODP_QUEUE_TYPE_POLL) ev = queue_deq_wait_time(queue, ns); else - ev = odp_schedule(NULL, ns); + ev = odp_schedule(NULL, wait); if (ev != ODP_EVENT_INVALID) { if (odp_event_type(ev) == ODP_EVENT_PACKET) { @@ -333,7 +374,7 @@ static odp_packet_t wait_for_packet(odp_queue_t queue, } /* not interested in this event */ - odp_buffer_free(odp_buffer_from_event(ev)); + odp_event_free(ev); } now = odp_time_cycles(); @@ -420,7 +461,7 @@ static void test_txrx(odp_queue_type_t q_type, int num_pkts) io = &pktios[i]; io->name = iface_name[i]; - io->id = create_pktio(iface_name[i], i); + io->id = create_pktio(iface_name[i], q_type, i); if (io->id == ODP_PKTIO_INVALID) { CU_FAIL("failed to open iface"); return; @@ -431,6 +472,9 @@ static void test_txrx(odp_queue_type_t q_type, int num_pkts) io->inq = odp_pktio_inq_getdef(io->id); else io->inq = ODP_QUEUE_INVALID; + + ret = odp_pktio_start(io->id); + CU_ASSERT(ret == 0); } /* if we have two interfaces then send through one and receive on @@ -476,7 +520,7 @@ void pktio_test_mtu(void) { int ret; int mtu; - odp_pktio_t pktio = create_pktio(iface_name[0], 0); + odp_pktio_t pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); mtu = odp_pktio_mtu(pktio); CU_ASSERT(mtu > 0); @@ -490,7 +534,7 @@ void pktio_test_mtu(void) void pktio_test_promisc(void) { int ret; - odp_pktio_t pktio = create_pktio(iface_name[0], 0); + odp_pktio_t pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); ret = odp_pktio_promisc_mode_set(pktio, 1); CU_ASSERT(0 == ret); @@ -515,7 +559,9 @@ void pktio_test_mac(void) unsigned char mac_addr[ODPH_ETHADDR_LEN]; int mac_len; int ret; - odp_pktio_t pktio = create_pktio(iface_name[0], 0); + odp_pktio_t pktio; + + pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); printf("testing mac for %s\n", iface_name[0]); @@ -536,21 +582,24 @@ void pktio_test_mac(void) void pktio_test_inq_remdef(void) { - odp_pktio_t pktio = create_pktio(iface_name[0], 0); + odp_pktio_t pktio; odp_queue_t inq; odp_event_t ev; + uint64_t wait; int i; + pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); CU_ASSERT(pktio != ODP_PKTIO_INVALID); CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0); inq = odp_pktio_inq_getdef(pktio); CU_ASSERT(inq != ODP_QUEUE_INVALID); CU_ASSERT(odp_pktio_inq_remdef(pktio) == 0); + wait = odp_schedule_wait_time(ODP_TIME_MSEC); for (i = 0; i < 100; i++) { - ev = odp_schedule(NULL, ODP_TIME_MSEC); + ev = odp_schedule(NULL, wait); if (ev != ODP_EVENT_INVALID) { - odp_buffer_free(odp_buffer_from_event(ev)); + odp_event_free(ev); CU_FAIL("received unexpected event"); } } @@ -562,29 +611,38 @@ void pktio_test_inq_remdef(void) void pktio_test_open(void) { odp_pktio_t pktio; + odp_pktio_param_t pktio_param; int i; /* test the sequence open->close->open->close() */ for (i = 0; i < 2; ++i) { - pktio = create_pktio(iface_name[0], 0); + pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); CU_ASSERT(pktio != ODP_PKTIO_INVALID); CU_ASSERT(odp_pktio_close(pktio) == 0); } - pktio = odp_pktio_open("nothere", default_pkt_pool); + memset(&pktio_param, 0, sizeof(pktio_param)); + pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; + + pktio = odp_pktio_open("nothere", default_pkt_pool, &pktio_param); CU_ASSERT(pktio == ODP_PKTIO_INVALID); } void pktio_test_lookup(void) { odp_pktio_t pktio, pktio_inval; + odp_pktio_param_t pktio_param; + + memset(&pktio_param, 0, sizeof(pktio_param)); + pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; - pktio = odp_pktio_open(iface_name[0], default_pkt_pool); + pktio = odp_pktio_open(iface_name[0], default_pkt_pool, &pktio_param); CU_ASSERT(pktio != ODP_PKTIO_INVALID); CU_ASSERT(odp_pktio_lookup(iface_name[0]) == pktio); - pktio_inval = odp_pktio_open(iface_name[0], default_pkt_pool); + pktio_inval = odp_pktio_open(iface_name[0], default_pkt_pool, + &pktio_param); CU_ASSERT(odp_errno() != 0); CU_ASSERT(pktio_inval == ODP_PKTIO_INVALID); @@ -597,7 +655,7 @@ void pktio_test_inq(void) { odp_pktio_t pktio; - pktio = create_pktio(iface_name[0], 0); + pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); CU_ASSERT(pktio != ODP_PKTIO_INVALID); CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0); @@ -605,18 +663,130 @@ void pktio_test_inq(void) CU_ASSERT(odp_pktio_close(pktio) == 0); } +static void pktio_test_start_stop(void) +{ + odp_pktio_t pktio[MAX_NUM_IFACES]; + odp_packet_t pkt; + odp_event_t tx_ev[1000]; + odp_event_t ev; + int i, pkts, ret, alloc = 0; + odp_queue_t outq; + uint64_t wait = odp_schedule_wait_time(ODP_TIME_MSEC); + + for (i = 0; i < num_ifaces; i++) { + pktio[i] = create_pktio(iface_name[i], ODP_QUEUE_TYPE_SCHED, 0); + CU_ASSERT(pktio[i] != ODP_PKTIO_INVALID); + create_inq(pktio[i], ODP_QUEUE_TYPE_SCHED); + } + + for (alloc = 0; alloc < 1000; alloc++) { + pkt = odp_packet_alloc(default_pkt_pool, packet_len); + if (pkt == ODP_PACKET_INVALID) + break; + pktio_init_packet(pkt); + tx_ev[alloc] = odp_packet_to_event(pkt); + } + + outq = odp_pktio_outq_getdef(pktio[0]); + + ret = odp_pktio_stop(pktio[0]); + CU_ASSERT(ret == 0); + + /* start first and queue packets */ + ret = odp_pktio_start(pktio[0]); + CU_ASSERT(ret == 0); + /* stop second and send packets*/ + if (num_ifaces > 1) { + ret = odp_pktio_stop(pktio[1]); + CU_ASSERT(ret == 0); + } + for (pkts = 0; pkts != alloc; ) { + ret = odp_queue_enq_multi(outq, &tx_ev[pkts], alloc - pkts); + if (ret < 0) { + CU_FAIL("unable to enqueue packet\n"); + break; + } + pkts += ret; + } + /* check that packets did not arrive */ + for (i = 0, pkts = 0; i < 1000; i++) { + ev = odp_schedule(NULL, wait); + if (ev != ODP_EVENT_INVALID) { + if (odp_event_type(ev) == ODP_EVENT_PACKET) { + if (pktio_pkt_seq(pkt) != TEST_SEQ_INVALID) + pkts++; + } + odp_event_free(ev); + } + } + if (pkts) + CU_FAIL("pktio stopped, received unexpected events"); + + /* start both, send and get packets */ + /* 0 already started */ + if (num_ifaces > 1) { + ret = odp_pktio_start(pktio[1]); + CU_ASSERT(ret == 0); + } + + /* flush packets with magic number in pipes */ + for (i = 0; i < 1000; i++) { + ev = odp_schedule(NULL, wait); + if (ev != ODP_EVENT_INVALID) + odp_event_free(ev); + } + + /* alloc */ + for (alloc = 0; alloc < 1000; alloc++) { + pkt = odp_packet_alloc(default_pkt_pool, packet_len); + if (pkt == ODP_PACKET_INVALID) + break; + pktio_init_packet(pkt); + tx_ev[alloc] = odp_packet_to_event(pkt); + } + + /* send */ + for (pkts = 0; pkts != alloc; ) { + ret = odp_queue_enq_multi(outq, &tx_ev[pkts], alloc - pkts); + if (ret < 0) { + CU_FAIL("unable to enqueue packet\n"); + break; + } + pkts += ret; + } + + /* get */ + for (i = 0, pkts = 0; i < 1000; i++) { + ev = odp_schedule(NULL, wait); + if (ev != ODP_EVENT_INVALID) { + if (odp_event_type(ev) == ODP_EVENT_PACKET) { + pkt = odp_packet_from_event(ev); + if (pktio_pkt_seq(pkt) != TEST_SEQ_INVALID) + pkts++; + } + odp_event_free(ev); + } + } + CU_ASSERT(pkts == alloc); + + for (i = 0; i < num_ifaces; i++) { + destroy_inq(pktio[i]); + CU_ASSERT(odp_pktio_close(pktio[i]) == 0); + } +} + static int create_pool(const char *iface, int num) { char pool_name[ODP_POOL_NAME_LEN]; odp_pool_param_t params; memset(¶ms, 0, sizeof(params)); - params.pkt.seg_len = PKT_BUF_SIZE; - params.pkt.len = PKT_BUF_SIZE; + set_pool_len(¶ms); params.pkt.num = PKT_BUF_NUM; params.type = ODP_POOL_PACKET; - snprintf(pool_name, sizeof(pool_name), "pkt_pool_%s", iface); + snprintf(pool_name, sizeof(pool_name), "pkt_pool_%s_%d", + iface, pool_segmentation); pool[num] = odp_pool_create(pool_name, ¶ms); if (ODP_POOL_INVALID == pool[num]) { @@ -627,7 +797,7 @@ static int create_pool(const char *iface, int num) return 0; } -int pktio_suite_init(void) +static int pktio_suite_init(void) { odp_atomic_init_u32(&ip_seq, 0); iface_name[0] = getenv("ODP_PKTIO_IF0"); @@ -659,6 +829,18 @@ int pktio_suite_init(void) return 0; } +int pktio_suite_init_unsegmented(void) +{ + pool_segmentation = PKT_POOL_UNSEGMENTED; + return pktio_suite_init(); +} + +int pktio_suite_init_segmented(void) +{ + pool_segmentation = PKT_POOL_SEGMENTED; + return pktio_suite_init(); +} + int pktio_suite_term(void) { char pool_name[ODP_POOL_NAME_LEN]; @@ -668,7 +850,7 @@ int pktio_suite_term(void) for (i = 0; i < num_ifaces; ++i) { snprintf(pool_name, sizeof(pool_name), - "pkt_pool_%s", iface_name[i]); + "pkt_pool_%s_%d", iface_name[i], pool_segmentation); pool = odp_pool_lookup(pool_name); if (pool == ODP_POOL_INVALID) continue; @@ -684,29 +866,42 @@ int pktio_suite_term(void) fprintf(stderr, "error: failed to destroy default pool\n"); ret = -1; } + default_pkt_pool = ODP_POOL_INVALID; return ret; } -CU_TestInfo pktio_suite[] = { - {"pktio open", pktio_test_open}, - {"pktio lookup", pktio_test_lookup}, - {"pktio inq", pktio_test_inq}, +CU_TestInfo pktio_suite_unsegmented[] = { + _CU_TEST_INFO(pktio_test_open), + _CU_TEST_INFO(pktio_test_lookup), + _CU_TEST_INFO(pktio_test_inq), + _CU_TEST_INFO(pktio_test_poll_queue), + _CU_TEST_INFO(pktio_test_poll_multi), + _CU_TEST_INFO(pktio_test_sched_queue), + _CU_TEST_INFO(pktio_test_sched_multi), + _CU_TEST_INFO(pktio_test_jumbo), + _CU_TEST_INFO(pktio_test_mtu), + _CU_TEST_INFO(pktio_test_promisc), + _CU_TEST_INFO(pktio_test_mac), + _CU_TEST_INFO(pktio_test_inq_remdef), + _CU_TEST_INFO(pktio_test_start_stop), + CU_TEST_INFO_NULL +}; + +CU_TestInfo pktio_suite_segmented[] = { {"pktio poll queues", pktio_test_poll_queue}, {"pktio poll multi", pktio_test_poll_multi}, {"pktio sched queues", pktio_test_sched_queue}, {"pktio sched multi", pktio_test_sched_multi}, {"pktio jumbo frames", pktio_test_jumbo}, - {"pktio mtu", pktio_test_mtu}, - {"pktio promisc mode", pktio_test_promisc}, - {"pktio mac", pktio_test_mac}, - {"pktio inq_remdef", pktio_test_inq_remdef}, CU_TEST_INFO_NULL }; CU_SuiteInfo pktio_suites[] = { - {"Packet I/O", - pktio_suite_init, pktio_suite_term, NULL, NULL, pktio_suite}, + {"Packet I/O Unsegmented", pktio_suite_init_unsegmented, + pktio_suite_term, NULL, NULL, pktio_suite_unsegmented}, + {"Packet I/O Segmented", pktio_suite_init_segmented, + pktio_suite_term, NULL, NULL, pktio_suite_segmented}, CU_SUITE_INFO_NULL }; diff --git a/test/validation/pktio/pktio.h b/test/validation/pktio/pktio.h index 1749d5d8e..feaf7fb70 100644 --- a/test/validation/pktio/pktio.h +++ b/test/validation/pktio/pktio.h @@ -28,7 +28,8 @@ extern CU_TestInfo pktio_suite[]; /* test array init/term functions: */ int pktio_suite_term(void); -int pktio_suite_init(void); +int pktio_suite_init_segmented(void); +int pktio_suite_init_unsegmented(void); /* test registry: */ extern CU_SuiteInfo pktio_suites[]; diff --git a/test/validation/pool/Makefile.am b/test/validation/pool/Makefile.am index 97f3eb450..8f626e7f1 100644 --- a/test/validation/pool/Makefile.am +++ b/test/validation/pool/Makefile.am @@ -6,3 +6,5 @@ libpool_la_SOURCES = pool.c bin_PROGRAMS = pool_main$(EXEEXT) dist_pool_main_SOURCES = pool_main.c pool_main_LDADD = libpool.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = pool.h diff --git a/test/validation/pool/pool.c b/test/validation/pool/pool.c index 924755763..44ba155c6 100644 --- a/test/validation/pool/pool.c +++ b/test/validation/pool/pool.c @@ -99,8 +99,6 @@ void pool_test_lookup_info_print(void) CU_ASSERT(odp_pool_destroy(pool) == 0); } -#define _CU_TEST_INFO(test_func) {#test_func, test_func} - CU_TestInfo pool_suite[] = { _CU_TEST_INFO(pool_test_create_destroy_buffer), _CU_TEST_INFO(pool_test_create_destroy_packet), diff --git a/test/validation/queue/Makefile.am b/test/validation/queue/Makefile.am index adeefc7ee..c4e5f9647 100644 --- a/test/validation/queue/Makefile.am +++ b/test/validation/queue/Makefile.am @@ -6,3 +6,5 @@ libqueue_la_SOURCES = queue.c bin_PROGRAMS = queue_main$(EXEEXT) dist_queue_main_SOURCES = queue_main.c queue_main_LDADD = libqueue.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = queue.h diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c index 5b2a13ae7..02a553817 100644 --- a/test/validation/queue/queue.c +++ b/test/validation/queue/queue.c @@ -51,9 +51,15 @@ void queue_test_sunnydays(void) int nr_deq_entries = 0; int max_iteration = CONFIG_MAX_ITERATION; void *prtn = NULL; + odp_queue_param_t qparams; + + odp_queue_param_init(&qparams); + qparams.sched.prio = ODP_SCHED_PRIO_LOWEST; + qparams.sched.sync = ODP_SCHED_SYNC_NONE; + qparams.sched.group = ODP_SCHED_GROUP_WORKER; queue_creat_id = odp_queue_create("test_queue", - ODP_QUEUE_TYPE_POLL, NULL); + ODP_QUEUE_TYPE_POLL, &qparams); CU_ASSERT(ODP_QUEUE_INVALID != queue_creat_id); CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL, @@ -62,9 +68,14 @@ void queue_test_sunnydays(void) queue_id = odp_queue_lookup("test_queue"); CU_ASSERT_EQUAL(queue_creat_id, queue_id); - CU_ASSERT(0 == odp_queue_set_context(queue_id, &queue_contest)); + CU_ASSERT_EQUAL(ODP_SCHED_GROUP_WORKER, + odp_queue_sched_group(queue_id)); + CU_ASSERT_EQUAL(ODP_SCHED_PRIO_LOWEST, odp_queue_sched_prio(queue_id)); + CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE, odp_queue_sched_type(queue_id)); + + CU_ASSERT(0 == odp_queue_context_set(queue_id, &queue_contest)); - prtn = odp_queue_get_context(queue_id); + prtn = odp_queue_context(queue_id); CU_ASSERT(&queue_contest == (int *)prtn); msg_pool = odp_pool_lookup("msg_pool"); @@ -115,7 +126,7 @@ void queue_test_sunnydays(void) } CU_TestInfo queue_suite[] = { - {"queue sunnyday", queue_test_sunnydays}, + _CU_TEST_INFO(queue_test_sunnydays), CU_TEST_INFO_NULL, }; diff --git a/test/validation/random/Makefile.am b/test/validation/random/Makefile.am index 85056d59f..8f871bc18 100644 --- a/test/validation/random/Makefile.am +++ b/test/validation/random/Makefile.am @@ -6,3 +6,5 @@ librandom_la_SOURCES = random.c bin_PROGRAMS = random_main$(EXEEXT) dist_random_main_SOURCES = random_main.c random_main_LDADD = librandom.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = random.h diff --git a/test/validation/random/random.c b/test/validation/random/random.c index 039c7a333..b6426f4c0 100644 --- a/test/validation/random/random.c +++ b/test/validation/random/random.c @@ -8,9 +8,6 @@ #include <odp_cunit_common.h> #include "random.h" -/* Helper macro for CU_TestInfo initialization */ -#define _CU_TEST_INFO(test_func) {#test_func, test_func} - void random_test_get_size(void) { int32_t ret; diff --git a/test/validation/scheduler/Makefile.am b/test/validation/scheduler/Makefile.am index d5696914f..e3947fae6 100644 --- a/test/validation/scheduler/Makefile.am +++ b/test/validation/scheduler/Makefile.am @@ -6,3 +6,5 @@ libscheduler_la_SOURCES = scheduler.c bin_PROGRAMS = scheduler_main$(EXEEXT) dist_scheduler_main_SOURCES = scheduler_main.c scheduler_main_LDADD = libscheduler.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = scheduler.h diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index 1bcaee693..1874889e7 100644 --- a/test/validation/scheduler/scheduler.c +++ b/test/validation/scheduler/scheduler.c @@ -20,6 +20,7 @@ #define GLOBALS_SHM_NAME "test_globals" #define MSG_POOL_NAME "msg_pool" +#define QUEUE_CTX_POOL_NAME "queue_ctx_pool" #define SHM_MSG_POOL_NAME "shm_msg_pool" #define SHM_THR_ARGS_NAME "shm_thr_args" @@ -35,6 +36,8 @@ #define ENABLE_EXCL_ATOMIC 1 #define MAGIC 0xdeadbeef +#define MAGIC1 0xdeadbeef +#define MAGIC2 0xcafef00d /* Test global variables */ typedef struct { @@ -57,7 +60,19 @@ typedef struct { int enable_excl_atomic; } thread_args_t; +typedef struct { + uint64_t sequence; +} buf_contents; + +typedef struct { + odp_buffer_t ctx_handle; + uint64_t sequence; + uint64_t lock_sequence; + odp_schedule_order_lock_t order_lock; +} queue_context; + odp_pool_t pool; +odp_pool_t queue_ctx_pool; static int exit_schedule_loop(void) { @@ -68,10 +83,7 @@ static int exit_schedule_loop(void) while ((ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT)) != ODP_EVENT_INVALID) { - odp_buffer_t buf; - - buf = odp_buffer_from_event(ev); - odp_buffer_free(buf); + odp_event_free(ev); ret++; } @@ -115,6 +127,8 @@ void scheduler_test_queue_destroy(void) ODP_SCHED_SYNC_ATOMIC, ODP_SCHED_SYNC_ORDERED}; + odp_queue_param_init(&qp); + odp_pool_param_init(¶ms); params.buf.size = 100; params.buf.align = 0; params.buf.num = 1; @@ -126,7 +140,6 @@ void scheduler_test_queue_destroy(void) for (i = 0; i < 3; i++) { qp.sched.prio = ODP_SCHED_PRIO_DEFAULT; - qp.sched.group = ODP_SCHED_GROUP_DEFAULT; qp.sched.sync = sync[i]; queue = odp_queue_create("sched_destroy_queue", @@ -157,6 +170,7 @@ void scheduler_test_queue_destroy(void) CU_ASSERT_FATAL(u32[0] == MAGIC); odp_buffer_free(buf); + odp_schedule_release_ordered(); CU_ASSERT_FATAL(odp_queue_destroy(queue) == 0); } @@ -164,11 +178,215 @@ void scheduler_test_queue_destroy(void) CU_ASSERT_FATAL(odp_pool_destroy(p) == 0); } +void scheduler_test_groups(void) +{ + odp_pool_t p; + odp_pool_param_t params; + odp_queue_param_t qp; + odp_queue_t queue_grp1, queue_grp2, from; + odp_buffer_t buf; + odp_event_t ev; + uint32_t *u32; + int i, j, rc; + odp_schedule_sync_t sync[] = {ODP_SCHED_SYNC_NONE, + ODP_SCHED_SYNC_ATOMIC, + ODP_SCHED_SYNC_ORDERED}; + int thr_id = odp_thread_id(); + odp_thrmask_t zeromask, mymask, testmask; + odp_schedule_group_t mygrp1, mygrp2, lookup; + + odp_thrmask_zero(&zeromask); + odp_thrmask_zero(&mymask); + odp_thrmask_set(&mymask, thr_id); + + /* Can't find a group before we create it */ + lookup = odp_schedule_group_lookup("Test Group 1"); + CU_ASSERT(lookup == ODP_SCHED_GROUP_INVALID); + + /* Now create the group */ + mygrp1 = odp_schedule_group_create("Test Group 1", &zeromask); + CU_ASSERT_FATAL(mygrp1 != ODP_SCHED_GROUP_INVALID); + + /* Verify we can now find it */ + lookup = odp_schedule_group_lookup("Test Group 1"); + CU_ASSERT(lookup == mygrp1); + + /* Threadmask should be retrievable and be what we expect */ + rc = odp_schedule_group_thrmask(mygrp1, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(!odp_thrmask_isset(&testmask, thr_id)); + + /* Now join the group and verify we're part of it */ + rc = odp_schedule_group_join(mygrp1, &mymask); + CU_ASSERT(rc == 0); + + rc = odp_schedule_group_thrmask(mygrp1, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(odp_thrmask_isset(&testmask, thr_id)); + + /* We can't join or leave an unknown group */ + rc = odp_schedule_group_join(ODP_SCHED_GROUP_INVALID, &mymask); + CU_ASSERT(rc != 0); + + rc = odp_schedule_group_leave(ODP_SCHED_GROUP_INVALID, &mymask); + CU_ASSERT(rc != 0); + + /* But we can leave our group */ + rc = odp_schedule_group_leave(mygrp1, &mymask); + CU_ASSERT(rc == 0); + + rc = odp_schedule_group_thrmask(mygrp1, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(!odp_thrmask_isset(&testmask, thr_id)); + + /* We shouldn't be able to find our second group before creating it */ + lookup = odp_schedule_group_lookup("Test Group 2"); + CU_ASSERT(lookup == ODP_SCHED_GROUP_INVALID); + + /* Now create it and verify we can find it */ + mygrp2 = odp_schedule_group_create("Test Group 2", &zeromask); + CU_ASSERT_FATAL(mygrp2 != ODP_SCHED_GROUP_INVALID); + + lookup = odp_schedule_group_lookup("Test Group 2"); + CU_ASSERT(lookup == mygrp2); + + /* Verify we're not part of it */ + rc = odp_schedule_group_thrmask(mygrp2, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(!odp_thrmask_isset(&testmask, thr_id)); + + /* Now join the group and verify we're part of it */ + rc = odp_schedule_group_join(mygrp2, &mymask); + CU_ASSERT(rc == 0); + + rc = odp_schedule_group_thrmask(mygrp2, &testmask); + CU_ASSERT(rc == 0); + CU_ASSERT(odp_thrmask_isset(&testmask, thr_id)); + + /* Now verify scheduler adherence to groups */ + odp_queue_param_init(&qp); + odp_pool_param_init(¶ms); + params.buf.size = 100; + params.buf.align = 0; + params.buf.num = 2; + params.type = ODP_POOL_BUFFER; + + p = odp_pool_create("sched_group_pool", ¶ms); + + CU_ASSERT_FATAL(p != ODP_POOL_INVALID); + + for (i = 0; i < 3; i++) { + qp.sched.prio = ODP_SCHED_PRIO_DEFAULT; + qp.sched.sync = sync[i]; + qp.sched.group = mygrp1; + + /* Create and populate a group in group 1 */ + queue_grp1 = odp_queue_create("sched_group_test_queue_1", + ODP_QUEUE_TYPE_SCHED, &qp); + CU_ASSERT_FATAL(queue_grp1 != ODP_QUEUE_INVALID); + CU_ASSERT_FATAL(odp_queue_sched_group(queue_grp1) == mygrp1); + + buf = odp_buffer_alloc(p); + + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + + u32 = odp_buffer_addr(buf); + u32[0] = MAGIC1; + + ev = odp_buffer_to_event(buf); + if (!(CU_ASSERT(odp_queue_enq(queue_grp1, ev) == 0))) + odp_buffer_free(buf); + + /* Now create and populate a queue in group 2 */ + qp.sched.group = mygrp2; + queue_grp2 = odp_queue_create("sched_group_test_queue_2", + ODP_QUEUE_TYPE_SCHED, &qp); + CU_ASSERT_FATAL(queue_grp2 != ODP_QUEUE_INVALID); + CU_ASSERT_FATAL(odp_queue_sched_group(queue_grp2) == mygrp2); + + buf = odp_buffer_alloc(p); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + + u32 = odp_buffer_addr(buf); + u32[0] = MAGIC2; + + ev = odp_buffer_to_event(buf); + if (!(CU_ASSERT(odp_queue_enq(queue_grp2, ev) == 0))) + odp_buffer_free(buf); + + /* Scheduler should give us the event from Group 2 */ + ev = odp_schedule(&from, ODP_SCHED_WAIT); + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); + CU_ASSERT_FATAL(from == queue_grp2); + + buf = odp_buffer_from_event(ev); + u32 = odp_buffer_addr(buf); + + CU_ASSERT_FATAL(u32[0] == MAGIC2); + + odp_buffer_free(buf); + + /* Scheduler should not return anything now since we're + * not in Group 1 and Queue 2 is empty. Do this several + * times to confirm. + */ + + for (j = 0; j < 10; j++) { + ev = odp_schedule(&from, ODP_SCHED_NO_WAIT); + CU_ASSERT_FATAL(ev == ODP_EVENT_INVALID) + } + + /* Now join group 1 and verify we can get the event */ + rc = odp_schedule_group_join(mygrp1, &mymask); + CU_ASSERT_FATAL(rc == 0); + + /* Tell scheduler we're about to request an event. + * Not needed, but a convenient place to test this API. + */ + odp_schedule_prefetch(1); + + /* Now get the event from Queue 1 */ + ev = odp_schedule(&from, ODP_SCHED_WAIT); + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); + CU_ASSERT_FATAL(from == queue_grp1); + + buf = odp_buffer_from_event(ev); + u32 = odp_buffer_addr(buf); + + CU_ASSERT_FATAL(u32[0] == MAGIC1); + + odp_buffer_free(buf); + + /* Leave group 1 for next pass */ + rc = odp_schedule_group_leave(mygrp1, &mymask); + CU_ASSERT_FATAL(rc == 0); + + /* We must release order before destroying queues */ + odp_schedule_release_ordered(); + + /* Done with queues for this round */ + CU_ASSERT_FATAL(odp_queue_destroy(queue_grp1) == 0); + CU_ASSERT_FATAL(odp_queue_destroy(queue_grp2) == 0); + + /* Verify we can no longer find our queues */ + CU_ASSERT_FATAL(odp_queue_lookup("sched_group_test_queue_1") == + ODP_QUEUE_INVALID); + CU_ASSERT_FATAL(odp_queue_lookup("sched_group_test_queue_2") == + ODP_QUEUE_INVALID); + } + + CU_ASSERT_FATAL(odp_schedule_group_destroy(mygrp1) == 0); + CU_ASSERT_FATAL(odp_schedule_group_destroy(mygrp2) == 0); + CU_ASSERT_FATAL(odp_pool_destroy(p) == 0); +} + static void *schedule_common_(void *arg) { thread_args_t *args = (thread_args_t *)arg; odp_schedule_sync_t sync; test_globals_t *globals; + queue_context *qctx; + buf_contents *bctx; globals = args->globals; sync = args->sync; @@ -199,16 +417,35 @@ static void *schedule_common_(void *arg) CU_ASSERT(num <= BURST_BUF_SIZE); if (num == 0) continue; - for (j = 0; j < num; j++) { - buf = odp_buffer_from_event(events[j]); - odp_buffer_free(buf); + + if (sync == ODP_SCHED_SYNC_ORDERED) { + qctx = odp_queue_context(from); + bctx = odp_buffer_addr( + odp_buffer_from_event(events[0])); + odp_schedule_order_lock(&qctx->order_lock); + CU_ASSERT(bctx->sequence == + qctx->lock_sequence); + qctx->lock_sequence += num; + odp_schedule_order_unlock(&qctx->order_lock); } + + for (j = 0; j < num; j++) + odp_event_free(events[j]); } else { ev = odp_schedule(&from, ODP_SCHED_NO_WAIT); buf = odp_buffer_from_event(ev); if (buf == ODP_BUFFER_INVALID) continue; num = 1; + if (sync == ODP_SCHED_SYNC_ORDERED) { + qctx = odp_queue_context(from); + bctx = odp_buffer_addr(buf); + odp_schedule_order_lock(&qctx->order_lock); + CU_ASSERT(bctx->sequence == + qctx->lock_sequence); + qctx->lock_sequence += num; + odp_schedule_order_unlock(&qctx->order_lock); + } odp_buffer_free(buf); } @@ -230,6 +467,9 @@ static void *schedule_common_(void *arg) if (sync == ODP_SCHED_SYNC_ATOMIC) odp_schedule_release_atomic(); + if (sync == ODP_SCHED_SYNC_ORDERED) + odp_schedule_release_ordered(); + odp_ticketlock_lock(&globals->lock); globals->buf_count -= num; @@ -293,6 +533,13 @@ static void fill_queues(thread_args_t *args) buf = odp_buffer_alloc(pool); CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); ev = odp_buffer_to_event(buf); + if (sync == ODP_SCHED_SYNC_ORDERED) { + queue_context *qctx = + odp_queue_context(queue); + buf_contents *bctx = + odp_buffer_addr(buf); + bctx->sequence = qctx->sequence++; + } if (!(CU_ASSERT(odp_queue_enq(queue, ev) == 0))) odp_buffer_free(buf); else @@ -304,6 +551,32 @@ static void fill_queues(thread_args_t *args) globals->buf_count = buf_count; } +static void reset_queues(thread_args_t *args) +{ + int i, j, k; + int num_prio = args->num_prio; + int num_queues = args->num_queues; + char name[32]; + + for (i = 0; i < num_prio; i++) { + for (j = 0; j < num_queues; j++) { + odp_queue_t queue; + + snprintf(name, sizeof(name), + "sched_%d_%d_o", i, j); + queue = odp_queue_lookup(name); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + for (k = 0; k < args->num_bufs; k++) { + queue_context *qctx = + odp_queue_context(queue); + qctx->sequence = 0; + qctx->lock_sequence = 0; + } + } + } +} + static void schedule_common(odp_schedule_sync_t sync, int num_queues, int num_prio, int enable_schd_multi) { @@ -328,6 +601,8 @@ static void schedule_common(odp_schedule_sync_t sync, int num_queues, fill_queues(&args); schedule_common_(&args); + if (sync == ODP_SCHED_SYNC_ORDERED) + reset_queues(&args); } static void parallel_execute(odp_schedule_sync_t sync, int num_queues, @@ -368,6 +643,10 @@ static void parallel_execute(odp_schedule_sync_t sync, int num_queues, /* Wait for worker threads to terminate */ odp_cunit_thread_exit(&args->cu_thr); + + /* Cleanup ordered queues for next pass */ + if (sync == ODP_SCHED_SYNC_ORDERED) + reset_queues(args); } /* 1 queue 1 thread ODP_SCHED_SYNC_NONE */ @@ -619,14 +898,28 @@ void scheduler_test_pause_resume(void) static int create_queues(void) { - int i, j, prios; + int i, j, prios, rc; + odp_pool_param_t params; + odp_buffer_t queue_ctx_buf; + queue_context *qctx; prios = odp_schedule_num_prio(); + odp_pool_param_init(¶ms); + params.buf.size = sizeof(queue_context); + params.buf.num = prios * QUEUES_PER_PRIO; + params.type = ODP_POOL_BUFFER; + + queue_ctx_pool = odp_pool_create(QUEUE_CTX_POOL_NAME, ¶ms); + + if (queue_ctx_pool == ODP_POOL_INVALID) { + printf("Pool creation failed (queue ctx).\n"); + return -1; + } for (i = 0; i < prios; i++) { odp_queue_param_t p; + odp_queue_param_init(&p); p.sched.prio = i; - p.sched.group = ODP_SCHED_GROUP_DEFAULT; for (j = 0; j < QUEUES_PER_PRIO; j++) { /* Per sched sync type */ @@ -659,6 +952,31 @@ static int create_queues(void) printf("Schedule queue create failed.\n"); return -1; } + + queue_ctx_buf = odp_buffer_alloc(queue_ctx_pool); + + if (queue_ctx_buf == ODP_BUFFER_INVALID) { + printf("Cannot allocate queue ctx buf\n"); + return -1; + } + + qctx = odp_buffer_addr(queue_ctx_buf); + qctx->ctx_handle = queue_ctx_buf; + qctx->sequence = 0; + qctx->lock_sequence = 0; + rc = odp_schedule_order_lock_init(&qctx->order_lock, q); + + if (rc != 0) { + printf("Ordered lock init failed\n"); + return -1; + } + + rc = odp_queue_context_set(q, qctx); + + if (rc != 0) { + printf("Cannot set queue context\n"); + return -1; + } } } @@ -674,6 +992,7 @@ int scheduler_suite_init(void) thread_args_t *args; odp_pool_param_t params; + odp_pool_param_init(¶ms); params.buf.size = BUF_SIZE; params.buf.align = 0; params.buf.num = MSG_POOL_SIZE / BUF_SIZE; @@ -727,11 +1046,15 @@ int scheduler_suite_init(void) static int destroy_queue(const char *name) { odp_queue_t q; + queue_context *qctx; q = odp_queue_lookup(name); if (q == ODP_QUEUE_INVALID) return -1; + qctx = odp_queue_context(q); + if (qctx) + odp_buffer_free(qctx->ctx_handle); return odp_queue_destroy(q); } @@ -760,6 +1083,9 @@ static int destroy_queues(void) } } + if (odp_pool_destroy(queue_ctx_pool) != 0) + return -1; + return 0; } @@ -780,36 +1106,37 @@ int scheduler_suite_term(void) } CU_TestInfo scheduler_suite[] = { - {"schedule_wait_time", scheduler_test_wait_time}, - {"schedule_num_prio", scheduler_test_num_prio}, - {"schedule_queue_destroy", scheduler_test_queue_destroy}, - {"schedule_1q_1t_n", scheduler_test_1q_1t_n}, - {"schedule_1q_1t_a", scheduler_test_1q_1t_a}, - {"schedule_1q_1t_o", scheduler_test_1q_1t_o}, - {"schedule_mq_1t_n", scheduler_test_mq_1t_n}, - {"schedule_mq_1t_a", scheduler_test_mq_1t_a}, - {"schedule_mq_1t_o", scheduler_test_mq_1t_o}, - {"schedule_mq_1t_prio_n", scheduler_test_mq_1t_prio_n}, - {"schedule_mq_1t_prio_a", scheduler_test_mq_1t_prio_a}, - {"schedule_mq_1t_prio_o", scheduler_test_mq_1t_prio_o}, - {"schedule_mq_mt_prio_n", scheduler_test_mq_mt_prio_n}, - {"schedule_mq_mt_prio_a", scheduler_test_mq_mt_prio_a}, - {"schedule_mq_mt_prio_o", scheduler_test_mq_mt_prio_o}, - {"schedule_1q_mt_a_excl", scheduler_test_1q_mt_a_excl}, - {"schedule_multi_1q_1t_n", scheduler_test_multi_1q_1t_n}, - {"schedule_multi_1q_1t_a", scheduler_test_multi_1q_1t_a}, - {"schedule_multi_1q_1t_o", scheduler_test_multi_1q_1t_o}, - {"schedule_multi_mq_1t_n", scheduler_test_multi_mq_1t_n}, - {"schedule_multi_mq_1t_a", scheduler_test_multi_mq_1t_a}, - {"schedule_multi_mq_1t_o", scheduler_test_multi_mq_1t_o}, - {"schedule_multi_mq_1t_prio_n", scheduler_test_multi_mq_1t_prio_n}, - {"schedule_multi_mq_1t_prio_a", scheduler_test_multi_mq_1t_prio_a}, - {"schedule_multi_mq_1t_prio_o", scheduler_test_multi_mq_1t_prio_o}, - {"schedule_multi_mq_mt_prio_n", scheduler_test_multi_mq_mt_prio_n}, - {"schedule_multi_mq_mt_prio_a", scheduler_test_multi_mq_mt_prio_a}, - {"schedule_multi_mq_mt_prio_o", scheduler_test_multi_mq_mt_prio_o}, - {"schedule_multi_1q_mt_a_excl", scheduler_test_multi_1q_mt_a_excl}, - {"schedule_pause_resume", scheduler_test_pause_resume}, + _CU_TEST_INFO(scheduler_test_wait_time), + _CU_TEST_INFO(scheduler_test_num_prio), + _CU_TEST_INFO(scheduler_test_queue_destroy), + _CU_TEST_INFO(scheduler_test_groups), + _CU_TEST_INFO(scheduler_test_1q_1t_n), + _CU_TEST_INFO(scheduler_test_1q_1t_a), + _CU_TEST_INFO(scheduler_test_1q_1t_o), + _CU_TEST_INFO(scheduler_test_mq_1t_n), + _CU_TEST_INFO(scheduler_test_mq_1t_a), + _CU_TEST_INFO(scheduler_test_mq_1t_o), + _CU_TEST_INFO(scheduler_test_mq_1t_prio_n), + _CU_TEST_INFO(scheduler_test_mq_1t_prio_a), + _CU_TEST_INFO(scheduler_test_mq_1t_prio_o), + _CU_TEST_INFO(scheduler_test_mq_mt_prio_n), + _CU_TEST_INFO(scheduler_test_mq_mt_prio_a), + _CU_TEST_INFO(scheduler_test_mq_mt_prio_o), + _CU_TEST_INFO(scheduler_test_1q_mt_a_excl), + _CU_TEST_INFO(scheduler_test_multi_1q_1t_n), + _CU_TEST_INFO(scheduler_test_multi_1q_1t_a), + _CU_TEST_INFO(scheduler_test_multi_1q_1t_o), + _CU_TEST_INFO(scheduler_test_multi_mq_1t_n), + _CU_TEST_INFO(scheduler_test_multi_mq_1t_a), + _CU_TEST_INFO(scheduler_test_multi_mq_1t_o), + _CU_TEST_INFO(scheduler_test_multi_mq_1t_prio_n), + _CU_TEST_INFO(scheduler_test_multi_mq_1t_prio_a), + _CU_TEST_INFO(scheduler_test_multi_mq_1t_prio_o), + _CU_TEST_INFO(scheduler_test_multi_mq_mt_prio_n), + _CU_TEST_INFO(scheduler_test_multi_mq_mt_prio_a), + _CU_TEST_INFO(scheduler_test_multi_mq_mt_prio_o), + _CU_TEST_INFO(scheduler_test_multi_1q_mt_a_excl), + _CU_TEST_INFO(scheduler_test_pause_resume), CU_TEST_INFO_NULL, }; diff --git a/test/validation/scheduler/scheduler.h b/test/validation/scheduler/scheduler.h index 31f02ca3b..eab8787b7 100644 --- a/test/validation/scheduler/scheduler.h +++ b/test/validation/scheduler/scheduler.h @@ -13,6 +13,7 @@ void scheduler_test_wait_time(void); void scheduler_test_num_prio(void); void scheduler_test_queue_destroy(void); +void scheduler_test_groups(void); void scheduler_test_1q_1t_n(void); void scheduler_test_1q_1t_a(void); void scheduler_test_1q_1t_o(void); diff --git a/test/validation/shmem/Makefile.am b/test/validation/shmem/Makefile.am index d81303db2..b2d94ed66 100644 --- a/test/validation/shmem/Makefile.am +++ b/test/validation/shmem/Makefile.am @@ -6,3 +6,5 @@ libshmem_la_SOURCES = shmem.c bin_PROGRAMS = shmem_main$(EXEEXT) dist_shmem_main_SOURCES = shmem_main.c shmem_main_LDADD = libshmem.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = shmem.h diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c index 3abba0c3b..6dc579a39 100644 --- a/test/validation/shmem/shmem.c +++ b/test/validation/shmem/shmem.c @@ -77,7 +77,7 @@ void shmem_test_odp_shm_sunnyday(void) } CU_TestInfo shmem_suite[] = { - {"test_odp_shm_creat", shmem_test_odp_shm_sunnyday}, + _CU_TEST_INFO(shmem_test_odp_shm_sunnyday), CU_TEST_INFO_NULL, }; diff --git a/test/validation/synchronizers/Makefile.am b/test/validation/synchronizers/Makefile.am index ecb9886a3..4cd313c2e 100644 --- a/test/validation/synchronizers/Makefile.am +++ b/test/validation/synchronizers/Makefile.am @@ -6,3 +6,5 @@ libsynchronizers_la_SOURCES = synchronizers.c bin_PROGRAMS = synchronizers_main$(EXEEXT) dist_synchronizers_main_SOURCES = synchronizers_main.c synchronizers_main_LDADD = libsynchronizers.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = synchronizers.h diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c index 7c521cadd..0a31a40ef 100644 --- a/test/validation/synchronizers/synchronizers.c +++ b/test/validation/synchronizers/synchronizers.c @@ -941,8 +941,8 @@ void synchronizers_test_barrier_functional(void) } CU_TestInfo synchronizers_suite_barrier[] = { - {"no_barrier_functional", synchronizers_test_no_barrier_functional}, - {"barrier_functional", synchronizers_test_barrier_functional}, + _CU_TEST_INFO(synchronizers_test_no_barrier_functional), + _CU_TEST_INFO(synchronizers_test_barrier_functional), CU_TEST_INFO_NULL }; @@ -957,7 +957,7 @@ void synchronizers_test_no_lock_functional(void) } CU_TestInfo synchronizers_suite_no_locking[] = { - {"no_lock_functional", synchronizers_test_no_lock_functional}, + _CU_TEST_INFO(synchronizers_test_no_lock_functional), CU_TEST_INFO_NULL }; @@ -982,8 +982,8 @@ void synchronizers_test_spinlock_functional(void) } CU_TestInfo synchronizers_suite_spinlock[] = { - {"spinlock_api", synchronizers_test_spinlock_api}, - {"spinlock_functional", synchronizers_test_spinlock_functional}, + _CU_TEST_INFO(synchronizers_test_spinlock_api), + _CU_TEST_INFO(synchronizers_test_spinlock_functional), CU_TEST_INFO_NULL }; @@ -1009,8 +1009,8 @@ void synchronizers_test_ticketlock_functional(void) } CU_TestInfo synchronizers_suite_ticketlock[] = { - {"ticketlock_api", synchronizers_test_ticketlock_api}, - {"ticketlock_functional", synchronizers_test_ticketlock_functional}, + _CU_TEST_INFO(synchronizers_test_ticketlock_api), + _CU_TEST_INFO(synchronizers_test_ticketlock_functional), CU_TEST_INFO_NULL }; @@ -1035,8 +1035,8 @@ void synchronizers_test_rwlock_functional(void) } CU_TestInfo synchronizers_suite_rwlock[] = { - {"rwlock_api", synchronizers_test_rwlock_api}, - {"rwlock_functional", synchronizers_test_rwlock_functional}, + _CU_TEST_INFO(synchronizers_test_rwlock_api), + _CU_TEST_INFO(synchronizers_test_rwlock_functional), CU_TEST_INFO_NULL }; @@ -1187,10 +1187,10 @@ void synchronizers_test_atomic_fetch_add_sub(void) } CU_TestInfo synchronizers_suite_atomic[] = { - {"atomic_inc_dec", synchronizers_test_atomic_inc_dec}, - {"atomic_add_sub", synchronizers_test_atomic_add_sub}, - {"atomic_fetch_inc_dec", synchronizers_test_atomic_fetch_inc_dec}, - {"atomic_fetch_add_sub", synchronizers_test_atomic_fetch_add_sub}, + _CU_TEST_INFO(synchronizers_test_atomic_inc_dec), + _CU_TEST_INFO(synchronizers_test_atomic_add_sub), + _CU_TEST_INFO(synchronizers_test_atomic_fetch_inc_dec), + _CU_TEST_INFO(synchronizers_test_atomic_fetch_add_sub), CU_TEST_INFO_NULL, }; diff --git a/test/validation/system/Makefile.am b/test/validation/system/Makefile.am index dd7759c2e..1c7de86f0 100644 --- a/test/validation/system/Makefile.am +++ b/test/validation/system/Makefile.am @@ -6,3 +6,5 @@ libsystem_la_SOURCES = system.c bin_PROGRAMS = system_main$(EXEEXT) dist_system_main_SOURCES = system_main.c system_main_LDADD = libsystem.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = system.h diff --git a/test/validation/system/system.c b/test/validation/system/system.c index 7687f20de..15f3ac467 100644 --- a/test/validation/system/system.c +++ b/test/validation/system/system.c @@ -12,7 +12,7 @@ void system_test_odp_version_numbers(void) { - int char_ok; + int char_ok = 0; char version_string[128]; char *s = version_string; @@ -84,13 +84,13 @@ void system_test_odp_sys_cpu_hz(void) } CU_TestInfo system_suite[] = { - {"odp version", system_test_odp_version_numbers}, - {"odp_cpu_count", system_test_odp_cpu_count}, - {"odp_sys_cache_line_size", system_test_odp_sys_cache_line_size}, - {"odp_sys_cpu_model_str", system_test_odp_sys_cpu_model_str}, - {"odp_sys_page_size", system_test_odp_sys_page_size}, - {"odp_sys_huge_page_size", system_test_odp_sys_huge_page_size}, - {"odp_sys_cpu_hz", system_test_odp_sys_cpu_hz}, + _CU_TEST_INFO(system_test_odp_version_numbers), + _CU_TEST_INFO(system_test_odp_cpu_count), + _CU_TEST_INFO(system_test_odp_sys_cache_line_size), + _CU_TEST_INFO(system_test_odp_sys_cpu_model_str), + _CU_TEST_INFO(system_test_odp_sys_page_size), + _CU_TEST_INFO(system_test_odp_sys_huge_page_size), + _CU_TEST_INFO(system_test_odp_sys_cpu_hz), CU_TEST_INFO_NULL, }; diff --git a/test/validation/thread/Makefile.am b/test/validation/thread/Makefile.am index c18bc5018..20b7f13d8 100644 --- a/test/validation/thread/Makefile.am +++ b/test/validation/thread/Makefile.am @@ -8,3 +8,5 @@ libthread_la_LIBADD = $(LIBTHRMASK_COMMON) bin_PROGRAMS = thread_main$(EXEEXT) dist_thread_main_SOURCES = thread_main.c thread_main_LDADD = libthread.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = thread.h diff --git a/test/validation/thread/thread.c b/test/validation/thread/thread.c index f95172ae6..d4f3ee0f9 100644 --- a/test/validation/thread/thread.c +++ b/test/validation/thread/thread.c @@ -10,9 +10,6 @@ #include <test_debug.h> #include "thread.h" -/* Helper macro for CU_TestInfo initialization */ -#define _CU_TEST_INFO(test_func) {#test_func, test_func} - /* Test thread entry and exit synchronization barriers */ odp_barrier_t bar_entry; odp_barrier_t bar_exit; diff --git a/test/validation/time/Makefile.am b/test/validation/time/Makefile.am index 418107d11..0e8742e82 100644 --- a/test/validation/time/Makefile.am +++ b/test/validation/time/Makefile.am @@ -6,3 +6,5 @@ libtime_la_SOURCES = time.c bin_PROGRAMS = time_main$(EXEEXT) dist_time_main_SOURCES = time_main.c time_main_LDADD = libtime.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = time.h diff --git a/test/validation/time/time.c b/test/validation/time/time.c index 4fa2eafa1..4b81c2c0b 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -62,9 +62,9 @@ void time_test_odp_time_conversion(void) } CU_TestInfo time_suite_time[] = { - {"cycles diff", time_test_odp_cycles_diff}, - {"negative diff", time_test_odp_cycles_negative_diff}, - {"conversion", time_test_odp_time_conversion}, + _CU_TEST_INFO(time_test_odp_cycles_diff), + _CU_TEST_INFO(time_test_odp_cycles_negative_diff), + _CU_TEST_INFO(time_test_odp_time_conversion), CU_TEST_INFO_NULL }; diff --git a/test/validation/timer/Makefile.am b/test/validation/timer/Makefile.am index 591dfb637..01e4fd3da 100644 --- a/test/validation/timer/Makefile.am +++ b/test/validation/timer/Makefile.am @@ -6,3 +6,5 @@ libtimer_la_SOURCES = timer.c bin_PROGRAMS = timer_main$(EXEEXT) dist_timer_main_SOURCES = timer_main.c timer_main_LDADD = libtimer.la $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST = timer.h diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c index 30b2b4343..7a8b98a17 100644 --- a/test/validation/timer/timer.c +++ b/test/validation/timer/timer.c @@ -427,7 +427,7 @@ static void *worker_entrypoint(void *arg TEST_UNUSED) CU_ASSERT(rc == 0); for (i = 0; i < NTIMERS; i++) { if (tt[i].ev != ODP_EVENT_INVALID) - odp_timeout_free(odp_timeout_from_event(tt[i].ev)); + odp_event_free(tt[i].ev); } free(tt); @@ -530,10 +530,10 @@ void timer_test_odp_timer_all(void) } CU_TestInfo timer_suite[] = { - {"test_timeout_pool_alloc", timer_test_timeout_pool_alloc}, - {"test_timeout_pool_free", timer_test_timeout_pool_free}, - {"test_odp_timer_cancel", timer_test_odp_timer_cancel}, - {"test_odp_timer_all", timer_test_odp_timer_all}, + _CU_TEST_INFO(timer_test_timeout_pool_alloc), + _CU_TEST_INFO(timer_test_timeout_pool_free), + _CU_TEST_INFO(timer_test_odp_timer_cancel), + _CU_TEST_INFO(timer_test_odp_timer_all), CU_TEST_INFO_NULL, }; |