1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ssrc.h"
#include "main.h"
#include "statistics.h"
struct rtpengine_config rtpe_config;
struct global_stats_gauge rtpe_stats_gauge;
struct global_gauge_min_max rtpe_gauge_min_max;
struct global_stats_counter *rtpe_stats;
struct global_stats_counter rtpe_stats_rate;
struct global_stats_counter rtpe_stats_intv;
struct global_stats_sampled rtpe_stats_sampled;
struct global_sampled_min_max rtpe_sampled_min_max;
struct global_sampled_min_max rtpe_sampled_graphite_min_max;
struct global_sampled_min_max rtpe_sampled_graphite_min_max_sampled;
__thread struct bufferpool *media_bufferpool;
void append_thread_lpr_to_glob_lpr(void) {}
struct bufferpool *shm_bufferpool;
static void most_cmp(struct payload_tracker *t, const char *cmp, const char *file, int line) {
char buf[1024] = "";
int len = 0;
for (int i = 0; i < t->most_len; i++) {
if (i > 0)
len += sprintf(buf+len, ",");
len += sprintf(buf+len, "%u", t->most[i]);
}
if (strcmp(buf, cmp)) {
printf("test nok: %s:%i\n", file, line);
printf("expected: %s\n", cmp);
printf("got: %s\n", buf);
abort();
}
printf("test ok: %s:%i\n", file, line);
}
#define cmp(s) most_cmp(&t, s, __FILE__, __LINE__)
#define add(p) payload_tracker_add(&t, p)
int main(void) {
struct payload_tracker t;
payload_tracker_init(&t);
cmp("");
add(0);
cmp("0");
add(0);
add(0);
cmp("0");
add(5);
cmp("0,5");
add(5);
add(5);
cmp("0,5");
add(5);
cmp("5,0");
add(0);
cmp("5,0");
add(0);
cmp("0,5");
add(120);
cmp("0,5,120");
add(120);
add(120);
add(120);
add(120);
cmp("0,120,5");
add(120);
cmp("120,0,5");
add(120);
add(120);
add(120);
cmp("120,0,5");
add(5);
add(5);
cmp("120,5,0");
// saturation fill test
for (int i = 0; i < 32; i++)
add(10);
cmp("10,5,120,0");
// bubble up all the way
for (int i = 0; i < 32; i++)
add(0);
cmp("0,10,5,120");
// filled with 0s, so a single 1 goes in second place
add(1);
cmp("0,1,10,5,120");
payload_tracker_init(&t);
for (int i = 0; i < 32; i++)
add(8);
cmp("8");
add(96);
add(96);
add(96);
cmp("8,96");
add(96);
add(96);
add(96);
add(96);
add(96);
add(96);
add(96);
cmp("8,96");
for (int i = 0; i < 32; i++)
add(8);
cmp("8,96");
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
cmp("8,100,96");
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
add(100);
cmp("100,8,96");
return 0;
}
int get_local_log_level(unsigned int u) {
return -1;
}
|