Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ jobs:
echo CAF_IMAGES=${CAF_IMAGES}
set -x
./build/run-fpm.sh run --verbose --example hello
./build/run-fpm.sh run --verbose --example stop_with_no_code
( set +e ; ./build/run-fpm.sh run --verbose --example stop_with_integer_code ; test $? = 99 )
( set +e ; ./build/run-fpm.sh run --verbose --example error_stop_with_integer_code ; test $? = 100 )

- name: Run unit tests
run: |
Expand All @@ -214,3 +211,20 @@ jobs:
CAF_IMAGES=$(( CAF_IMAGES / 2 )) ; \
done

- name: Run exit tests
run: |
echo CAF_IMAGES=${CAF_IMAGES}
set -x
./build/run-fpm.sh run --verbose --example stop_with_no_code
( set +e ; ./build/run-fpm.sh run --verbose --example stop_with_integer_code ; test $? = 99 )
( set +e ; ./build/run-fpm.sh run --verbose --example error_stop_with_integer_code ; test $? = 100 )
unset GASNET_SPAWN_VERBOSE
for ((i=1; i<=4; i++)); do \
(set +e ; \
./build/run-fpm.sh run --verbose --example exit_case -- $i 2>&1 | tee output ; \
test ${PIPESTATUS[0]} = $((i + 100)) \
&& grep -q "stdout from image $CAF_IMAGES" output \
&& grep -q "stderr from image $CAF_IMAGES" output \
) ; \
done

48 changes: 48 additions & 0 deletions example/support-test/exit_case.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
program hello_world
use iso_c_binding, only: c_bool
use iso_fortran_env, only: output_unit,error_unit
use prif, only : &
prif_init &
,prif_this_image_no_coarray &
,prif_num_images &
,prif_stop &
,prif_error_stop &
,prif_sync_all
implicit none

integer :: init_exit_code, me, num_imgs, exitcase = 1
logical(kind=c_bool), parameter :: false = .false._c_bool, true = .true._c_bool
character(len=256) :: arg_string

call prif_init(init_exit_code)
if (init_exit_code /= 0) call prif_error_stop(quiet=false, stop_code_char="program startup failed")

call prif_this_image_no_coarray(this_image=me)
call prif_num_images(num_images=num_imgs)
if (command_argument_count() > 0) then
call get_command_argument(1, arg_string)
read(arg_string, *) exitcase
end if
if (me == 1) write(output_unit,*) "testing exit case ", exitcase

call prif_sync_all()

write(output_unit,'(A,I1,A,I1)') "stdout from image ", me, " of ", num_imgs
write(error_unit,'(A,I1,A,I1)') "stderr from image ", me, " of ", num_imgs

call prif_sync_all()

select case (exitcase)
case (1)
call prif_stop(quiet=true, stop_code_int=exitcase+100)
case (2)
call prif_stop(quiet=false, stop_code_int=exitcase+100)
case (3)
if (me == num_imgs) call prif_error_stop(quiet=true, stop_code_int=exitcase+100)
case default
if (me == num_imgs) call prif_error_stop(quiet=false, stop_code_int=exitcase+100)
end select

call prif_sync_all()

end program