From 22387905196c1ec8003a263c546b423597337b2a Mon Sep 17 00:00:00 2001 From: Brett Warren Date: Mon, 27 Jun 2022 09:49:35 +0100 Subject: [PATCH] test_c007: correct processing of triplet rate arrays The test incorrectly accesses triplet rate arrays by going out of bounds due to a incorrectly used increment variable. This is replaced by fixed indexes outside of the previous loop. Signed-off-by: Brett Warren --- test_pool/clock/test_c007.c | 67 +++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/test_pool/clock/test_c007.c b/test_pool/clock/test_c007.c index afcfb5b..fa0866b 100644 --- a/test_pool/clock/test_c007.c +++ b/test_pool/clock/test_c007.c @@ -97,11 +97,11 @@ uint32_t clock_query_describe_rates(void) /* Rate array starts from return_values[1]*/ rate_array = &return_values[RATES_OFFSET]; - for (i = 0; i < num_rates_retured; i++) + if (return_format == CLOCK_RATE_FMT_ARRAY) { - val_print(VAL_PRINT_TEST, "\n Rate Index : %d", rate_index + i); + for (i = 0; i < num_rates_retured; i++) { + val_print(VAL_PRINT_DEBUG, "\n Rate Index : %d", rate_index + i); - if (return_format == CLOCK_RATE_FMT_ARRAY) { lower_word = rate_array[i * 2]; upper_word = rate_array[1 + i * 2]; @@ -118,40 +118,35 @@ uint32_t clock_query_describe_rates(void) val_clock_save_rate(CLOCK_HIGHEST_RATE, clock_id, clock_rate); } - } else { - /* Verify remaining rates for triplet format */ - val_print(VAL_PRINT_TEST, "\n [Check 3] Verify triplet return format"); - if (num_rates_retured != 3 || num_remaining_rates != 0) - return VAL_STATUS_FAIL; - - /* Find lowest clock rate from rate array */ - lower_word = rate_array[i * 6]; - upper_word = rate_array[1 + i * 6]; - clock_rate = VAL_GET_64BIT_DATA(upper_word, lower_word); - - /* Find highest clock rate from rate array */ - lower_word = rate_array[2 + i * 6]; - upper_word = rate_array[3 + i * 6]; - clock_rate_higher = VAL_GET_64BIT_DATA(upper_word, lower_word); - - /* Find step size from rate array */ - lower_word = rate_array[4 + i * 6]; - upper_word = rate_array[5 + i * 6]; - step_size = VAL_GET_64BIT_DATA(upper_word, lower_word); - - val_print(VAL_PRINT_DEBUG, "\n LOWEST RATE : 0x%llX", - clock_rate); - val_print(VAL_PRINT_DEBUG, "\n HIGHEST RATE : 0x%llX", - clock_rate_higher); - val_print(VAL_PRINT_DEBUG, "\n STEP SIZE : 0x%llX", - step_size); - - /* Store lowest & highest rates*/ - val_clock_save_rate(CLOCK_LOWEST_RATE, - clock_id, clock_rate); - val_clock_save_rate(CLOCK_HIGHEST_RATE, - clock_id, clock_rate_higher); } + } else { + /* Find lowest clock rate from rate array */ + lower_word = rate_array[0]; + upper_word = rate_array[1]; + clock_rate = VAL_GET_64BIT_DATA(upper_word, lower_word); + + /* Find highest clock rate from rate array */ + lower_word = rate_array[2]; + upper_word = rate_array[3]; + clock_rate_higher = VAL_GET_64BIT_DATA(upper_word, lower_word); + + /* Find step size from rate array */ + lower_word = rate_array[4]; + upper_word = rate_array[5]; + step_size = VAL_GET_64BIT_DATA(upper_word, lower_word); + + val_print(VAL_PRINT_DEBUG, "\n LOWEST RATE : 0x%llX", + clock_rate); + val_print(VAL_PRINT_DEBUG, "\n HIGHEST RATE : 0x%llX", + clock_rate_higher); + val_print(VAL_PRINT_DEBUG, "\n STEP SIZE : 0x%llX", + step_size); + + /* Store lowest & highest rates*/ + val_clock_save_rate(CLOCK_LOWEST_RATE, + clock_id, clock_rate); + val_clock_save_rate(CLOCK_HIGHEST_RATE, + clock_id, clock_rate_higher); } } while (num_remaining_rates > 0); -- GitLab