diff options
author | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2019-07-04 10:40:06 +0200 |
---|---|---|
committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2019-07-04 10:48:05 +0200 |
commit | 8d53e9f3c6001dcb2865f6e894da5b54e1418f88 (patch) | |
tree | 63907f21c13636a987d43463c675d0727a04e327 /test/test | |
parent | e2bea7436061ca2e7e14bfcfdc5870f2555c3965 (diff) |
New upstream version 18.11.2upstream-18.11-stable
Change-Id: I23eb4f9179abf1f9c659891f8fddb27ee68ad26b
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'test/test')
-rw-r--r-- | test/test/autotest_data.py | 6 | ||||
-rw-r--r-- | test/test/commands.c | 12 | ||||
-rw-r--r-- | test/test/meson.build | 3 | ||||
-rw-r--r-- | test/test/test_barrier.c | 6 | ||||
-rw-r--r-- | test/test/test_compressdev.c | 1 | ||||
-rw-r--r-- | test/test/test_cryptodev.c | 3 | ||||
-rw-r--r-- | test/test/test_cryptodev_blockcipher.h | 4 | ||||
-rw-r--r-- | test/test/test_distributor.c | 7 | ||||
-rw-r--r-- | test/test/test_eal_flags.c | 1 | ||||
-rw-r--r-- | test/test/test_event_eth_rx_adapter.c | 3 | ||||
-rw-r--r-- | test/test/test_hash_perf.c | 6 | ||||
-rw-r--r-- | test/test/test_link_bonding.c | 45 | ||||
-rw-r--r-- | test/test/test_pmd_perf.c | 13 | ||||
-rw-r--r-- | test/test/test_spinlock.c | 31 | ||||
-rw-r--r-- | test/test/test_string_fns.c | 45 |
15 files changed, 125 insertions, 61 deletions
diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py index 0fb7866d..d878f954 100644 --- a/test/test/autotest_data.py +++ b/test/test/autotest_data.py @@ -297,12 +297,6 @@ parallel_test_list = [ "Report": None, }, { - "Name": "Devargs autotest", - "Command": "devargs_autotest", - "Func": default_autotest, - "Report": None, - }, - { "Name": "Link bonding autotest", "Command": "link_bonding_autotest", "Func": default_autotest, diff --git a/test/test/commands.c b/test/test/commands.c index 94fbc310..8d5a03a9 100644 --- a/test/test/commands.c +++ b/test/test/commands.c @@ -44,6 +44,7 @@ #include <cmdline_parse_num.h> #include <cmdline_parse_string.h> #include <cmdline.h> +#include <rte_string_fns.h> #include "test.h" @@ -365,23 +366,22 @@ cmdline_parse_ctx_t main_ctx[] = { int commands_init(void) { struct test_command *t; - char *commands, *ptr; + char *commands; int commands_len = 0; TAILQ_FOREACH(t, &commands_list, next) { commands_len += strlen(t->command) + 1; } - commands = malloc(commands_len + 1); + commands = (char *)calloc(commands_len, sizeof(char)); if (!commands) return -1; - ptr = commands; TAILQ_FOREACH(t, &commands_list, next) { - ptr += sprintf(ptr, "%s#", t->command); + strlcat(commands, t->command, commands_len); + if (TAILQ_NEXT(t, next) != NULL) + strlcat(commands, "#", commands_len); } - ptr--; - ptr[0] = '\0'; cmd_autotest_autotest.string_data.str = commands; return 0; diff --git a/test/test/meson.build b/test/test/meson.build index 5a4816fe..8f03ddda 100644 --- a/test/test/meson.build +++ b/test/test/meson.build @@ -154,7 +154,6 @@ test_names = [ 'cycles_autotest', 'debug_autotest', 'delay_us_sleep_autotest', - 'devargs_autotest', 'distributor_autotest', 'distributor_perf_autotest', 'eal_flags_autotest', @@ -263,7 +262,7 @@ if cc.has_argument('-Wno-format-truncation') endif # specify -D_GNU_SOURCE unconditionally -default_cflags += '-D_GNU_SOURCE' +cflags += '-D_GNU_SOURCE' test_dep_objs = [] compress_test_dep = dependency('zlib', required: false) diff --git a/test/test/test_barrier.c b/test/test/test_barrier.c index 82b572c3..92f3d325 100644 --- a/test/test/test_barrier.c +++ b/test/test/test_barrier.c @@ -92,12 +92,14 @@ plock_lock(struct plock *l, uint32_t self) other = self ^ 1; l->flag[self] = 1; + rte_smp_wmb(); l->victim = self; store_load_barrier(l->utype); while (l->flag[other] == 1 && l->victim == self) rte_pause(); + rte_smp_rmb(); } static void @@ -202,7 +204,7 @@ plock_test(uint32_t iter, enum plock_use_type utype) printf("%s(iter=%u, utype=%u) started on %u lcores\n", __func__, iter, utype, n); - if (pt == NULL || lpt == NULL) { + if (pt == NULL || lpt == NULL || sum == NULL) { printf("%s: failed to allocate memory for %u lcores\n", __func__, n); free(pt); @@ -252,7 +254,7 @@ plock_test(uint32_t iter, enum plock_use_type utype) /* race condition occurred, lock doesn't work properly */ if (sum[i] != pt[i].val || 2 * iter != pt[i].iter) { - printf("error: local and shared sums don't much\n"); + printf("error: local and shared sums don't match\n"); rc = -1; } } diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c index 5d5e5190..03334225 100644 --- a/test/test/test_compressdev.c +++ b/test/test/test_compressdev.c @@ -4,6 +4,7 @@ #include <string.h> #include <zlib.h> #include <math.h> +#include <unistd.h> #include <rte_cycles.h> #include <rte_malloc.h> diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index 84065eb4..fbe8c21e 100644 --- a/test/test/test_cryptodev.c +++ b/test/test/test_cryptodev.c @@ -15,6 +15,7 @@ #include <rte_crypto.h> #include <rte_cryptodev.h> #include <rte_cryptodev_pmd.h> +#include <rte_string_fns.h> #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER #include <rte_cryptodev_scheduler.h> @@ -374,7 +375,7 @@ testsuite_setup(void) snprintf(vdev_args, sizeof(vdev_args), "%s%d", temp_str, i); strcpy(temp_str, vdev_args); - strcat(temp_str, ";"); + strlcat(temp_str, ";", sizeof(temp_str)); slave_core_count++; socket_id = lcore_config[i].socket_id; } diff --git a/test/test/test_cryptodev_blockcipher.h b/test/test/test_cryptodev_blockcipher.h index f8bd8583..52c37764 100644 --- a/test/test/test_cryptodev_blockcipher.h +++ b/test/test/test_cryptodev_blockcipher.h @@ -27,10 +27,10 @@ #define BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC 0x0020 /* DPAA2_SEC flag */ #define BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC 0x0040 /* DPAA_SEC flag */ #define BLOCKCIPHER_TEST_TARGET_PMD_MVSAM 0x0080 /* Marvell flag */ -#define BLOCKCIPHER_TEST_TARGET_PMD_CCP 0x0040 /* CCP flag */ -#define BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO 0x0200 /* VIRTIO flag */ #define BLOCKCIPHER_TEST_TARGET_PMD_OCTEONTX 0x0100 /* OCTEON TX flag */ +#define BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO 0x0200 /* VIRTIO flag */ #define BLOCKCIPHER_TEST_TARGET_PMD_CAAM_JR 0x0400 /* CAAM_JR flag */ +#define BLOCKCIPHER_TEST_TARGET_PMD_CCP 0x0800 /* CCP flag */ #define BLOCKCIPHER_TEST_OP_CIPHER (BLOCKCIPHER_TEST_OP_ENCRYPT | \ BLOCKCIPHER_TEST_OP_DECRYPT) diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c index 98919ec0..da3348fd 100644 --- a/test/test/test_distributor.c +++ b/test/test/test_distributor.c @@ -11,6 +11,7 @@ #include <rte_mempool.h> #include <rte_mbuf.h> #include <rte_distributor.h> +#include <rte_string_fns.h> #define ITER_POWER 20 /* log 2 of how many iterations we do when timing. */ #define BURST 32 @@ -642,9 +643,11 @@ test_distributor(void) worker_params.dist = dist[i]; if (i) - sprintf(worker_params.name, "burst"); + strlcpy(worker_params.name, "burst", + sizeof(worker_params.name)); else - sprintf(worker_params.name, "single"); + strlcpy(worker_params.name, "single", + sizeof(worker_params.name)); rte_eal_mp_remote_launch(handle_work, &worker_params, SKIP_MASTER); diff --git a/test/test/test_eal_flags.c b/test/test/test_eal_flags.c index 81e345b8..775ccd3d 100644 --- a/test/test/test_eal_flags.c +++ b/test/test/test_eal_flags.c @@ -17,6 +17,7 @@ #include <sys/wait.h> #include <sys/file.h> #include <limits.h> +#include <fcntl.h> #include <rte_per_lcore.h> #include <rte_debug.h> diff --git a/test/test/test_event_eth_rx_adapter.c b/test/test/test_event_eth_rx_adapter.c index 1d3be82b..38f5c039 100644 --- a/test/test/test_event_eth_rx_adapter.c +++ b/test/test/test_event_eth_rx_adapter.c @@ -479,7 +479,8 @@ adapter_multi_eth_add_del(void) /* add the max port for rx_adapter */ port_index = rte_eth_dev_count_total(); for (; port_index < RTE_MAX_ETHPORTS; port_index += 1) { - sprintf(driver_name, "%s%u", "net_null", drv_id); + snprintf(driver_name, sizeof(driver_name), "%s%u", "net_null", + drv_id); err = rte_vdev_init(driver_name, NULL); TEST_ASSERT(err == 0, "Failed driver %s got %d", driver_name, err); diff --git a/test/test/test_hash_perf.c b/test/test/test_hash_perf.c index 52521118..5648fce0 100644 --- a/test/test/test_hash_perf.c +++ b/test/test/test_hash_perf.c @@ -85,9 +85,11 @@ create_table(unsigned int with_data, unsigned int table_index, if (with_data) /* Table will store 8-byte data */ - sprintf(name, "test_hash%d_data", hashtest_key_lens[table_index]); + snprintf(name, sizeof(name), "test_hash%u_data", + hashtest_key_lens[table_index]); else - sprintf(name, "test_hash%d", hashtest_key_lens[table_index]); + snprintf(name, sizeof(name), "test_hash%u", + hashtest_key_lens[table_index]); if (with_locks) diff --git a/test/test/test_link_bonding.c b/test/test/test_link_bonding.c index 0fe1d78e..0438e76c 100644 --- a/test/test/test_link_bonding.c +++ b/test/test/test_link_bonding.c @@ -201,6 +201,7 @@ configure_ethdev(uint16_t port_id, uint8_t start, uint8_t en_isr) } static int slaves_initialized; +static int mac_slaves_initialized; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cvar = PTHREAD_COND_INITIALIZER; @@ -873,10 +874,11 @@ test_set_explicit_bonded_mac(void) static int test_set_bonded_port_initialization_mac_assignment(void) { - int i, slave_count, bonded_port_id; + int i, slave_count; uint16_t slaves[RTE_MAX_ETHPORTS]; - int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT]; + static int bonded_port_id = -1; + static int slave_port_ids[BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT]; struct ether_addr slave_mac_addr, bonded_mac_addr, read_mac_addr; @@ -887,29 +889,36 @@ test_set_bonded_port_initialization_mac_assignment(void) /* * 1. a - Create / configure bonded / slave ethdevs */ - bonded_port_id = rte_eth_bond_create("net_bonding_mac_ass_test", - BONDING_MODE_ACTIVE_BACKUP, rte_socket_id()); - TEST_ASSERT(bonded_port_id > 0, "failed to create bonded device"); + if (bonded_port_id == -1) { + bonded_port_id = rte_eth_bond_create("net_bonding_mac_ass_test", + BONDING_MODE_ACTIVE_BACKUP, rte_socket_id()); + TEST_ASSERT(bonded_port_id > 0, "failed to create bonded device"); - TEST_ASSERT_SUCCESS(configure_ethdev(bonded_port_id, 0, 0), - "Failed to configure bonded ethdev"); + TEST_ASSERT_SUCCESS(configure_ethdev(bonded_port_id, 0, 0), + "Failed to configure bonded ethdev"); + } - for (i = 0; i < BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT; i++) { - char pmd_name[RTE_ETH_NAME_MAX_LEN]; + if (!mac_slaves_initialized) { + for (i = 0; i < BONDED_INIT_MAC_ASSIGNMENT_SLAVE_COUNT; i++) { + char pmd_name[RTE_ETH_NAME_MAX_LEN]; - slave_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = i + 100; + slave_mac_addr.addr_bytes[ETHER_ADDR_LEN-1] = i + 100; - snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, "eth_slave_%d", i); + snprintf(pmd_name, RTE_ETH_NAME_MAX_LEN, + "eth_slave_%d", i); - slave_port_ids[i] = virtual_ethdev_create(pmd_name, - &slave_mac_addr, rte_socket_id(), 1); + slave_port_ids[i] = virtual_ethdev_create(pmd_name, + &slave_mac_addr, rte_socket_id(), 1); - TEST_ASSERT(slave_port_ids[i] >= 0, - "Failed to create slave ethdev %s", pmd_name); + TEST_ASSERT(slave_port_ids[i] >= 0, + "Failed to create slave ethdev %s", + pmd_name); - TEST_ASSERT_SUCCESS(configure_ethdev(slave_port_ids[i], 1, 0), - "Failed to configure virtual ethdev %s", - pmd_name); + TEST_ASSERT_SUCCESS(configure_ethdev(slave_port_ids[i], 1, 0), + "Failed to configure virtual ethdev %s", + pmd_name); + } + mac_slaves_initialized = 1; } diff --git a/test/test/test_pmd_perf.c b/test/test/test_pmd_perf.c index f5095c87..ed8524a1 100644 --- a/test/test/test_pmd_perf.c +++ b/test/test/test_pmd_perf.c @@ -493,16 +493,21 @@ main_loop(__rte_unused void *args) for (i = 0; i < conf->nb_ports; i++) { portid = conf->portlist[i]; - int nb_free = pkt_per_port; + int nb_free = 0; + uint64_t timeout = 10000; do { /* dry out */ nb_rx = rte_eth_rx_burst(portid, 0, pkts_burst, MAX_PKT_BURST); nb_tx = 0; while (nb_tx < nb_rx) rte_pktmbuf_free(pkts_burst[nb_tx++]); - nb_free -= nb_rx; - } while (nb_free != 0); - printf("free %d mbuf left in port %u\n", pkt_per_port, portid); + nb_free += nb_rx; + + if (unlikely(nb_rx == 0)) + timeout--; + } while (nb_free != pkt_per_port && timeout != 0); + printf("free %d (expected %d) mbuf left in port %u\n", nb_free, + pkt_per_port, portid); } if (count == 0) diff --git a/test/test/test_spinlock.c b/test/test/test_spinlock.c index 73bff128..6ac74959 100644 --- a/test/test/test_spinlock.c +++ b/test/test/test_spinlock.c @@ -96,16 +96,16 @@ test_spinlock_recursive_per_core(__attribute__((unused)) void *arg) } static rte_spinlock_t lk = RTE_SPINLOCK_INITIALIZER; -static uint64_t lock_count[RTE_MAX_LCORE] = {0}; +static uint64_t time_count[RTE_MAX_LCORE] = {0}; -#define TIME_MS 100 +#define MAX_LOOP 10000 static int load_loop_fn(void *func_param) { uint64_t time_diff = 0, begin; uint64_t hz = rte_get_timer_hz(); - uint64_t lcount = 0; + volatile uint64_t lcount = 0; const int use_lock = *(int*)func_param; const unsigned lcore = rte_lcore_id(); @@ -114,17 +114,15 @@ load_loop_fn(void *func_param) while (rte_atomic32_read(&synchro) == 0); begin = rte_get_timer_cycles(); - while (time_diff < hz * TIME_MS / 1000) { + while (lcount < MAX_LOOP) { if (use_lock) rte_spinlock_lock(&lk); lcount++; if (use_lock) rte_spinlock_unlock(&lk); - /* delay to make lock duty cycle slighlty realistic */ - rte_delay_us(1); - time_diff = rte_get_timer_cycles() - begin; } - lock_count[lcore] = lcount; + time_diff = rte_get_timer_cycles() - begin; + time_count[lcore] = time_diff * 1000000 / hz; return 0; } @@ -138,14 +136,16 @@ test_spinlock_perf(void) printf("\nTest with no lock on single core...\n"); load_loop_fn(&lock); - printf("Core [%u] count = %"PRIu64"\n", lcore, lock_count[lcore]); - memset(lock_count, 0, sizeof(lock_count)); + printf("Core [%u] Cost Time = %"PRIu64" us\n", lcore, + time_count[lcore]); + memset(time_count, 0, sizeof(time_count)); printf("\nTest with lock on single core...\n"); lock = 1; load_loop_fn(&lock); - printf("Core [%u] count = %"PRIu64"\n", lcore, lock_count[lcore]); - memset(lock_count, 0, sizeof(lock_count)); + printf("Core [%u] Cost Time = %"PRIu64" us\n", lcore, + time_count[lcore]); + memset(time_count, 0, sizeof(time_count)); printf("\nTest with lock on %u cores...\n", rte_lcore_count()); @@ -160,11 +160,12 @@ test_spinlock_perf(void) rte_eal_mp_wait_lcore(); RTE_LCORE_FOREACH(i) { - printf("Core [%u] count = %"PRIu64"\n", i, lock_count[i]); - total += lock_count[i]; + printf("Core [%u] Cost Time = %"PRIu64" us\n", i, + time_count[i]); + total += time_count[i]; } - printf("Total count = %"PRIu64"\n", total); + printf("Total Cost Time = %"PRIu64" us\n", total); return 0; } diff --git a/test/test/test_string_fns.c b/test/test/test_string_fns.c index 3f091ab9..5e105d2b 100644 --- a/test/test/test_string_fns.c +++ b/test/test/test_string_fns.c @@ -130,10 +130,55 @@ test_rte_strsplit(void) } static int +test_rte_strlcat(void) +{ + /* only run actual unit tests if we have system-provided strlcat */ +#if defined(__BSD_VISIBLE) || defined(RTE_USE_LIBBSD) +#define BUF_LEN 32 + const char dst[BUF_LEN] = "Test string"; + const char src[] = " appended"; + char bsd_dst[BUF_LEN]; + char rte_dst[BUF_LEN]; + size_t i, bsd_ret, rte_ret; + + LOG("dst = '%s', strlen(dst) = %zu\n", dst, strlen(dst)); + LOG("src = '%s', strlen(src) = %zu\n", src, strlen(src)); + LOG("---\n"); + + for (i = 0; i < BUF_LEN; i++) { + /* initialize destination buffers */ + memcpy(bsd_dst, dst, BUF_LEN); + memcpy(rte_dst, dst, BUF_LEN); + /* compare implementations */ + bsd_ret = strlcat(bsd_dst, src, i); + rte_ret = rte_strlcat(rte_dst, src, i); + if (bsd_ret != rte_ret) { + LOG("Incorrect retval for buf length = %zu\n", i); + LOG("BSD: '%zu', rte: '%zu'\n", bsd_ret, rte_ret); + return -1; + } + if (memcmp(bsd_dst, rte_dst, BUF_LEN) != 0) { + LOG("Resulting buffers don't match\n"); + LOG("BSD: '%s', rte: '%s'\n", bsd_dst, rte_dst); + return -1; + } + LOG("buffer size = %zu: dst = '%s', ret = %zu\n", + i, rte_dst, rte_ret); + } + LOG("Checked %zu combinations\n", i); +#undef BUF_LEN +#endif /* defined(__BSD_VISIBLE) || defined(RTE_USE_LIBBSD) */ + + return 0; +} + +static int test_string_fns(void) { if (test_rte_strsplit() < 0) return -1; + if (test_rte_strlcat() < 0) + return -1; return 0; } |