mirror of https://gerrit.osmocom.org/libosmocore
bssgp_fc_test: sanitizer: free msgb context when done
Print remaining msgbs when done, then free the entire tall_msgb_context. To be able to do that, call msgb_talloc_ctx_init() and use its return value. A subsequent patch will fix a known mem leak and add assertions for 0b in 1 blocks remaining in the tall_msgb_context. Helps fix sanitizer build on debian 9. Change-Id: I67d347ab2642b0bfc27b21b44231a7f3146ff641
This commit is contained in:
parent
9541a68378
commit
0128c78ffe
|
@ -130,6 +130,7 @@ int main(int argc, char **argv)
|
||||||
uint32_t pdu_length = 10; /* octets */
|
uint32_t pdu_length = 10; /* octets */
|
||||||
uint32_t pdu_count = 20; /* messages */
|
uint32_t pdu_count = 20; /* messages */
|
||||||
int c;
|
int c;
|
||||||
|
void *tall_msgb_ctx;
|
||||||
|
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "bucket-size-max", 1, 0, 's' },
|
{ "bucket-size-max", 1, 0, 's' },
|
||||||
|
@ -145,6 +146,8 @@ int main(int argc, char **argv)
|
||||||
log_set_use_color(osmo_stderr_target, 0);
|
log_set_use_color(osmo_stderr_target, 0);
|
||||||
log_set_print_filename(osmo_stderr_target, 0);
|
log_set_print_filename(osmo_stderr_target, 0);
|
||||||
|
|
||||||
|
tall_msgb_ctx = msgb_talloc_ctx_init(NULL, 0);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "s:r:d:l:c:",
|
while ((c = getopt_long(argc, argv, "s:r:d:l:c:",
|
||||||
long_options, NULL)) != -1) {
|
long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -184,6 +187,11 @@ int main(int argc, char **argv)
|
||||||
bucket_leak_rate, max_queue_depth, pdu_length, pdu_count);
|
bucket_leak_rate, max_queue_depth, pdu_length, pdu_count);
|
||||||
test_fc(bucket_size_max, bucket_leak_rate, max_queue_depth,
|
test_fc(bucket_size_max, bucket_leak_rate, max_queue_depth,
|
||||||
pdu_length, pdu_count);
|
pdu_length, pdu_count);
|
||||||
|
printf("msgb ctx: %zu b in %zu blocks (0 b in 1 block == just the context)\n",
|
||||||
|
talloc_total_size(tall_msgb_ctx),
|
||||||
|
talloc_total_blocks(tall_msgb_ctx));
|
||||||
|
/* KNOWN BUG: expecting 0b in 1 block, but a full queue is still a mem leak */
|
||||||
|
talloc_free(tall_msgb_ctx);
|
||||||
printf("===== BSSGP flow-control test END\n\n");
|
printf("===== BSSGP flow-control test END\n\n");
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
|
@ -56,6 +56,7 @@ size-max=100 oct, leak-rate=100 oct/s, queue-len=5 msgs, pdu_len=10 oct, pdu_cnt
|
||||||
30: FC OUT Nr 13
|
30: FC OUT Nr 13
|
||||||
40: FC OUT Nr 14
|
40: FC OUT Nr 14
|
||||||
50: FC OUT Nr 15
|
50: FC OUT Nr 15
|
||||||
|
msgb ctx: 685 b in 6 blocks (0 b in 1 block == just the context)
|
||||||
===== BSSGP flow-control test END
|
===== BSSGP flow-control test END
|
||||||
|
|
||||||
===== BSSGP flow-control test START
|
===== BSSGP flow-control test START
|
||||||
|
@ -121,6 +122,7 @@ size-max=100 oct, leak-rate=100 oct/s, queue-len=100 msgs, pdu_len=10 oct, pdu_c
|
||||||
80: FC OUT Nr 18
|
80: FC OUT Nr 18
|
||||||
90: FC OUT Nr 19
|
90: FC OUT Nr 19
|
||||||
100: FC OUT Nr 20
|
100: FC OUT Nr 20
|
||||||
|
msgb ctx: 0 b in 1 blocks (0 b in 1 block == just the context)
|
||||||
===== BSSGP flow-control test END
|
===== BSSGP flow-control test END
|
||||||
|
|
||||||
===== BSSGP flow-control test START
|
===== BSSGP flow-control test START
|
||||||
|
@ -166,6 +168,7 @@ size-max=100 oct, leak-rate=100 oct/s, queue-len=5 msgs, pdu_len=1000 oct, pdu_c
|
||||||
-> -5: PDU too large, msg dropped.
|
-> -5: PDU too large, msg dropped.
|
||||||
0: FC IN Nr 20
|
0: FC IN Nr 20
|
||||||
-> -5: PDU too large, msg dropped.
|
-> -5: PDU too large, msg dropped.
|
||||||
|
msgb ctx: 0 b in 1 blocks (0 b in 1 block == just the context)
|
||||||
===== BSSGP flow-control test END
|
===== BSSGP flow-control test END
|
||||||
|
|
||||||
===== BSSGP flow-control test START
|
===== BSSGP flow-control test START
|
||||||
|
@ -226,5 +229,6 @@ size-max=100 oct, leak-rate=100 oct/s, queue-len=5 msgs, pdu_len=10 oct, pdu_cnt
|
||||||
30: FC OUT Nr 13
|
30: FC OUT Nr 13
|
||||||
40: FC OUT Nr 14
|
40: FC OUT Nr 14
|
||||||
50: FC OUT Nr 15
|
50: FC OUT Nr 15
|
||||||
|
msgb ctx: 685 b in 6 blocks (0 b in 1 block == just the context)
|
||||||
===== BSSGP flow-control test END
|
===== BSSGP flow-control test END
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue