-
Notifications
You must be signed in to change notification settings - Fork 0
/
pftest_hello.pf
143 lines (120 loc) · 4.57 KB
/
pftest_hello.pf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
! 1. This test suite should be executed with atleast 3 MPI processes
! 2. When building these tests pass the "-DUSE_MPI=YES" to the
! compiler. If this option is not provided only the non-MPI tests,
! tests that don't have npes specified, will be run
module test_helloworld
use pfunit_mod
contains
@test
subroutine test_hello()
implicit none
call hello()
@assertTrue(.true.)
end subroutine test_hello
@test(npes=[1])
subroutine test_hello_single_proc(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
integer comm, size, rank, tmp
integer ierr
print *, "Test resticted to single proc"
comm = this%getMpiCommunicator()
call comm_hello(comm)
call MPI_COMM_SIZE(comm, size, ierr)
tmp = this%getNumProcesses()
@mpiAssertEqual(size, tmp)
@mpiAssertEqual(size, 1)
end subroutine test_hello_single_proc
! This test is run twice
! 1) With 2 procs
! 2) With 3 procs
@test(npes=[2,3])
subroutine test_hello_multi_proc(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
integer comm, size, rank
integer ierr
print *, "Test resticted for 2 & 3 procs"
comm = this%getMpiCommunicator()
call MPI_COMM_SIZE(comm, size, ierr)
@mpiAssertTrue((size == 2) .OR. (size ==3))
call MPI_COMM_RANK(comm, rank, ierr)
if(size == 2) then
@mpiAssertTrue((rank == 0) .OR. (rank == 1))
else
@mpiAssertTrue((rank == 0) .OR. (rank == 1) .OR. (rank == 2))
endif
call rank_hello(rank)
end subroutine test_hello_multi_proc
@test(npes=[2,3])
subroutine test_hello_mpi_openmp(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
integer comm, size, rank
integer ierr
!$OMP PARALLEL
print *, "Test resticted for 2 & 3 procs"
!$OMP END PARALLEL
comm = this%getMpiCommunicator()
call MPI_COMM_SIZE(comm, size, ierr)
@mpiAssertTrue((size == 2) .OR. (size ==3))
call MPI_COMM_RANK(comm, rank, ierr)
if(size == 2) then
@mpiAssertTrue((rank == 0) .OR. (rank == 1))
else
@mpiAssertTrue((rank == 0) .OR. (rank == 1) .OR. (rank == 2))
endif
call rank_hello(rank)
end subroutine test_hello_mpi_openmp
@test
subroutine test_asserts()
implicit none
integer :: one = 1, two = 2
@assertEqual(one, 1)
@assertEqual(one, 1, "one is not equal to 1")
@assertTrue(one == 1)
@assertTrue(one == 1, "(one == 1) is not true")
@assertFalse(one /= 1)
@assertFalse(one /= 1, "(one /= 1) is not false")
@assertLessThan(one, two)
@assertLessThan(one, two, "one is not less than two")
@assertLessThanOrEqual(one, two)
@assertLessThanOrEqual(one, two, "one is not less than or equal to two")
@assertGreaterThan(two, one)
@assertGreaterThan(two, one, "two is not greater than one")
@assertGreaterThanOrEqual(two, one)
@assertGreaterThanOrEqual(two, one, "two is not greater than or equal to one")
@assertAny([one == 1, two == 1])
@assertAny([one == 1, two == 1], "one is not equal to 1 AND two is not equal to 1")
@assertAll([one == 1, two == 2])
@assertAll([one == 1, two == 2], "one is not equal to 1 OR two is not equal to 2")
@assertNone([one /= 1, two /= 2])
@assertNone([one /= 1, two /= 2], "one is not equal to 1 OR two is not equal to 2")
end subroutine test_asserts
@test(npes=[2,3])
subroutine test_mpi_asserts(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
integer :: one = 1, two = 2
@mpiAssertEqual(one, 1)
@mpiAssertEqual(one, 1, "one is not equal to 1")
@mpiAssertTrue(one == 1)
@mpiAssertTrue(one == 1, "(one == 1) is not true")
@mpiAssertFalse(one /= 1)
@mpiAssertFalse(one /= 1, "(one /= 1) is not false")
@mpiAssertLessThan(one, two)
@mpiAssertLessThan(one, two, "one is not less than two")
@mpiAssertLessThanOrEqual(one, two)
@mpiAssertLessThanOrEqual(one, two, "one is not less than or equal to two")
@mpiAssertGreaterThan(two, one)
@mpiAssertGreaterThan(two, one, "two is not greater than one")
@mpiAssertGreaterThanOrEqual(two, one)
@mpiAssertGreaterThanOrEqual(two, one, "two is not greater than or equal to one")
@mpiAssertAny([one == 1, two == 1])
@mpiAssertAny([one == 1, two == 1], "one is not equal to 1 AND two is not equal to 1")
@mpiAssertAll([one == 1, two == 2])
@mpiAssertAll([one == 1, two == 2], "one is not equal to 1 OR two is not equal to 2")
@mpiAssertNone([one /= 1, two /= 2])
@mpiAssertNone([one /= 1, two /= 2], "one is not equal to 1 OR two is not equal to 2")
end subroutine test_mpi_asserts
end module test_helloworld