From ad8e69da9683b75d82997ff298cee5bd75bcc1f5 Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Fri, 13 Apr 2018 17:35:55 +0200 Subject: [PATCH] pkg/cn-cbor: compile with context pointer support --- pkg/cn-cbor/Makefile.include | 3 +++ tests/unittests/tests-cn_cbor/tests-cn_cbor.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/cn-cbor/Makefile.include b/pkg/cn-cbor/Makefile.include index bb736000ee..026202fe34 100644 --- a/pkg/cn-cbor/Makefile.include +++ b/pkg/cn-cbor/Makefile.include @@ -1 +1,4 @@ INCLUDES += -I$(PKGDIRBASE)/cn-cbor/include + +#enable context pointer +CFLAGS += -DUSE_CBOR_CONTEXT diff --git a/tests/unittests/tests-cn_cbor/tests-cn_cbor.c b/tests/unittests/tests-cn_cbor/tests-cn_cbor.c index ce00ab8796..0dff8b08ae 100644 --- a/tests/unittests/tests-cn_cbor/tests-cn_cbor.c +++ b/tests/unittests/tests-cn_cbor/tests-cn_cbor.c @@ -36,6 +36,14 @@ static size_t test, offs; static unsigned char ebuf[EBUF_SIZE]; static cn_cbor_errback errb; +/* Dummy context struct to force fallback to POSIX calloc/free */ +static cn_cbor_context ct = +{ + NULL, + NULL, + NULL, +}; + static void setup_cn_cbor(void) { test = 0; @@ -107,7 +115,7 @@ static void test_parse(void) errb.err = CN_CBOR_NO_ERROR; - cn_cbor *cbor = cn_cbor_decode(buf, len, &errb); + cn_cbor *cbor = cn_cbor_decode(buf, len, &ct, &errb); TEST_ASSERT_EQUAL_INT(errb.err, CN_CBOR_NO_ERROR); TEST_ASSERT_NOT_NULL(cbor); @@ -143,7 +151,7 @@ static void test_errors(void) size_t len = fmt_hex_bytes(buf, tests[offs].hex); TEST_ASSERT(len); - cn_cbor *cbor = cn_cbor_decode(buf, len, &errb); + cn_cbor *cbor = cn_cbor_decode(buf, len, &ct, &errb); TEST_ASSERT_NULL(cbor); TEST_ASSERT_EQUAL_INT(errb.err, tests[offs].err); cn_cbor_free(cbor);