Commit Graph

12 Commits

Author SHA1 Message Date
Neels Hofmeyr a829b45c85 use osmo_init_logging2() with proper talloc ctx
Ironically, when deprecating osmo_init_logging() in
I216837780e9405fdaec8059c63d10699c695b360, I forgot to change the callers
within libosmocore itself, i.e. in the various regression tests.

Change-Id: Ia36c248f99353d5baaa2533f46a2f60a8579bdf8
2018-04-06 04:37:50 +02:00
Neels Hofmeyr 85f5a2cd9c bssgp_fc_test: sanitize: free fc struct when done
Helps fix sanitizer build on debian 9.

Change-Id: I0ef95ee8185a4789f0732b9420243dda5104d181
2017-11-20 17:22:42 +01:00
Neels Hofmeyr cd325efae5 gprs_bssgp: bssgp_fc_in(): fix mem leak on queue overflow
All successful and all error code paths of bssgp_fc_in() free the msgb, except
the code path calling fc_enqueue() when the msg is dropped (due to queue being
full, or failure to allocate).

Callers could theoretically catch the -ENOSPC return value and discard the
msgb. However, in other code paths, a callback's return value is returned,
which is expected to free the msgb, so such callback would have to never return
-ENOSPC when it freed the msgb. Much simpler semantics would be to free the
msgb in every code path, no matter which kind of error occurred.

Who is currently calling bssgp_fc_in and how do they handle the return value?
- bssgp_fc_test.c ignores the return value (and hits a mem leak aka sanitizer
  build failure if the queue is full).
- fc_timer_cb() ignores the return value.
- bssgp_tx_dl_ud() returns the bssgp_fc_in() rc.
  - which is returned by a cascade of functions leading up to being returned,
    for example, by gprs_llgmm_reset(), which is usually called with ignored
    return code.
At this point it is already fairly clear that bssgp_fc_in() should always free
the msgb, since the callers don't seem to distinguish even between error or
success, let alone between -ENOSPC or other errors.

bssgp_fc_test: assert that no msgbs remain unfreed after the tests.
Adjust expected results.

Helps fix sanitizer build on debian 9.

Change-Id: I00c62a104baeaad6a85883c380259c469aebf0df
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 0128c78ffe 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
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 9541a68378 bssgp_fc_test: clarify by outputting ok / failure messages
The test fills up the queue / sends too large PDUs on purpose. Make that
obvious by outputting returned errors in the expected output.

Cosmetic:
- fc_in()'s return value is ignored, hence don't return anything.
- add comment.

Change-Id: I57d6fce2515a65f6dd037e75af5397079215cb46
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 568f8e2017 bssgp_fc_test: remove rounding to deciseconds
Ever since this test was changed to use osmo_gettimeofday_override, the times
it sees are exact every time and don't need rounding to pass the expected
output.

Change-Id: I4a9a5d31fc02eb55caf7ba9c141426d8115bb740
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 7132011afa bssgp_fc_test: do not use real time
Employ osmo_gettimeofday_override_* to take bssgp_fc_test off real time. The
jenkins build slave often failed the test based on sporadic time delays due to
server load and randomly rejected good patches. This patch ends that.

Change-Id: Ie5029b85c2a154554d75d7f9af49a3b93425fdd9
Related: OS#1809
2017-02-07 00:39:54 +00:00
Neels Hofmeyr 8e2f7e87f4 add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.

Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-09-22 07:18:39 +02:00
Holger Hans Peter Freyther 10dd73cf6a bssgp: Free msgb in case of error when calling into gprs_ns_sendmsg
In the OsmoSGSN we have a crash with a DEAD/BLOCKED GPRS-NS and
segmented SN-UNITDATA. For the caller it is not easy to know if
the passed msg buffer has been freed or not. The most easy solution
is to always take the ownership and either pass it on or free it
in case of an error.

Adjust indirect and direct callers of gprs_ns_sendmsg. I found
the following call-chains with an external msgb parameter.

gprs_ns_sendmsg
  <- _bssgp_tx_dl_ud
     <- bssgp_fc_in
        <- bssgp_tx_dl_ud

Update the test to allocate a real msgb because for the test with
'1000' we will msgb_free it right away.

Sponsored-by: On-Waves ehf
2014-10-10 17:55:13 +02:00
Holger Hans Peter Freyther 5b6416a729 bssgp: Address various compiler warnings in the bssgp code
gb/bssgp_fc_test.c: In function ‘fc_out_cb’:
gb/bssgp_fc_test.c:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
gb/bssgp_fc_test.c: In function ‘fc_in’:
gb/bssgp_fc_test.c:56:1: warning: no return statement in function returning non-void [-Wreturn-type]
gb/bssgp_fc_test.c: In function ‘test_fc’:
gb/bssgp_fc_test.c:79:3: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]
2013-09-16 14:13:25 +02:00
Holger Hans Peter Freyther c302eca2c6 tests: Make the gb test work with srcdir != builddir
* Disable color and printing the filename of the stderr log target,
  update the results
* Add the .ok, .err and .sh files to the extra_dist
* Execute the shell script from the source directory
2012-09-11 11:49:35 +02:00
Harald Welte 57e5b94e90 BSSGP flow-control: Add unit test for algorithm tests 2012-09-07 12:07:54 +02:00