| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include "librist/librist.h" |
| 8 |
#include "librist/peer.h" |
| 9 |
|
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
#include <string.h> |
| 13 |
|
| 14 |
static int expect_priority(const char *url, uint32_t want) |
| 15 |
{ |
| 16 |
struct rist_peer_config *cfg = NULL; |
| 17 |
int ret = rist_parse_address2(url, &cfg); |
| 18 |
if (ret != 0 || cfg == NULL) { |
| 19 |
fprintf(stderr, |
| 20 |
"FAIL: rist_parse_address2(%s) ret=%d cfg=%p\n", |
| 21 |
url, ret, (void *)cfg); |
| 22 |
if (cfg) |
| 23 |
rist_peer_config_free2(&cfg); |
| 24 |
return 1; |
| 25 |
} |
| 26 |
if (cfg->recovery_priority != want) { |
| 27 |
fprintf(stderr, |
| 28 |
"FAIL: %s -> recovery_priority=%u (want %u)\n", |
| 29 |
url, cfg->recovery_priority, want); |
| 30 |
rist_peer_config_free2(&cfg); |
| 31 |
return 1; |
| 32 |
} |
| 33 |
rist_peer_config_free2(&cfg); |
| 34 |
return 0; |
| 35 |
} |
| 36 |
|
| 37 |
int main(void) |
| 38 |
{ |
| 39 |
int failures = 0; |
| 40 |
|
| 41 |
|
| 42 |
failures += expect_priority( |
| 43 |
"rist://@127.0.0.1:1234", |
| 44 |
RIST_DEFAULT_RECOVERY_PRIORITY); |
| 45 |
|
| 46 |
failures += expect_priority( |
| 47 |
"rist://@127.0.0.1:1234?recovery-priority=0", 0); |
| 48 |
failures += expect_priority( |
| 49 |
"rist://@127.0.0.1:1234?recovery-priority=1", 1); |
| 50 |
failures += expect_priority( |
| 51 |
"rist://@127.0.0.1:1234?recovery-priority=1000", 1000); |
| 52 |
|
| 53 |
|
| 54 |
failures += expect_priority( |
| 55 |
"rist://@127.0.0.1:1234?weight=1000&recovery-priority=5", 5); |
| 56 |
failures += expect_priority( |
| 57 |
"rist://@127.0.0.1:1234?recovery-priority=5&buffer=100", 5); |
| 58 |
|
| 59 |
|
| 60 |
failures += expect_priority( |
| 61 |
"rist://@127.0.0.1:1234?recovery-priority=-1", |
| 62 |
RIST_DEFAULT_RECOVERY_PRIORITY); |
| 63 |
|
| 64 |
if (failures == 0) { |
| 65 |
printf("OK\n"); |
| 66 |
return 0; |
| 67 |
} |
| 68 |
fprintf(stderr, "Total failures: %d\n", failures); |
| 69 |
return 1; |
| 70 |
} |