[2/2] stdlib: Verify heapsort for two-element cases

Message ID 20240116021657.2553198-3-visitorckw@gmail.com
State Committed
Commit 1bb28b7b4f01709b841c86850e1bb83b554feafe
Headers
Series stdlib: Fix and verify heapsort for two-element cases |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed

Commit Message

Kuan-Wei Chiu Jan. 16, 2024, 2:16 a.m. UTC
  Adjust the testing approach to start from scenarios with only 2
elements, as insertion sort no longer handles such cases.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
 stdlib/tst-qsort4.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Adhemerval Zanella Netto Jan. 16, 2024, 10:47 a.m. UTC | #1
On 15/01/24 23:16, Kuan-Wei Chiu wrote:
> Adjust the testing approach to start from scenarios with only 2
> elements, as insertion sort no longer handles such cases.
> 
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>


> ---
>  stdlib/tst-qsort4.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/stdlib/tst-qsort4.c b/stdlib/tst-qsort4.c
> index 4635275419..247917b454 100644
> --- a/stdlib/tst-qsort4.c
> +++ b/stdlib/tst-qsort4.c
> @@ -96,9 +96,7 @@ do_test (void)
>    check_one_sort ((signed char[16]) {15, 3, 4, 2, 1, 0, 8, 7, 6, 5, 14,
>                                       13, 12, 11, 10, 9}, 16);
>  
> -  /* Array lengths 2 and less are not handled by heapsort_r and
> -     deferred to insertion sort.  */
> -  for (int i = 3; i <= 8; ++i)
> +  for (int i = 2; i <= 8; ++i)
>      {
>        signed char *buf = xmalloc (i);
>        check_combinations (i, buf, 0);
  

Patch

diff --git a/stdlib/tst-qsort4.c b/stdlib/tst-qsort4.c
index 4635275419..247917b454 100644
--- a/stdlib/tst-qsort4.c
+++ b/stdlib/tst-qsort4.c
@@ -96,9 +96,7 @@  do_test (void)
   check_one_sort ((signed char[16]) {15, 3, 4, 2, 1, 0, 8, 7, 6, 5, 14,
                                      13, 12, 11, 10, 9}, 16);
 
-  /* Array lengths 2 and less are not handled by heapsort_r and
-     deferred to insertion sort.  */
-  for (int i = 3; i <= 8; ++i)
+  for (int i = 2; i <= 8; ++i)
     {
       signed char *buf = xmalloc (i);
       check_combinations (i, buf, 0);