blob: c58c0c306aca1ab3c611daf1814659ab1bfd3852 [file] [log] [blame]
/*
* Copyright (c) 2016, 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <ztest.h>
#include "test_mheap.h"
/* request 0 bytes*/
#define TEST_SIZE_0 0
/*test cases*/
/**
* @brief The test validates k_calloc() API.
*
* @ingroup kernel_heap_tests
*
* @details The 8 blocks of memory of size 16 bytes are allocated
* by k_calloc() API. When allocated using k_calloc() the memory buffers
* have to be zeroed. Check is done, if the blocks are memset to 0 and
* read/write is allowed. The test is then teared up by freeing all the
* blocks allocated.
*
* @see k_malloc(), k_free()
*/
void test_mheap_malloc_align4(void)
{
void *block[BLK_NUM_MAX];
/**
* TESTPOINT: The address of the allocated chunk is guaranteed to be
* aligned on a word boundary (4 or 8 bytes).
*/
for (int i = 0; i < BLK_NUM_MAX; i++) {
block[i] = k_malloc(i);
zassert_not_null(block[i], NULL);
zassert_false((uintptr_t)block[i] % sizeof(void *), NULL);
}
/* test case tear down*/
for (int i = 0; i < BLK_NUM_MAX; i++) {
k_free(block[i]);
}
}