From: Jerry DeLisle Date: Sat, 14 Feb 2026 23:46:44 +0000 (-0800) Subject: Fortran: Adjust test to work with multiple images. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=be90cfa22cb4e3cea7ffb4ca429829381369a8d2;p=thirdparty%2Fgcc.git 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 --git a/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 b/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 index 1ec5984a4d3..d990fd3f908 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 -