wasm-micro-runtime/tests/unit/mem-alloc/test_runner.c
liang.he@intel.com 779edfa277 feat(api): expose aligned allocation through wasm_runtime_aligned_alloc
Add public API for aligned memory allocation, exposing the existing
mem_allocator_malloc_aligned infrastructure through wasm_export.h.

- Add wasm_runtime_aligned_alloc() API declaration with documentation
- Implement internal helper wasm_runtime_aligned_alloc_internal()
- Add public function with size/alignment validation
- POOL mode only, returns NULL for other memory modes
- Follows wasm_runtime_malloc() patterns for consistency

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-16 09:00:06 +08:00

39 lines
1.4 KiB
C

/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>
#include <cmocka.h>
/* Include test implementations */
#include "mem_alloc_test.c"
int
main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_normal_alloc_basic),
cmocka_unit_test(test_aligned_alloc_valid_alignments),
cmocka_unit_test(test_realloc_rejects_aligned),
cmocka_unit_test(test_normal_realloc_works),
cmocka_unit_test(test_aligned_alloc_invalid_not_power_of_2),
cmocka_unit_test(test_aligned_alloc_size_not_multiple),
cmocka_unit_test(test_mixed_alloc_interleaved),
cmocka_unit_test(test_mixed_obj_to_hmu),
cmocka_unit_test(test_aligned_alloc_many),
cmocka_unit_test(test_mixed_alloc_many),
cmocka_unit_test(test_wasm_runtime_aligned_alloc_valid),
cmocka_unit_test(test_wasm_runtime_aligned_alloc_zero_size),
cmocka_unit_test(test_wasm_runtime_aligned_alloc_zero_alignment),
cmocka_unit_test(test_wasm_runtime_aligned_alloc_system_mode),
cmocka_unit_test(test_wasm_runtime_realloc_rejects_aligned),
cmocka_unit_test(test_wasm_runtime_aligned_alloc_multiple_alignments),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}