-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathRemoteProxyTestCase.F90
More file actions
209 lines (175 loc) · 6.03 KB
/
RemoteProxyTestCase.F90
File metadata and controls
209 lines (175 loc) · 6.03 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
!-------------------------------------------------------------------------------
! NASA/GSFC Advanced Software Technology Group
!-------------------------------------------------------------------------------
! MODULE: RemoteProxyTestCase
!
!> @brief
!! <BriefDescription>
!!
!! @author
!! Tom Clune, NASA/GSFC
!!
!! @date
!! 07 Nov 2013
!!
!! @note <A note here.>
!! <Or starting here...>
!
! REVISION HISTORY:
!
! 07 Nov 2013 - Added the prologue for the compliance with Doxygen.
!
!-------------------------------------------------------------------------------
module PF_RemoteProxyTestCase
use pf_SourceLocation
use PF_UnixProcess
use PF_ExceptionList
use pf_DisableAnnotation
use PF_Test
use PF_TestCase
use iso_c_binding
use pf_Posix
use pf_File
use pf_TestAnnotation
use pf_StringTestAnnotationMap
use pf_TimeoutAnnotation
use pf_TestTimer
implicit none
private
public :: RemoteProxyTestCase
type, extends(TestCase) :: RemoteProxyTestCase
private
type(File) :: posix_file
type(TestTimer) :: timer
logical :: errored = .false.
contains
procedure :: runMethod
procedure :: encountered_errors
end type RemoteProxyTestCase
interface RemoteProxyTestCase
module procedure newRemoteProxyTestCase
end interface RemoteProxyTestCase
contains
function newRemoteProxyTestCase(a_test, f, max_time) result(proxy)
type (RemoteProxyTestCase) :: proxy
class (Test), intent(in) :: a_test
type(File), intent(in) :: f
real, intent(in) :: max_time
class(StringTestAnnotationMap), pointer :: annotations
class(TestAnnotation), pointer :: annotation
integer :: status
annotations => a_test%get_annotations()
if (annotations%count('Timeout') == 1) then
annotation => annotations%at('Timeout', rc=status)
! cast
select type (annotation)
class is (TimeoutAnnotation)
proxy%timer = annotation%make_timer()
end select
else
proxy%timer = TestTimer(max_time)
end if
proxy%posix_file = f
call proxy%setName(a_test%getName())
if(a_test%is_disabled()) then
call annotations%insert(Disable%type_name(),Disable)
end if
end function newRemoteProxyTestCase
subroutine runMethod(this)
use PF_UnixPipeInterfaces
class (RemoteProxyTestCase), intent(inout) :: this
character(:), allocatable :: line
character(:), allocatable :: file_name
integer :: line_number
character(:), allocatable :: num_exceptions_str
character(:), allocatable :: line_number_str
integer :: num_exceptions
character(:), allocatable :: message
integer :: i_exception
integer :: rc
call this%posix_file%timed_read_line(line, this%timer, rc)
if (rc /= SUCCESS) then
this%errored = .true.
call throw('RUNTIME-ERROR: failure to read start message from remote')
return
end if
if (line /= 'started: '// trim(this%getName())) then
this%errored = .true.
call throw('RUNTIME-ERROR: wrong start message from remote')
return
end if
call this%posix_file%timed_read_line(line, this%timer, rc)
if (rc /= SUCCESS) then
this%errored = .true.
call throw('RUNTIME-ERROR: failure to message from remote')
return
end if
if (line == 'ended: ' // trim(this%getName())) then ! success
this%errored = .false.
return
else ! probably failure messages
if (index(line, 'failed: # exceptions = ') /= 0) then
this%errored = .true.
call throw('RUNTIME-ERROR: misformatted message from remote')
return
end if
num_exceptions_str = content_scan(line)
read(num_exceptions_str,*) num_exceptions
do i_exception = 1, num_exceptions
! File name
call this%posix_file%timed_read_line(line, this%timer, rc)
if (rc /= SUCCESS) then
this%errored = .true.
call throw('RUNTIME-ERROR: failure to parse message from remote')
return
end if
file_name = content_scan(line)
! Line number
call this%posix_file%timed_read_line(line, this%timer, rc)
if (rc /= SUCCESS) then
this%errored = .true.
call throw('RUNTIME-ERROR: failure to parse message from remote')
return
end if
line_number_str = content_scan(line)
read(line_number_str,*) line_number
! Message
call this%posix_file%timed_read_line(line, this%timer, rc)
if (rc /= SUCCESS) then
this%errored = .true.
call throw('RUNTIME-ERROR: failure to parse message from remote')
return
end if
message = content_scan(line)
call throw(trim(message), SourceLocation(file_name, line_number))
end do
call this%posix_file%timed_read_line(line, this%timer, rc)
if (rc /= SUCCESS) then
this%errored = .true.
call throw('RUNTIME-ERROR: failure to message from remote')
return
end if
if (line == 'ended: ' // trim(this%getName())) then ! success
this%errored = .false.
return
else
this%errored = .true.
call throw('RUNTIME-ERROR: failure to message from remote')
return
end if
end if
contains
function content_scan(string) result(valueString)
character(len=*), intent(in) :: string
character(len=:), allocatable :: valueString
integer :: i0, i1
i0 = scan(string,'<<<') + 3
i1 = scan(string,'>>>',back=.true.) - 3
valueString = string(i0:i1)
end function content_scan
end subroutine runMethod
logical function encountered_errors(this)
class(RemoteProxyTestCase), intent(in) :: this
encountered_errors = this%errored
end function encountered_errors
end module PF_RemoteProxyTestCase