Skip to content

Commit 532223f

Browse files
author
Damian Rouson
committed
Allow option of multiple failures per test
wait until end to error terminate if checks fail
1 parent 4338a61 commit 532223f

File tree

6 files changed

+437
-250
lines changed

6 files changed

+437
-250
lines changed

src/tests/unit/send-get/get_array_test.f90

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ program main
77
integer, parameter :: n = 3
88
integer, parameter :: m = 4
99

10+
logical :: error_printed=.false.
11+
1012
! Allocatable coarrays
1113
call one(-5, 1)
1214
call one(0, 0)
@@ -16,7 +18,11 @@ program main
1618
! Static coarrays
1719
call two()
1820
call three()
19-
write(*,*) 'Test passed'
21+
22+
if (error_printed) error stop
23+
sync all
24+
25+
if (this_image()==1) print *,'Test passed.'
2026
contains
2127
subroutine one(lb1, lb2)
2228
integer, value :: lb1, lb2
@@ -42,7 +48,7 @@ subroutine one(lb1, lb2)
4248
end if
4349
sync all
4450
if(this_image()==1) then
45-
if(any (a /= c)) error stop "ARRAY = SCALAR failed in get_array_test"
51+
if(any (a /= c)) call print_and_register( "ARRAY = SCALAR failed in get_array_test")
4652
endif
4753

4854
! Whole array: ARRAY = ARRAY
@@ -59,7 +65,7 @@ subroutine one(lb1, lb2)
5965
print *, a
6066
print *, c
6167
! FIXME: Without the print lines above, it always fails. Why?
62-
error stop "ARRAY = ARRAY failed in get_array_test"
68+
call print_and_register( "ARRAY = ARRAY failed in get_array_test")
6369
end if
6470
endif
6571

@@ -98,7 +104,7 @@ subroutine one(lb1, lb2)
98104
print *, this_image(), ': ', a
99105
print *, this_image(), ': ', c
100106
! FIXME: Without the print lines above, it always fails. Why?
101-
error stop "scalar assignment failed in get_array_test"
107+
call print_and_register( "scalar assignment failed in get_array_test")
102108
end if
103109
endif
104110
! Array sections with different ranges and pos/neg strides
@@ -130,7 +136,7 @@ subroutine one(lb1, lb2)
130136
print *, a
131137
print *, c
132138
print *, a-c
133-
error stop "array sections with ranges and strides failed in get_array_test"
139+
call print_and_register( "array sections with ranges and strides failed in get_array_test")
134140
endif
135141
end if
136142
! ARRAY = ARRAY
@@ -155,7 +161,7 @@ subroutine one(lb1, lb2)
155161
print *, a
156162
print *, c
157163
print *, a-c
158-
error stop "array sections with ranges and strides failed in get_array_test"
164+
call print_and_register( "array sections with ranges and strides failed in get_array_test")
159165
endif
160166
end if
161167
end do
@@ -189,7 +195,7 @@ subroutine two()
189195
sync all
190196
if (this_image() == num_images()) then
191197
if (any (a /= caf)) &
192-
error stop "Array = scalar failed in subroutine two get_array_test"
198+
call print_and_register( "Array = scalar failed in subroutine two get_array_test")
193199
end if
194200

195201
! Whole array: ARRAY = ARRAY
@@ -203,7 +209,7 @@ subroutine two()
203209
sync all
204210
if (this_image() == num_images()) then
205211
if (any (a /= caf)) &
206-
error stop "Array = array failed in subroutine two get_array_test"
212+
call print_and_register( "Array = array failed in subroutine two get_array_test")
207213
end if
208214

209215
! Scalar assignment
@@ -235,7 +241,7 @@ subroutine two()
235241
sync all
236242
if (this_image() == num_images()) then
237243
if (any (a /= caf)) &
238-
error stop "scalar assignment failed in subroutine two get_array_test"
244+
call print_and_register( "scalar assignment failed in subroutine two get_array_test")
239245
end if
240246

241247
! Array sections with different ranges and pos/neg strides
@@ -280,7 +286,7 @@ subroutine two()
280286
print *, a
281287
print *, caf
282288
print *, a-caf
283-
error stop "arrays with ranges and strides failed sub. two get_array_test failed"
289+
call print_and_register( "arrays with ranges and strides failed sub. two get_array_test failed")
284290
endif
285291
end if
286292
end do
@@ -314,7 +320,7 @@ subroutine three()
314320
sync all
315321
if (this_image() == num_images()) then
316322
if (any (a /= caf)) &
317-
error stop "Array = scalar subroutine three get_array_test failed"
323+
call print_and_register( "Array = scalar subroutine three get_array_test failed")
318324
end if
319325

320326
! Whole array: ARRAY = ARRAY
@@ -328,7 +334,7 @@ subroutine three()
328334
sync all
329335
if (this_image() == num_images()) then
330336
if (any (a /= caf)) &
331-
error stop "Array = array subroutine three get_array_test failed"
337+
call print_and_register( "Array = array subroutine three get_array_test failed")
332338
end if
333339

334340
! Scalar assignment
@@ -360,7 +366,7 @@ subroutine three()
360366
sync all
361367
if (this_image() == num_images()) then
362368
if (any (a /= caf)) &
363-
error stop "scalar assignment subroutine three get_array_test failed"
369+
call print_and_register( "scalar assignment subroutine three get_array_test failed")
364370
end if
365371

366372
! Array sections with different ranges and pos/neg strides
@@ -405,7 +411,7 @@ subroutine three()
405411
print *, a
406412
print *, caf
407413
print *, a-caf
408-
error stop "range stride in subroutine three get_array_test failed"
414+
call print_and_register( "range stride in subroutine three get_array_test failed")
409415
endif
410416
end if
411417
end do
@@ -417,4 +423,12 @@ subroutine three()
417423
end do
418424
end do
419425
end subroutine three
426+
427+
subroutine print_and_register(error_message)
428+
use iso_fortran_env, only : error_unit
429+
character(len=*), intent(in) :: error_message
430+
write(error_unit,*) error_message
431+
error_printed=.true.
432+
end subroutine
433+
420434
end program main

0 commit comments

Comments
 (0)