test: improve compatibility for malloc

The C header file malloc.h does not exist on
some Xtensa processor configurations or host OSes,
include stdlib.h instead because they both provide
the prototype for 'malloc' function.

Fixes: #5102

Signed-off-by: Chao Song <chao.song@linux.intel.com>
This commit is contained in:
Chao Song 2021-12-23 14:50:23 +08:00 committed by Liam Girdwood
parent 37ce03fbd9
commit b673d4a3e2
8 changed files with 49 additions and 9 deletions

View File

@ -6,11 +6,16 @@
#include <stdint.h>
#include <stddef.h>
#include <malloc.h>
#include <sof/list.h>
#include <sof/audio/stream.h>
#include <sof/audio/component.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include "comp_mock.h"
static struct comp_dev *mock_comp_new(const struct comp_driver *drv,

View File

@ -9,7 +9,6 @@
#include <math.h>
#include <setjmp.h>
#include <stdint.h>
#include <malloc.h>
#include <cmocka.h>
#include <sof/list.h>
#include <sof/ipc/driver.h>
@ -21,6 +20,12 @@
#include <sof/audio/format.h>
#include <sof/audio/mixer.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include "comp_mock.h"
#define MIX_TEST_SAMPLES 32

View File

@ -16,10 +16,15 @@
#include <stddef.h>
#include <setjmp.h>
#include <math.h>
#include <malloc.h>
#include <stdint.h>
#include <cmocka.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include "../../util.h"
/* used during float assertions */

View File

@ -12,9 +12,14 @@
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>
#include <malloc.h>
#include <cmocka.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#define PIPELINE_ID_SAME 3
#define PIPELINE_ID_DIFFERENT 4

View File

@ -14,9 +14,14 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <malloc.h>
#include <cmocka.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
/* mock free() - dont free as we inspect contents */
void rfree(void *ptr)
{

View File

@ -12,9 +12,14 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <malloc.h>
#include <cmocka.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
static int setup(void **state)
{
struct pipeline_new_setup_data *pipeline_data = malloc(

View File

@ -10,9 +10,14 @@
#include <stdarg.h>
#include <setjmp.h>
#include <stdint.h>
#include <malloc.h>
#include <cmocka.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include <sof/trace/preproc.h>
#include <sof/sof.h>
#include <sof/trace/trace.h>
@ -46,7 +51,7 @@ static void test_debugability_macros_declare_log_entry(void **state)
"1"
"0"
"1"
"31"
"36"
"sizeof(\"" RELATIVE_FILE "\")"
"sizeof(\"Message\")"
"\"" RELATIVE_FILE "\""

View File

@ -11,9 +11,14 @@
#include <setjmp.h>
#include <stdint.h>
#include <stdlib.h>
#include <malloc.h>
#include <cmocka.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include <test_group_generator.h>
struct test_data_t {