MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_alloc_single_socket

Function test_alloc_single_socket

dpdk/app/test/test_malloc.c:966–1007  ·  view source on GitHub ↗

Test using rte_[c|m|zm]alloc_socket() on a specific socket */

Source from the content-addressed store, hash-verified

964
965/* Test using rte_[c|m|zm]alloc_socket() on a specific socket */
966static int
967test_alloc_single_socket(int32_t socket)
968{
969 const char *type = NULL;
970 const size_t size = 10;
971 const unsigned align = 0;
972 char *mem = NULL;
973 int32_t desired_socket = (socket == SOCKET_ID_ANY) ?
974 (int32_t)rte_socket_id() : socket;
975
976 /* Test rte_calloc_socket() */
977 mem = rte_calloc_socket(type, size, sizeof(char), align, socket);
978 if (mem == NULL)
979 return -1;
980 if (addr_to_socket(mem) != desired_socket) {
981 rte_free(mem);
982 return -1;
983 }
984 rte_free(mem);
985
986 /* Test rte_malloc_socket() */
987 mem = rte_malloc_socket(type, size, align, socket);
988 if (mem == NULL)
989 return -1;
990 if (addr_to_socket(mem) != desired_socket) {
991 rte_free(mem);
992 return -1;
993 }
994 rte_free(mem);
995
996 /* Test rte_zmalloc_socket() */
997 mem = rte_zmalloc_socket(type, size, align, socket);
998 if (mem == NULL)
999 return -1;
1000 if (addr_to_socket(mem) != desired_socket) {
1001 rte_free(mem);
1002 return -1;
1003 }
1004 rte_free(mem);
1005
1006 return 0;
1007}
1008
1009static int
1010test_alloc_socket(void)

Callers 1

test_alloc_socketFunction · 0.85

Calls 6

rte_socket_idFunction · 0.85
rte_calloc_socketFunction · 0.85
addr_to_socketFunction · 0.85
rte_freeFunction · 0.85
rte_malloc_socketFunction · 0.85
rte_zmalloc_socketFunction · 0.85

Tested by

no test coverage detected