https://gcc.gnu.org/g:be90cfa22cb4e3cea7ffb4ca429829381369a8d2
commit r16-7737-gbe90cfa22cb4e3cea7ffb4ca429829381369a8d2 Author: Jerry DeLisle <[email protected]> Date: Sat Feb 14 15:46:44 2026 -0800 Fortran: Adjust test to work with multiple images. The testcase would fail occasionally with multiple images because the use of acquired_lock is a non-blocking LOCK. Only UNLOCK this if the LOCK was acquired. Keep track of the loop count and bail out if the limit is reached. During testing it was observed that the loop count could go as high as 33 times depending on system conditions, running the test outside the testsuite 1000's of times. PR fortran/121429 gcc/testsuite/ChangeLog: * gfortran.dg/coarray/lock_1.f90: Updated. Diff: --- gcc/testsuite/gfortran.dg/coarray/lock_1.f90 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 b/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 index 1ec5984a4d34..d990fd3f908c 100644 --- a/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 +++ b/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 @@ -4,12 +4,12 @@ ! ! PR fortran/18918 ! - use iso_fortran_env implicit none type(lock_type) :: lock[*] integer :: stat +integer :: counter logical :: acquired LOCK(lock) @@ -18,15 +18,19 @@ UNLOCK(lock) stat = 99 LOCK(lock, stat=stat) if (stat /= 0) STOP 1 + stat = 99 UNLOCK(lock, stat=stat) if (stat /= 0) STOP 2 -if (this_image() == 1) then - acquired = .false. +acquired = .false. +counter = 0 +do while (.not. acquired) + counter = counter + 1 LOCK (lock[this_image()], acquired_lock=acquired) - if (.not. acquired) STOP 3 - UNLOCK (lock[1]) -end if + if (acquired) UNLOCK (lock) + if ((num_images() .eq. 8) .and. (counter .gt. 100)) exit +end do +! counter here can vary depending on conditions, picked 100. +if (counter .gt. 100) stop counter end -
