-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpftest_before_after.pf
70 lines (52 loc) · 1.74 KB
/
pftest_before_after.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
! 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_before_after
use pfunit_mod
implicit none
integer :: num_tests
integer :: test_sz = 0
public :: init, finalise, test_one, test_two
contains
@before
subroutine init(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
integer comm, size, rank
integer ierr
comm = this%getMpiCommunicator()
call MPI_COMM_SIZE(comm, size, ierr)
num_tests = 0
test_sz = size
end subroutine init
! Cannot use "finalize" because "pfunit_mod" already
! defines it - yikes
@after
subroutine finalise(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
integer comm, size, rank
integer ierr
comm = this%getMpiCommunicator()
call MPI_COMM_SIZE(comm, size, ierr)
! "num_tests" should be equal to 1 - Since the init/finalize
! is run before every test
@mpiAssertEqual(num_tests, 1, "Number of tests is not equal to 1")
@mpiAssertEqual(test_sz, size)
end subroutine finalise
@test(npes=[2,3])
subroutine test_one(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
num_tests = num_tests + 1
@mpiAssertFalse(test_sz == 0, "Test size is equal to 0 - fixtures not working")
end subroutine test_one
@test(npes=[1,2])
subroutine test_two(this)
implicit none
class (MpiTestMethod), intent(inout) :: this
num_tests = num_tests + 1
@mpiAssertFalse(test_sz == 0, "Test size is equal to 0 - fixtures not working")
end subroutine test_two
end module test_before_after