diff --git a/.travis.yml b/.travis.yml index c5ccd563..749e4e24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,11 +20,7 @@ before_install: matrix: include: - compiler: clang - env: CUSTOM_ALLOC=ON - - compiler: clang - env: CUSTOM_ALLOC=OFF - compiler: gcc - env: CUSTOM_ALLOC=OFF script: - export SOURCE=$(pwd) && ./buildscript.sh diff --git a/buildscript.sh b/buildscript.sh index 7ddc5172..b4f29aa0 100755 --- a/buildscript.sh +++ b/buildscript.sh @@ -6,7 +6,7 @@ cd $SOURCE cppcheck . --error-exitcode=1 --suppressions cppcheck_suppressions.txt --force cd $PREVD -cmake $SOURCE -DCUSTOM_ALLOC=$CUSTOM_ALLOC -DCMAKE_BUILD_TYPE=Debug +cmake $SOURCE -DCUSTOM_ALLOC=ON -DCMAKE_BUILD_TYPE=Debug make VERBOSE=1 ctest -V diff --git a/test/fuzz_test.c b/test/fuzz_test.c index 60494379..1a2c8610 100644 --- a/test/fuzz_test.c +++ b/test/fuzz_test.c @@ -38,6 +38,16 @@ static void printmem(const unsigned char * ptr, size_t length) unsigned seed; +#ifdef CBOR_CUSTOM_ALLOC +void *mock_malloc(size_t size) +{ + if (size > (1 << 19)) + return NULL; + else + return malloc(size); +} +#endif + static void run_round() { cbor_item_t *item; @@ -64,6 +74,10 @@ static void run_round() static void fuzz(void **state) { + +#ifdef CBOR_CUSTOM_ALLOC + cbor_set_allocs(mock_malloc, realloc, free); +#endif printf( "Fuzzing %llu rounds of up to %llu bytes with seed %u\n", ROUNDS,