| 879 | } |
| 880 | |
| 881 | static int |
| 882 | test_malloc_bad_params(void) |
| 883 | { |
| 884 | const char *type = NULL; |
| 885 | size_t size = 0; |
| 886 | unsigned align = RTE_CACHE_LINE_SIZE; |
| 887 | |
| 888 | /* rte_malloc expected to return null with inappropriate size */ |
| 889 | char *bad_ptr = rte_malloc(type, size, align); |
| 890 | if (bad_ptr != NULL) |
| 891 | goto err_return; |
| 892 | |
| 893 | /* rte_realloc expected to return null with inappropriate size */ |
| 894 | bad_ptr = rte_realloc(NULL, size, align); |
| 895 | if (bad_ptr != NULL) |
| 896 | goto err_return; |
| 897 | |
| 898 | /* rte_malloc expected to return null with inappropriate alignment */ |
| 899 | align = 17; |
| 900 | size = 1024; |
| 901 | |
| 902 | bad_ptr = rte_malloc(type, size, align); |
| 903 | if (bad_ptr != NULL) |
| 904 | goto err_return; |
| 905 | |
| 906 | /* rte_realloc expected to return null with inappropriate alignment */ |
| 907 | bad_ptr = rte_realloc(NULL, size, align); |
| 908 | if (bad_ptr != NULL) |
| 909 | goto err_return; |
| 910 | |
| 911 | #if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG) |
| 912 | /* this test can not be built, will get trapped at compile time! */ |
| 913 | #else |
| 914 | /* rte_malloc expected to return null with size will cause overflow */ |
| 915 | align = RTE_CACHE_LINE_SIZE; |
| 916 | size = (size_t)-8; |
| 917 | |
| 918 | bad_ptr = rte_malloc(type, size, align); |
| 919 | if (bad_ptr != NULL) |
| 920 | goto err_return; |
| 921 | |
| 922 | bad_ptr = rte_realloc(NULL, size, align); |
| 923 | if (bad_ptr != NULL) |
| 924 | goto err_return; |
| 925 | #endif |
| 926 | return 0; |
| 927 | |
| 928 | err_return: |
| 929 | /* clean up pointer */ |
| 930 | rte_free(bad_ptr); |
| 931 | return -1; |
| 932 | } |
| 933 | |
| 934 | static int |
| 935 | check_socket_mem(const struct rte_memseg_list *msl, void *arg) |
no test coverage detected