summaryrefslogtreecommitdiffstats
path: root/tests/msgb/msgb_test.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-11-27 13:26:20 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-15 18:12:49 +0100
commit17b3c3aca1290a3f2c20a0858d4d499a17752ced (patch)
treee5d0986a9e24e9ebdbb4481281f3020b415720b4 /tests/msgb/msgb_test.c
parentff42b26520a7421a6c6c9c9cd4b88aed00453b01 (diff)
msgb/test: Add test case for error cases
Include a test for msgb_trim. Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests/msgb/msgb_test.c')
-rw-r--r--tests/msgb/msgb_test.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/msgb/msgb_test.c b/tests/msgb/msgb_test.c
index e6cb33ec..8839a2ed 100644
--- a/tests/msgb/msgb_test.c
+++ b/tests/msgb/msgb_test.c
@@ -121,6 +121,27 @@ static void test_msgb_api()
msgb_free(msg);
}
+static void test_msgb_api_errors()
+{
+ struct msgb *msg = msgb_alloc_headroom(4096, 128, "data");
+ volatile int e = 0;
+ int rc;
+
+ printf("Testing the msgb API error handling\n");
+
+ osmo_set_panic_handler(osmo_panic_raise);
+
+ if (OSMO_PANIC_TRY(&e))
+ msgb_trim(msg, -1);
+ OSMO_ASSERT(e != 0);
+
+ rc = msgb_trim(msg, 4096 + 500);
+ OSMO_ASSERT(rc == -1);
+
+ msgb_free(msg);
+ osmo_set_panic_handler(NULL);
+}
+
static void test_msgb_copy()
{
struct msgb *msg = msgb_alloc_headroom(4096, 128, "data");
@@ -263,6 +284,7 @@ int main(int argc, char **argv)
osmo_init_logging(&info);
test_msgb_api();
+ test_msgb_api_errors();
test_msgb_copy();
test_msgb_resize_area();