Skip to content

Commit d0c877c

Browse files
authored
Merge pull request #241 from sourceryinstitute/cleanup-tests
Cleanup tests
2 parents 1c9f8a6 + 354f3f1 commit d0c877c

15 files changed

+111
-171
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ script:
166166
cd cmake-build
167167
cmake -DCMAKE_INSTALL_PREFIX:PATH="$HOME/OpenCoarrays" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" ..
168168
make -j 4
169-
ctest --verbose
169+
ctest --output-on-failure
170170
make install
171171
cd ..
172172
fi

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,12 @@ configure_file ( "${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" "${CMAKE_BINARY_
148148
add_custom_target ( uninstall
149149
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/uninstall.cmake" )
150150

151-
152151
enable_testing()
153152

153+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
154+
# See JSON-Fortran's CMakeLists.txt file to find out how to get the check target to depend
155+
# on the test executables
156+
154157
# Determine if we're using Open MPI
155158
execute_process(COMMAND ${MPIEXEC} --version
156159
OUTPUT_VARIABLE mpi_version_out)
@@ -190,6 +193,7 @@ if(opencoarrays_aware_compiler)
190193
add_mpi_test(allocate_as_barrier 2 ${tests_root}/unit/init_register/allocate_as_barrier)
191194
add_mpi_test(allocate_as_barrier_proc 32 ${tests_root}/unit/init_register/allocate_as_barrier_proc)
192195
add_mpi_test(get_array 2 ${tests_root}/unit/send-get/get_array)
196+
add_mpi_test(get_self 2 ${tests_root}/unit/send-get/get_self)
193197
add_mpi_test(send_array 2 ${tests_root}/unit/send-get/send_array)
194198
add_mpi_test(get_with_offset_1d 2 ${tests_root}/unit/send-get/get_with_offset_1d)
195199
add_mpi_test(whole_get_array 2 ${tests_root}/unit/send-get/whole_get_array)
@@ -200,9 +204,13 @@ if(opencoarrays_aware_compiler)
200204
add_mpi_test(co_max 4 ${tests_root}/unit/collectives/co_max_test)
201205
add_mpi_test(syncall 32 ${tests_root}/unit/sync/syncall)
202206
add_mpi_test(syncimages 32 ${tests_root}/unit/sync/syncimages)
207+
add_mpi_test(syncimages2 32 ${tests_root}/unit/sync/syncimages2)
203208
add_mpi_test(duplicate_syncimages 8 ${tests_root}/unit/sync/duplicate_syncimages)
204209
add_mpi_test(co_reduce 4 ${tests_root}/unit/collectives/co_reduce_test)
205210
add_mpi_test(syncimages_status 32 ${tests_root}/unit/sync/syncimages_status)
211+
add_mpi_test(simpleatomics 32 ${tests_root}/unit/simple/atomics)
212+
# I think there is a logic error in the following test
213+
# add_mpi_test(increment_my_neighbor 32 ${tests_root}/unit/simple/increment_my_neighbor)
206214

207215
# Integration tests verifying the use of libcaf_mpi in applications
208216
add_mpi_test(hello_multiverse 2 ${tests_root}/integration/coarrayHelloWorld/hello_multiverse)

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ program main
1414
call one(0, -11)
1515

1616
! Static coarrays
17-
! call two()
18-
! call three()
17+
call two()
18+
call three()
1919
write(*,*) 'Test passed'
2020
contains
2121
subroutine one(lb1, lb2)
@@ -42,7 +42,7 @@ subroutine one(lb1, lb2)
4242
end if
4343
sync all
4444
if(this_image()==1) then
45-
if(any (a /= c)) call abort()
45+
if(any (a /= c)) error stop "ARRAY = SCALAR failed in get_array_test"
4646
endif
4747

4848
! Whole array: ARRAY = ARRAY
@@ -59,7 +59,7 @@ subroutine one(lb1, lb2)
5959
print *, a
6060
print *, c
6161
! FIXME: Without the print lines above, it always fails. Why?
62-
call abort()
62+
error stop "ARRAY = ARRAY failed in get_array_test"
6363
end if
6464
endif
6565

@@ -98,7 +98,7 @@ subroutine one(lb1, lb2)
9898
print *, this_image(), ': ', a
9999
print *, this_image(), ': ', c
100100
! FIXME: Without the print lines above, it always fails. Why?
101-
call abort()
101+
error stop "scalar assignment failed in get_array_test"
102102
end if
103103
endif
104104
! Array sections with different ranges and pos/neg strides
@@ -130,7 +130,7 @@ subroutine one(lb1, lb2)
130130
print *, a
131131
print *, c
132132
print *, a-c
133-
call abort()
133+
error stop "array sections with ranges and strides failed in get_array_test"
134134
endif
135135
end if
136136
! ARRAY = ARRAY
@@ -155,7 +155,7 @@ subroutine one(lb1, lb2)
155155
print *, a
156156
print *, c
157157
print *, a-c
158-
call abort()
158+
error stop "array sections with ranges and strides failed in get_array_test"
159159
endif
160160
end if
161161
end do
@@ -189,7 +189,7 @@ subroutine two()
189189
sync all
190190
if (this_image() == num_images()) then
191191
if (any (a /= caf)) &
192-
call abort()
192+
error stop "Array = scalar failed in subroutine two get_array_test"
193193
end if
194194

195195
! Whole array: ARRAY = ARRAY
@@ -203,7 +203,7 @@ subroutine two()
203203
sync all
204204
if (this_image() == num_images()) then
205205
if (any (a /= caf)) &
206-
call abort()
206+
error stop "Array = array failed in subroutine two get_array_test"
207207
end if
208208

209209
! Scalar assignment
@@ -235,7 +235,7 @@ subroutine two()
235235
sync all
236236
if (this_image() == num_images()) then
237237
if (any (a /= caf)) &
238-
call abort()
238+
error stop "scalar assignment failed in subroutine two get_array_test"
239239
end if
240240

241241
! Array sections with different ranges and pos/neg strides
@@ -280,7 +280,7 @@ subroutine two()
280280
print *, a
281281
print *, caf
282282
print *, a-caf
283-
call abort()
283+
error stop "arrays with ranges and strides failed sub. two get_array_test failed"
284284
endif
285285
end if
286286
end do
@@ -314,7 +314,7 @@ subroutine three()
314314
sync all
315315
if (this_image() == num_images()) then
316316
if (any (a /= caf)) &
317-
call abort()
317+
error stop "Array = scalar subroutine three get_array_test failed"
318318
end if
319319

320320
! Whole array: ARRAY = ARRAY
@@ -328,7 +328,7 @@ subroutine three()
328328
sync all
329329
if (this_image() == num_images()) then
330330
if (any (a /= caf)) &
331-
call abort()
331+
error stop "Array = array subroutine three get_array_test failed"
332332
end if
333333

334334
! Scalar assignment
@@ -360,7 +360,7 @@ subroutine three()
360360
sync all
361361
if (this_image() == num_images()) then
362362
if (any (a /= caf)) &
363-
call abort()
363+
error stop "scalar assignment subroutine three get_array_test failed"
364364
end if
365365

366366
! Array sections with different ranges and pos/neg strides
@@ -405,7 +405,7 @@ subroutine three()
405405
print *, a
406406
print *, caf
407407
print *, a-caf
408-
call abort()
408+
error stop "range stride in subroutine three get_array_test failed"
409409
endif
410410
end if
411411
end do

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ program get_offset_1d
2323

2424
if(me == 1) then
2525
do i=1,10
26-
if(b(i) /= 20+i+me+1) call abort()
26+
if(b(i) /= 20+i+me+1) error stop "get offset 1d failed"
2727
enddo
28-
write(*,*) 'Test passed.'
2928
endif
30-
sync all
29+
sync all
30+
if(me ==1) write(*,*) 'Test passed.'
3131
end program

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ subroutine one(lb1, lb2)
4545
if (any (a /= b(lb1,lb2))) then
4646
! FIXME: ABORTS UNLESS THERE IS SOME OTHER CODE
4747
print *, 'HELLO!!!!!!!!!!!!!!!!!'
48-
call abort()
48+
error stop
4949
end if
5050
end if
5151

@@ -63,7 +63,7 @@ subroutine one(lb1, lb2)
6363
print *, a
6464
print *, b
6565
print *, 'WRONG:', any (a /= b)
66-
call abort()
66+
error stop
6767
end if
6868
end if
6969

@@ -114,7 +114,7 @@ subroutine one(lb1, lb2)
114114
! print *, a
115115
! print *, caf
116116
! print *, a-caf
117-
! call abort()
117+
! error stop
118118
! endif
119119
end if
120120
end do
@@ -152,7 +152,7 @@ subroutine two()
152152
sync all
153153
if (this_image() == 1) then
154154
if (any (a /= b)) &
155-
call abort()
155+
error stop
156156
end if
157157

158158
! Whole array: ARRAY = ARRAY
@@ -170,7 +170,7 @@ subroutine two()
170170
sync all
171171
if (this_image() == 1) then
172172
if (any (a /= b)) &
173-
call abort()
173+
error stop
174174
end if
175175

176176
! Array sections with different ranges and pos/neg strides
@@ -221,7 +221,7 @@ subroutine two()
221221
! print *, a
222222
! print *, caf
223223
! print *, a-caf
224-
! call abort()
224+
! error stop
225225
! endif
226226
end if
227227
end do
@@ -259,7 +259,7 @@ subroutine three()
259259
sync all
260260
if (this_image() == 1) then
261261
if (any (a /= b)) &
262-
call abort()
262+
error stop
263263
end if
264264

265265
! Whole array: ARRAY = ARRAY
@@ -277,7 +277,7 @@ subroutine three()
277277
sync all
278278
if (this_image() == 1) then
279279
if (any (a /= b)) &
280-
call abort()
280+
error stop
281281
end if
282282

283283
! Array sections with different ranges and pos/neg strides
@@ -329,7 +329,7 @@ subroutine three()
329329
! print *, a
330330
! print *, caf
331331
! print *, a-caf
332-
! call abort()
332+
! error stop
333333
! endif
334334
end if
335335
end do

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

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ program sameloc
1212
integer,dimension(9,10),codimension[*] :: m
1313
integer,dimension(10) :: t
1414
integer :: i,j
15+
logical :: tests_passed
16+
17+
tests_passed = .true.
1518

1619
a = 10
1720
b(1:5) = 1
@@ -36,9 +39,11 @@ program sameloc
3639
if(this_image() == 1) then
3740
c = m(1,:)[1]
3841
if(any(c(:) /= t(:))) then
39-
call abort()
42+
tests_passed = .false.
43+
error stop "get row failed"
4044
else
41-
write(*,*) 'ok get row'
45+
tests_passed = tests_passed .and. .true.
46+
write(*,*) 'ok get row'
4247
endif
4348
endif
4449

@@ -48,12 +53,15 @@ program sameloc
4853
do i=1,10
4954
if(m(9,i)[1] /= t(i)) then
5055
write(*,*) 'pos',i,'value get',m(9,i)[1],'value t',t(i)
51-
call abort()
56+
tests_passed = .false.
57+
error stop "get element from matrix failed"
58+
else
59+
tests_passed = tests_passed .and. .true.
5260
endif
5361
enddo
5462
endif
5563

56-
if(this_image() == 1) write(*,*) 'Ok get element from matrix'
64+
if (this_image() == 1) write(*,*) 'Ok get element from matrix'
5765

5866
sync all
5967

@@ -64,12 +72,15 @@ program sameloc
6472
m(9,i)[1] = i
6573
if(m(9,i)[1] /= t(i)) then
6674
write(*,*) 'pos',i,'value get',m(9,i)[1],'value t',t(i)
67-
call abort()
75+
tests_passed = .false.
76+
error stop "put element from matrix failed"
77+
else
78+
tests_passed = tests_passed .and. .true.
6879
endif
6980
enddo
7081
endif
7182

72-
if(this_image() == 1 ) write(*,*) 'Ok put element from matrix'
83+
if (this_image() == 1) write(*,*) 'Ok put element from matrix'
7384

7485
t(:) = b(:)
7586
t(1:5) = b(2:6)
@@ -82,8 +93,10 @@ program sameloc
8293
if(this_image() == 1) then
8394
b(1:5)[1] = b(2:6)
8495
if(any(b(:) /= t(:))) then
85-
call abort()
96+
tests_passed = .false.
97+
error stop "put overlapped failed"
8698
else
99+
tests_passed = tests_passed .and. .true.
87100
write(*,*) 'OK put overlapped'
88101
endif
89102
endif
@@ -96,8 +109,10 @@ program sameloc
96109
if(this_image() == 1) then
97110
b(1:5)[1] = b(2:6)[1]
98111
if(any(b(:) /= t(:))) then
99-
call abort()
112+
tests_passed = .false.
113+
error stop "putget overlapped failed"
100114
else
115+
tests_passed = tests_passed .and. .true.
101116
write(*,*) 'OK putget overlapped'
102117
endif
103118
endif
@@ -110,11 +125,13 @@ program sameloc
110125
if(this_image() == 1) then
111126
c(10:1:-1)[1] = c(:)
112127
if(any(t(:) /= c(:))) then
128+
tests_passed = .false.
113129
write(*,*) 'Error in put reversed'
114130
write(*,*) c
115131
write(*,*) t
116-
call abort()
132+
error stop "put reversed failed"
117133
else
134+
tests_passed = tests_passed .and. .true.
118135
write(*,*) 'OK put reversed'
119136
endif
120137
endif
@@ -128,12 +145,24 @@ program sameloc
128145
if(this_image() == 1) then
129146
c(:) = c(10:1:-1)[1]
130147
if(any(t(:) /= c(:))) then
148+
tests_passed = .false.
131149
write(*,*) c
132150
write(*,*) t
133-
call abort()
151+
error stop "get reversed failed"
134152
else
153+
tests_passed = tests_passed .and. .true.
135154
write(*,*) 'OK get reversed'
136155
endif
137156
endif
138157

158+
if ( .not. tests_passed ) then
159+
error stop "Test failures exist!"
160+
end if
161+
162+
sync all
163+
164+
if ( tests_passed ) then
165+
if (this_image() == 1) write(*,*) 'Test passed'
166+
end if
167+
139168
end program

0 commit comments

Comments
 (0)