GET tests
| 2 | |
| 3 | // GET tests |
| 4 | static int test1() |
| 5 | { |
| 6 | int retcode; |
| 7 | // Normal get |
| 8 | char cookie[HAMLIB_COOKIE_SIZE]; |
| 9 | retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, sizeof(cookie)); |
| 10 | |
| 11 | if (retcode == RIG_OK) { printf("Test#1a OK\n"); } |
| 12 | else {printf("Test#1a Failed\n"); return 1;} |
| 13 | |
| 14 | // Should be able to release and get it right back |
| 15 | rig_cookie(NULL, RIG_COOKIE_RELEASE, cookie, sizeof(cookie)); |
| 16 | retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, sizeof(cookie)); |
| 17 | |
| 18 | if (retcode == RIG_OK) { printf("Test#1b OK\n"); } |
| 19 | else {printf("Test#1b Failed\n"); return 1;} |
| 20 | |
| 21 | |
| 22 | // Doing a get when another cookie is active should fail |
| 23 | char cookie2[HAMLIB_COOKIE_SIZE]; |
| 24 | cookie2[0] = 0; |
| 25 | retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie2, sizeof(cookie2)); |
| 26 | |
| 27 | if (retcode == RIG_OK) { printf("Test#1c OK\n"); } |
| 28 | else {printf("Test#1c Failed\n"); return 1;} |
| 29 | |
| 30 | #if 0 |
| 31 | // after 1 second we should be able to get a cookie |
| 32 | // this means the cookie holder did not renew within 1 second |
| 33 | hl_usleep(1500 * 1000); // after 1 second we should be able to get a cookie |
| 34 | |
| 35 | retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie2, sizeof(cookie2)); |
| 36 | |
| 37 | if (retcode == RIG_OK) { printf("Test#1d OK\n"); } |
| 38 | else {printf("Test#1d Failed\n"); return 1;} |
| 39 | |
| 40 | #endif |
| 41 | |
| 42 | retcode = rig_cookie(NULL, RIG_COOKIE_RELEASE, cookie2, sizeof(cookie2)); |
| 43 | |
| 44 | if (retcode == RIG_OK) { printf("Test#1e OK\n"); } |
| 45 | else {printf("Test#1e Failed\n"); return 1;} |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | // RENEW tests |
| 51 | static int test2() |
no test coverage detected