X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Ftest_malloc.c;h=a16e28cc32c88a8e8fbc9c35f83c89d60bea7d55;hb=94a24aaf6c5bd0a03c2828e7411d30a4fc0ac075;hp=6b6c6fec1139ea2445277d588c8be45f400a4819;hpb=a9de470cc7c0649221e156fc5f30a2dbdfe7c166;p=dpdk.git diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c index 6b6c6fec11..a16e28cc32 100644 --- a/app/test/test_malloc.c +++ b/app/test/test_malloc.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation + * Copyright(c) 2010-2019 Intel Corporation */ #include @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -26,6 +25,13 @@ #define N 10000 + +static int +is_mem_on_socket(int32_t socket); + +static int32_t +addr_to_socket(void *addr); + /* * Malloc * ====== @@ -365,18 +371,6 @@ test_multi_alloc_statistics(void) return 0; } -static int -test_rte_malloc_type_limits(void) -{ - /* The type-limits functionality is not yet implemented, - * so always return 0 no matter what the retval. - */ - const char *typename = "limit_test"; - rte_malloc_set_limit(typename, 64 * 1024); - rte_malloc_dump_stats(stdout, typename); - return 0; -} - static int test_realloc(void) { @@ -542,7 +536,49 @@ test_realloc(void) return -1; } rte_free(ptr12); - return 0; + + /* check realloc_socket part */ + int32_t socket_count = 0, socket_allocated, socket; + int ret = -1; + size_t size = 1024; + + ptr1 = NULL; + for (socket = 0; socket < RTE_MAX_NUMA_NODES; socket++) { + if (is_mem_on_socket(socket)) { + int j = 2; + + socket_count++; + while (j--) { + /* j == 1 -> resizing */ + ptr2 = rte_realloc_socket(ptr1, size, + RTE_CACHE_LINE_SIZE, + socket); + if (ptr2 == NULL) { + printf("NULL pointer returned from rte_realloc_socket\n"); + goto end; + } + + ptr1 = ptr2; + socket_allocated = addr_to_socket(ptr2); + if (socket_allocated != socket) { + printf("Requested socket (%d) doesn't mach allocated one (%d)\n", + socket, socket_allocated); + goto end; + } + size += RTE_CACHE_LINE_SIZE; + } + } + } + + /* Print warnign if only a single socket, but don't fail the test */ + if (socket_count < 2) + printf("WARNING: realloc_socket test needs memory on multiple sockets!\n"); + + ret = 0; +end: + rte_free(ptr1); + + return ret; } static int @@ -903,15 +939,6 @@ test_malloc(void) } else printf("test_random_alloc_free() passed\n"); - /*----------------------------*/ - ret = test_rte_malloc_type_limits(); - if (ret < 0){ - printf("test_rte_malloc_type_limits() failed\n"); - return ret; - } - /* TODO: uncomment following line once type limits are valid */ - /*else printf("test_rte_malloc_type_limits() passed\n");*/ - /*----------------------------*/ ret = test_rte_malloc_validate(); if (ret < 0){