Skip to content

Commit 17ac8ee

Browse files
committed
feat: rm data=partitioning test in test/main
1 parent 6878454 commit 17ac8ee

File tree

5 files changed

+75
-127
lines changed

5 files changed

+75
-127
lines changed

src/test_result_s.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
end procedure
1010

1111
module procedure characterize
12-
characterization = merge("passes on ", "fails on ", self%passed_) // self%description_ // "."
12+
characterization = merge("passes on ", "FAILS on ", self%passed_) // self%description_ // "."
1313
end procedure
1414

1515
end submodule test_result_s

tests/data_partition_test.f90

Lines changed: 57 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,129 @@
11
module data_partition_test
2-
!! author: Damian Rouson
3-
!!
4-
!! summary: verify data partitioning across images and data gathering
5-
use vegetables, only: &
6-
result_t, example_t, input_t, integer_input_t, test_item_t, & ! types
7-
describe, it, assert_equals, assert_that ! functions
8-
use data_partition_m, only : data_partition_t
9-
use iso_fortran_env, only : real64
10-
implicit none
11-
12-
private
13-
public :: test_data_partition
2+
!! verify data partitioning across images and data gathering
3+
use data_partition_m, only : data_partition_t
4+
use test_m, only : test_t, test_result_t
5+
use iso_fortran_env, only : real64
6+
implicit none
147

15-
type(data_partition_t) partition
16-
integer, parameter :: num_particles=31, gatherer=1, num_steps=9, dummy=0
8+
private
9+
public :: data_partition_test_t
10+
11+
type, extends(test_t) :: data_partition_test_t
12+
contains
13+
procedure, nopass :: subject
14+
procedure, nopass :: results
15+
end type
16+
17+
type(data_partition_t) partition
18+
integer, parameter :: num_particles=31, gatherer=1, num_steps=9, dummy=0
1719

1820
contains
1921

20-
function test_data_partition() result(tests)
21-
type(test_item_t) tests
22+
pure function subject() result(specimen)
23+
character(len=:), allocatable :: specimen
24+
specimen = "The data_partition_t type"
25+
end function
26+
27+
function results() result(test_results)
28+
type(test_result_t), allocatable :: test_results(:)
2229

23-
call partition%define_partitions( cardinality=num_particles)
30+
call partition%define_partitions(cardinality=num_particles)
2431

2532
associate( me=>this_image() )
2633
associate( my_first=>partition%first(me), my_last=>partition%last(me) )
27-
tests = describe( &
28-
"data_partition class", &
29-
[it( &
30-
"partitions data in nearly even blocks", &
31-
verify_block_partitioning), &
32-
it( &
33-
"all data partitioned across all images without data loss", &
34-
verify_all_particles_partitioned), &
35-
it( &
36-
"1D real array gathered on all images", &
37-
[example_t(integer_input_t(dummy)), example_t(integer_input_t(dummy))], &
38-
verify_all_gather_1D_real_array), &
39-
it( &
40-
"dimension 1 of 2D real array gathered on all images witout dim argument", &
41-
[example_t(integer_input_t(dummy)), example_t(integer_input_t(dummy))], &
42-
verify_all_gather_2D_real_array), &
43-
it( &
44-
"dimension 1 of 2D real array gathered on all images with dim argument", &
45-
[example_t(integer_input_t(dummy)), example_t(integer_input_t(dummy))], &
46-
verify_all_gather_2D_real_array_dim1), &
47-
it( &
48-
"dimension 1 of 2D real array gathered onto result_image with dim argument", &
49-
[example_t(integer_input_t(dummy)), example_t(integer_input_t(dummy))], &
50-
verify_gather_2D_real_array_dim1)])
51-
34+
test_results = [ &
35+
test_result_t("partitioning data in nearly even blocks", verify_block_partitioning()), &
36+
test_result_t("partitioning all data across all images without data loss", verify_all_particles_partitioned()), &
37+
test_result_t("gathering a 1D real array onto all images", verify_all_gather_1D_real_array()), &
38+
test_result_t("gathering dimension 1 of 2D real array onto all images witout dim argument", &
39+
verify_all_gather_2D_real_array()), &
40+
test_result_t("gathering dimension 1 of 2D real array onton all images with dim argument", &
41+
verify_all_gather_2D_real_array_dim1()), &
42+
test_result_t("gathering dimension 1 of 2D real array onto result_image with dim argument", &
43+
verify_gather_2D_real_array_dim1()) &
44+
]
5245
end associate
5346
end associate
5447
end function
5548

