Test using rte_[c|m|zm]alloc_socket() on a specific socket */
| 964 | |
| 965 | /* Test using rte_[c|m|zm]alloc_socket() on a specific socket */ |
| 966 | static int |
| 967 | test_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 | |
| 1009 | static int |
| 1010 | test_alloc_socket(void) |
no test coverage detected