From 35ad4e86326d21db41f1e19b71857baa7612778d Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 1 Sep 2020 13:56:11 +0200 Subject: [PATCH] tests: lib: cmsis_dsp: matrix: binary_q15 reorder test to fit 128k ram tests/lib/cmsis_dsp/matrix/ with config: * libraries.cmsis_dsp.matrix.binary_q15 128k is sufficient if tests steps are reordered, otherwise system run out of memory. Biggest chunk first for better malloc chunk reusability. Tested on nucleo_f207zg Signed-off-by: Alexandre Bourdiol --- tests/lib/cmsis_dsp/matrix/src/binary_q15.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/lib/cmsis_dsp/matrix/src/binary_q15.c b/tests/lib/cmsis_dsp/matrix/src/binary_q15.c index e0d64df9e5f..4314db73119 100644 --- a/tests/lib/cmsis_dsp/matrix/src/binary_q15.c +++ b/tests/lib/cmsis_dsp/matrix/src/binary_q15.c @@ -38,6 +38,9 @@ static void test_op2(int op, const q15_t *input1, const q15_t *input2, arm_matrix_instance_q15 mat_out; /* Allocate buffers */ + output = malloc(length * sizeof(q15_t)); + zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED); + tmp1 = malloc(MAX_MATRIX_DIM * MAX_MATRIX_DIM * sizeof(q15_t)); zassert_not_null(tmp1, ASSERT_MSG_BUFFER_ALLOC_FAILED); @@ -47,9 +50,6 @@ static void test_op2(int op, const q15_t *input1, const q15_t *input2, scratch = malloc(MAX_MATRIX_DIM * MAX_MATRIX_DIM * sizeof(q15_t)); zassert_not_null(scratch, ASSERT_MSG_BUFFER_ALLOC_FAILED); - output = malloc(length * sizeof(q15_t)); - zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED); - /* Initialise contexts */ mat_in1.pData = tmp1; mat_in2.pData = tmp2; @@ -127,6 +127,9 @@ static void test_op2c(int op, const q15_t *input1, const q15_t *input2, arm_matrix_instance_q15 mat_out; /* Allocate buffers */ + output = malloc(2 * length * sizeof(q15_t)); + zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED); + tmp1 = malloc(2 * MAX_MATRIX_DIM * MAX_MATRIX_DIM * sizeof(q15_t)); zassert_not_null(tmp1, ASSERT_MSG_BUFFER_ALLOC_FAILED); @@ -136,9 +139,6 @@ static void test_op2c(int op, const q15_t *input1, const q15_t *input2, scratch = malloc(2 * MAX_MATRIX_DIM * MAX_MATRIX_DIM * sizeof(q15_t)); zassert_not_null(scratch, ASSERT_MSG_BUFFER_ALLOC_FAILED); - output = malloc(2 * length * sizeof(q15_t)); - zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED); - /* Initialise contexts */ mat_in1.pData = tmp1; mat_in2.pData = tmp2; @@ -206,8 +206,8 @@ DEFINE_TEST_VARIANT5( void test_matrix_binary_q15(void) { ztest_test_suite(matrix_binary_q15, - ztest_unit_test(test_op2_arm_mat_mult_q15), - ztest_unit_test(test_op2c_arm_mat_cmplx_mult_q15) + ztest_unit_test(test_op2c_arm_mat_cmplx_mult_q15), + ztest_unit_test(test_op2_arm_mat_mult_q15) ); ztest_run_test_suite(matrix_binary_q15);