56-
function verify_block_partitioning() result(result_)
49+
function verify_block_partitioning() result(test_passes)
5750
!! Verify that the data is partitioned across images evenly to
5851
!! within a difference of one datum between any two images.
5952
type(data_partition_t) partition
60-
type(result_t) result_
53+
logical test_passes
6154
integer my_particles
6255

6356
associate( me=>this_image() )
6457
associate( my_first=>partition%first(me), my_last=>partition%last(me) )
6558
my_particles = my_last - my_first + 1
6659
associate( ni=>num_images() )
6760
associate( quotient=>num_particles/ni, remainder=>mod(num_particles,ni) )
68-
result_ = assert_equals( quotient + merge(1, 0, me<=remainder), my_particles, "block distribution" )
61+
test_passes = quotient + merge(1, 0, me<=remainder) == my_particles
6962
end associate
7063
end associate
7164
end associate
7265
end associate
7366
end function
7467

75-
function verify_all_particles_partitioned() result(result_)
68+
function verify_all_particles_partitioned() result(test_passes)
7669
!! Verify that the number of particles on each image sums to the
7770
!! total number of particles distributed.
7871
type(data_partition_t) partition
79-
type(result_t) result_
72+
logical test_passes
8073
integer particles
8174

8275
associate(me => this_image())
8376
associate( my_first=>partition%first(me), my_last=>partition%last(me) )
8477
particles = my_last - my_first + 1
8578
call co_sum(particles)
86-
result_ = assert_equals(num_particles, particles, "all particles distributed" )
79+
test_passes = num_particles == particles
8780
end associate
8881
end associate
8982
end function
9083

91-
function verify_all_gather_1D_real_array(unused) result(result_)
84+
function verify_all_gather_1D_real_array() result(test_passes)
9285
type(data_partition_t) partition
93-
class(input_t), intent(in) :: unused
94-
type(result_t) result_
86+
logical test_passes
9587
real(real64) :: particle_scalar(num_particles)
9688
real(real64), parameter :: junk=-12345._real64, expected=1._real64
9789

98-
associate( no_op => unused) ! eliminate unused-variable warning
99-
end associate
100-
10190
associate(me => this_image())
10291
associate( first=>partition%first(me), last=>partition%last(me) )
103-
10492
particle_scalar(first:last) = expected !! values to be gathered
10593
particle_scalar(1:first-1) = junk !! values to be overwritten by the gather
10694
particle_scalar(last+1:) = junk !! values to be overwritten by the gather
107-
10895
call partition%gather(particle_scalar)
109-
110-
result_ = assert_that( all(particle_scalar==expected), "real 1D array all-gathered" )
111-
96+
test_passes = all(particle_scalar==expected)
11297
end associate
11398
end associate
11499
end function
115100

116-
function verify_all_gather_2D_real_array(unused) result(result_)
117-
class(input_t), intent(in) :: unused
101+
function verify_all_gather_2D_real_array() result(test_passes)
118102
type(data_partition_t) partition
119-
type(result_t) result_
103+
logical test_passes
120104
integer, parameter :: vec_space_dim=3
121105
real(real64) particle_vector(vec_space_dim, num_particles)
122106
real(real64), parameter :: junk=-12345._real64, expected=1._real64
123107

124-
associate( no_op => unused) ! eliminate unused-variable warning
125-
end associate
126-
127108
associate(me => this_image())
128109
associate( first=>partition%first(me), last=>partition%last(me) )
129110

130111
particle_vector(:, first:last) = expected !! values to be gathered
131112
particle_vector(:, 1:first-1) = junk !! values to be overwritten by the gather
132113
particle_vector(:, last+1:) = junk !! values to be overwritten by the gather
133-
134114
call partition%gather(particle_vector)
135-
136-
result_ = assert_that(all(particle_vector==expected), "real 2D array all-gathered implicitly along dimension 1" )
137-
115+
test_passes = all(particle_vector==expected)
138116
end associate
139117
end associate
140118
end function
141119

142-
function verify_all_gather_2D_real_array_dim1(unused) result(result_)
143-
class(input_t), intent(in) :: unused
120+
function verify_all_gather_2D_real_array_dim1() result(test_passes)
144121
type(data_partition_t) partition
145-
type(result_t) result_
122+
logical test_passes
146123
integer, parameter :: vec_space_dim=3
147124
real(real64) :: vector_transpose(num_particles, vec_space_dim)
148125
real(real64), parameter :: junk=-12345._real64, expected=1._real64
149126

