Skip to content

Commit 8917dfe

Browse files
committed
fix(test/main): always call prif_init
This commit fixes a problem that caused seg faults when running subsets test. Previously, if the subset didn't include the prif_init test, then prif_init was never called. This commit calls prif_init in test/main.F90 before running the tests. Consequently, the test for normal execution of prif_init now happens via an assertion rather than in a unit test.
1 parent e5183aa commit 8917dfe

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

test/main.F90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute
22
! Terms of use are as specified in LICENSE.txt
33

4-
!#include "assert_macros.h"
4+
#include "assert_macros.h"
55

66
program main
77
!! Test the Caffeine implementation of the Parallel Runtime Interface for Fortran (PRIF)
@@ -30,13 +30,15 @@ program main
3030
use prif_this_image_test_m, only : prif_this_image_test_t
3131
implicit none
3232

33+
integer, parameter :: successful=0
3334
integer :: passes=0, tests=0
34-
integer me
35+
integer me, init_status
3536

3637
call stop_and_print_usage_info_if_help_requested
38+
call prif_init(stat=init_status)
39+
call_assert(init_status==successful)
3740
call run_tests_and_report(passes, tests)
3841
call prif_this_image_no_coarray(this_image=me)
39-
4042
if (me==1) print "(a,*(a,G0))", new_line(''), "_________ In total, ",passes," of ",tests, " tests pass. _________"
4143
call prif_sync_all
4244
if (passes /= tests) call prif_error_stop(quiet=.false._c_bool)

test/prif_init_test_m.F90

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,29 @@ function results() result(test_results)
3434

3535
#if HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
3636
test_descriptions = [ &
37-
test_description_t("completing normally when called once", check_caffeination), &
38-
test_description_t("returning PRIF_STAT_ALREADY_INIT when called a second time", check_subsequent_prif_init_call) &
37+
test_description_t("returning PRIF_STAT_ALREADY_INIT when called a second time", check_redundant_prif_init_call) &
3938
]
4039
#else
41-
procedure(test_function_i), pointer :: check_caffeination_ptr, check_subsequent_prif_init_call_ptr
42-
43-
check_caffeination_ptr => check_caffeination
44-
check_subsequent_prif_init_call_ptr => check_subsequent_prif_init_call
40+
procedure(test_function_i), pointer :: check_caffeination_ptr, check_redundant_prif_init_call_ptr
41+
check_redundant_prif_init_call_ptr => check_redundant_prif_init_call
4542

4643
test_descriptions = [ &
47-
test_description_t("completing normally when called once", check_caffeination_ptr) &
48-
,test_description_t("returning PRIF_STAT_ALREADY_INIT when called a second time", check_subsequent_prif_init_call_ptr) &
44+
test_description_t("returning PRIF_STAT_ALREADY_INIT when called a second time", check_redundant_prif_init_call_ptr) &
4945
]
5046
#endif
5147

5248
test_descriptions = pack(test_descriptions, &
5349
index(subject(), test_description_substring) /= 0 &
5450
.or. test_descriptions%contains_text(test_description_substring))
55-
5651
test_results = test_descriptions%run()
5752
end function
5853

59-
function check_caffeination() result(test_passes)
60-
!! check program initiation
54+
function check_redundant_prif_init_call() result(test_passes)
6155
logical test_passes
62-
integer, parameter :: successful_initiation = 0
63-
integer init_exit_code
64-
65-
call prif_init(init_exit_code)
66-
test_passes = init_exit_code == successful_initiation
67-
end function
68-
69-
function check_subsequent_prif_init_call() result(test_passes)
70-
logical test_passes
71-
72-
integer :: stat
73-
74-
call prif_init(stat)
75-
call prif_init(stat)
76-
test_passes = stat == PRIF_STAT_ALREADY_INIT
56+
integer stat
57+
call prif_init(stat)
58+
call prif_init(stat)
59+
test_passes = stat == PRIF_STAT_ALREADY_INIT
7760
end function
7861

7962
end module prif_init_test_m

0 commit comments

Comments
 (0)