Input sanity checks
| 86 | |
| 87 | // Input sanity checks |
| 88 | static int test3_invalid_input() |
| 89 | { |
| 90 | int retcode; |
| 91 | char cookie[HAMLIB_COOKIE_SIZE]; |
| 92 | int n = 0; |
| 93 | |
| 94 | /* Make sure any value smaller than HAMLIB_COOKIE_SIZE is rejected */ |
| 95 | for (unsigned int i = 0; i < HAMLIB_COOKIE_SIZE; i++) |
| 96 | { |
| 97 | retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, i); |
| 98 | |
| 99 | if (retcode != -RIG_EINVAL) { n++; printf("Test#3a failed at %u bytes\n", i); } |
| 100 | } |
| 101 | |
| 102 | if (n == 0) { printf("Test#3a OK\n"); } |
| 103 | |
| 104 | /* Make sure a NULL cookie is ignored */ |
| 105 | retcode = rig_cookie(NULL, RIG_COOKIE_GET, NULL, sizeof(cookie)); |
| 106 | |
| 107 | if (retcode == -RIG_EINVAL) { printf("Test#3b OK\n"); } |
| 108 | else {printf("Test#3b Failed\n"); return 1;} |
| 109 | |
| 110 | /* Make sure an invalid command is dropped with proto error */ |
| 111 | retcode = rig_cookie(NULL, RIG_COOKIE_RENEW + 1, cookie, sizeof(cookie)); |
| 112 | |
| 113 | if (retcode == -RIG_EPROTO) { printf("Test#3c OK\n"); } |
| 114 | else {printf("Test#3c Failed\n"); return 1;} |
| 115 | |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | static int test4_large_cookie_size() |
| 120 | { |