150-
associate( no_op => unused) ! eliminate unused-variable warning
151-
end associate
152-
153127
associate(me => this_image())
154128
associate( first=>partition%first(me), last=>partition%last(me) )
155129

@@ -159,23 +133,19 @@ function verify_all_gather_2D_real_array_dim1(unused) result(result_)
159133

160134
call partition%gather( vector_transpose, dim=1)
161135

162-
result_ = assert_that(all(vector_transpose==expected), "vector_transpose gathered explicitly along dimension 1" )
136+
test_passes= all(vector_transpose==expected)
163137

164138
end associate
165139
end associate
166140
end function
167141

168-
function verify_gather_2D_real_array_dim1(unused) result(result_)
169-
class(input_t), intent(in) :: unused
142+
function verify_gather_2D_real_array_dim1() result(test_passes)
170143
type(data_partition_t) partition
171-
type(result_t) result_
144+
logical test_passes
172145
integer, parameter :: vec_space_dim=3
173146
real(real64) :: vector_transpose(num_particles, vec_space_dim)
174147
real(real64), parameter :: junk=-12345._real64, expected=1._real64
175148

176-
associate( no_op => unused) ! eliminate unused-variable warning
177-
end associate
178-
179149
associate(me => this_image())
180150
associate( first=>partition%first(me), last=>partition%last(me) )
181151

@@ -186,12 +156,12 @@ function verify_gather_2D_real_array_dim1(unused) result(result_)
186156
call partition%gather( vector_transpose, result_image=gatherer, dim=1)
187157

188158
if (me==gatherer) then
189-
result_ = assert_that(all(vector_transpose==expected), "all( particle_vector==expected)")
159+
test_passes = all(vector_transpose==expected)
190160
else
191-
result_ = &
192-
assert_that(all(vector_transpose(1:first-1,:)==junk), "lower transpose data unchanged)") .and. &
193-
assert_that(all(vector_transpose(first:last,:)==expected), "expected transpose data gathered") .and. &
194-
assert_that(all(vector_transpose(last+1:,:)==junk), "upper transpose data unchanged)" )
161+
test_passes = &
162+
all(vector_transpose(1:first-1,:)==junk) .and. &
163+
all(vector_transpose(first:last,:)==expected) .and. &
164+
all(vector_transpose(last+1:,:)==junk)
195165
end if
196166

197167
end associate

tests/main.f90

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
! Generated by make_vegetable_driver. DO NOT EDIT
21
program main
3-
implicit none
4-
5-
call run()
6-
contains
7-
subroutine run()
8-
use data_partition_test, only: &
9-
data_partition_data_partition => &
10-
test_data_partition
11-
use vegetables, only: test_item_t, test_that, run_tests
12-
13-
14-
15-
type(test_item_t) :: tests
16-
type(test_item_t) :: individual_tests(1)
17-
18-
individual_tests(1) = data_partition_data_partition()
19-
tests = test_that(individual_tests)
20-
21-
22-
call run_tests(tests)
23-
24-
end subroutine
2+
use user_defined_collectives_test, only : collectives_test_t
3+
use data_partition_test, only : data_partition_test_t
4+
use object_m_test, only : object_test_t
5+
use formats_test, only : formats_test_t
6+
implicit none
7+
8+
type(data_partition_test_t) data_partition_test
9+
type(collectives_test_t) collectives_test
10+
type(object_test_t) object_test
11+
type(formats_test_t) formats_test
12+
13+
call data_partition_test%report()
14+
call collectives_test%report()
15+
call object_test%report()
16+
call formats_test%report()
2517
end program

tests/object_m_test.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pure function results() result(test_results)
2929
type(test_result_t), allocatable :: test_results(:)
3030

3131
test_results = [ &
32-
test_result_t(".not. user_defined() if only default-initialized", check_default_initialization()), &
33-
test_result_t("user_defined() after call mark_as_defined", check_mark_as_defined()) &
32+
test_result_t("object being .not. user_defined() if it is only default-initialized", check_default_initialization()), &
33+
test_result_t("object being user_defined() after call to mark_as_defined", check_mark_as_defined()) &
3434
]
3535
end function
3636

tests/test-driver.f90

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)