7#include "porting_assistant.h"
15 "Failed to allocate 1560 bytes. Check that your heap is configured correctly\n\n");
26 FIRST_ALLOCATION_SIZE = 100,
27 REALLOCATION_SIZE = 200,
34 "Failed to allocate %d bytes. Check that your heap is configured correctly\n\n",
35 FIRST_ALLOCATION_SIZE);
36 return TEST_FAILED_NON_CRITICAL;
38 memset(
buf, 0xc0, FIRST_ALLOCATION_SIZE);
44 "Failed to reallocate %d bytes. Check that your heap supports realloc\n\n",
46 return TEST_FAILED_NON_CRITICAL;
51 for (ii = 0; ii < FIRST_ALLOCATION_SIZE; ii++)
56 "Reallocated block contents mismatch at offset %u\n\n", ii);
57 return TEST_FAILED_NON_CRITICAL;
71 int32_t delta = (int32_t)(end_time - start_time);
72 if (delta < 49 || delta > 51)
75 "Time delta (%ld ms) did not match sleep time (50 ms)\n\n", delta);
89 TASK_ERROR_GET_ACTIVE_INVALID,
93static volatile enum task_state task_state = TASK_NOT_STARTED;
95static struct mmosal_task *
volatile task_handle;
98static void new_task_main(
void *arg)
102 task_state = TASK_STARTED;
110 task_state = TASK_ERROR_GET_ACTIVE_INVALID;
114 task_state = TASK_TERMINATING;
124 if (task_handle == NULL)
127 "mmosal_task_create() returned NULL; expected a task handle.\n\n");
128 return TEST_FAILED_NON_CRITICAL;
135 if (task_state != TASK_STARTED)
138 "The task created with mmosal_task_create() did not run.\n\n");
139 return TEST_FAILED_NON_CRITICAL;
147 case TASK_TERMINATING:
150 case TASK_ERROR_GET_ACTIVE_INVALID:
152 "mmosal_task_get_active() did not return the correct task handle.\n\n");
153 return TEST_FAILED_NON_CRITICAL;
157 "Task in unexpected state %d.\n\n", task_state);
158 return TEST_FAILED_NON_CRITICAL;
#define mmosal_malloc(size)
Allocate memory of the given size and return a pointer to it (malloc).
void mmosal_free(void *p)
Free the given memory allocation.
void * mmosal_realloc(void *ptr, size_t size)
Equivalent of standard library realloc().
struct mmosal_task * mmosal_task_create(mmosal_task_fn_t task_fn, void *argument, enum mmosal_task_priority priority, unsigned stack_size_u32, const char *name)
Create a new task.
struct mmosal_task * mmosal_task_get_active(void)
Get the handle of the active task.
void mmosal_task_sleep(uint32_t duration_ms)
Sleep for a period of time, yielding during that time.
void mmosal_task_delete(struct mmosal_task *task)
Delete the given task.
@ MMOSAL_TASK_PRI_HIGH
High priority.
uint32_t mmosal_get_time_ms(void)
Get the system time in milliseconds.
const struct test_step test_step_os_malloc
Test definition.
const struct test_step test_step_os_realloc
Test definition.
const struct test_step test_step_os_time
Test definition.
const struct test_step test_step_os_task_creation
Test definition.
char buf[1408]
Statically allocated buffer for HTTP GET request, just under 1 packet size.