X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Ftest_malloc.c;h=de40e506113a38980461b7ce73fc6f54553ccc41;hb=55ae8965bf8eecd5ebec36663bb0f36018abf64b;hp=71b3cfdde5cf920ae2e18405ef6d8294b865a5c9;hpb=b341a09c1dd3664b43d5b3a91b6a83136f2d4a12;p=dpdk.git diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c index 71b3cfdde5..de40e50611 100644 --- a/app/test/test_malloc.c +++ b/app/test/test_malloc.c @@ -2,13 +2,17 @@ * Copyright(c) 2010-2019 Intel Corporation */ +#include "test.h" + #include #include #include #include #include #include +#ifndef RTE_EXEC_ENV_WINDOWS #include +#endif #include #include @@ -23,11 +27,8 @@ #include #include -#include "test.h" - #define N 10000 - static int is_mem_on_socket(int32_t socket); @@ -47,8 +48,8 @@ addr_to_socket(void *addr); static int is_memory_overlap(void *p1, size_t len1, void *p2, size_t len2) { - unsigned long ptr1 = (unsigned long)p1; - unsigned long ptr2 = (unsigned long)p2; + uintptr_t ptr1 = (uintptr_t)p1; + uintptr_t ptr2 = (uintptr_t)p2; if (ptr2 >= ptr1 && (ptr2 - ptr1) < len1) return 1; @@ -60,7 +61,7 @@ is_memory_overlap(void *p1, size_t len1, void *p2, size_t len2) static int is_aligned(void *p, int align) { - unsigned long addr = (unsigned long)p; + uintptr_t addr = (uintptr_t)p; unsigned mask = align - 1; if (addr & mask) @@ -373,6 +374,14 @@ test_multi_alloc_statistics(void) return 0; } +#ifdef RTE_EXEC_ENV_WINDOWS +static int +test_realloc(void) +{ + return TEST_SKIPPED; +} +#else + static int test_realloc_socket(int socket) { @@ -603,7 +612,7 @@ test_realloc_numa(void) } } - /* Print warnign if only a single socket, but don't fail the test */ + /* Print warning 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"); @@ -671,6 +680,8 @@ end: return ret; } +#endif /* !RTE_EXEC_ENV_WINDOWS */ + static int test_random_alloc_free(void *_ __rte_unused) { @@ -812,7 +823,7 @@ test_zero_aligned_alloc(void) err_return: /*clean up */ - if (p1) rte_free(p1); + rte_free(p1); return -1; } @@ -846,6 +857,9 @@ test_malloc_bad_params(void) if (bad_ptr != NULL) goto err_return; +#if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG) + /* this test can not be built, will get trapped at compile time! */ +#else /* rte_malloc expected to return null with size will cause overflow */ align = RTE_CACHE_LINE_SIZE; size = (size_t)-8; @@ -857,13 +871,12 @@ test_malloc_bad_params(void) bad_ptr = rte_realloc(NULL, size, align); if (bad_ptr != NULL) goto err_return; - +#endif return 0; err_return: /* clean up pointer */ - if (bad_ptr) - rte_free(bad_ptr); + rte_free(bad_ptr); return -1; } @@ -968,7 +981,7 @@ test_alloc_socket(void) } } - /* Print warnign if only a single socket, but don't fail the test */ + /* Print warning if only a single socket, but don't fail the test */ if (socket_count < 2) { printf("WARNING: alloc_socket test needs memory on multiple sockets!\n"); } @@ -1007,11 +1020,11 @@ test_malloc(void) else printf("test_realloc() passed\n"); /*----------------------------*/ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { rte_eal_remote_launch(test_align_overlap_per_lcore, NULL, lcore_id); } - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (rte_eal_wait_lcore(lcore_id) < 0) ret = -1; } @@ -1022,11 +1035,11 @@ test_malloc(void) else printf("test_align_overlap_per_lcore() passed\n"); /*----------------------------*/ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { rte_eal_remote_launch(test_reordered_free_per_lcore, NULL, lcore_id); } - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (rte_eal_wait_lcore(lcore_id) < 0) ret = -1; } @@ -1037,11 +1050,11 @@ test_malloc(void) else printf("test_reordered_free_per_lcore() passed\n"); /*----------------------------*/ - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { rte_eal_remote_launch(test_random_alloc_free, NULL, lcore_id); } - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (rte_eal_wait_lcore(lcore_id) < 0) ret = -1; }