| 73 | } |
| 74 | |
| 75 | static int |
| 76 | test_malloc_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova, |
| 77 | int n_pages) |
| 78 | { |
| 79 | static const char * const names[] = { |
| 80 | NULL, /* NULL name */ |
| 81 | "", /* empty name */ |
| 82 | "this heap name is definitely way too long to be valid" |
| 83 | }; |
| 84 | const char *valid_name = "valid heap name"; |
| 85 | unsigned int i; |
| 86 | |
| 87 | /* check invalid name handling */ |
| 88 | for (i = 0; i < RTE_DIM(names); i++) { |
| 89 | const char *name = names[i]; |
| 90 | |
| 91 | /* these calls may fail for other reasons, so check errno */ |
| 92 | if (rte_malloc_heap_create(name) >= 0 || rte_errno != EINVAL) { |
| 93 | printf("%s():%i: Created heap with invalid name\n", |
| 94 | __func__, __LINE__); |
| 95 | goto fail; |
| 96 | } |
| 97 | |
| 98 | if (rte_malloc_heap_destroy(name) >= 0 || rte_errno != EINVAL) { |
| 99 | printf("%s():%i: Destroyed heap with invalid name\n", |
| 100 | __func__, __LINE__); |
| 101 | goto fail; |
| 102 | } |
| 103 | |
| 104 | if (rte_malloc_heap_get_socket(name) >= 0 || |
| 105 | rte_errno != EINVAL) { |
| 106 | printf("%s():%i: Found socket for heap with invalid name\n", |
| 107 | __func__, __LINE__); |
| 108 | goto fail; |
| 109 | } |
| 110 | |
| 111 | if (rte_malloc_heap_memory_add(name, addr, len, |
| 112 | NULL, 0, pgsz) >= 0 || rte_errno != EINVAL) { |
| 113 | printf("%s():%i: Added memory to heap with invalid name\n", |
| 114 | __func__, __LINE__); |
| 115 | goto fail; |
| 116 | } |
| 117 | if (rte_malloc_heap_memory_remove(name, addr, len) >= 0 || |
| 118 | rte_errno != EINVAL) { |
| 119 | printf("%s():%i: Removed memory from heap with invalid name\n", |
| 120 | __func__, __LINE__); |
| 121 | goto fail; |
| 122 | } |
| 123 | |
| 124 | if (rte_malloc_heap_memory_attach(name, addr, len) >= 0 || |
| 125 | rte_errno != EINVAL) { |
| 126 | printf("%s():%i: Attached memory to heap with invalid name\n", |
| 127 | __func__, __LINE__); |
| 128 | goto fail; |
| 129 | } |
| 130 | if (rte_malloc_heap_memory_detach(name, addr, len) >= 0 || |
| 131 | rte_errno != EINVAL) { |
| 132 | printf("%s():%i: Detached memory from heap with invalid name\n", |
no test coverage detected