Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Migliore
VTK
Commits
7d4b71e3
Commit
7d4b71e3
authored
3 months ago
by
Lucas Givord
Browse files
Options
Downloads
Patches
Plain Diff
TestSocketComunicator: check breaking connection handling
parent
c86e3aaa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Parallel/Core/Testing/Cxx/TestSocketCommunicator.cxx
+81
-38
81 additions, 38 deletions
Parallel/Core/Testing/Cxx/TestSocketCommunicator.cxx
with
81 additions
and
38 deletions
Parallel/Core/Testing/Cxx/TestSocketCommunicator.cxx
+
81
−
38
View file @
7d4b71e3
...
...
@@ -13,6 +13,80 @@
#define MESSAGE(x) cout << (is_server ? "SERVER" : "CLIENT") << ":" x << endl;
//-----------------------------------------------------------------------------
// This unit test make sure that we can Send/Receive a int, vtkDataArray and a vtkDataSet
bool
TestSendReceiveDataArray
(
vtkSocketController
*
controller
,
bool
&
is_server
)
{
int
idata
=
0
;
double
ddata
=
0
;
vtkNew
<
vtkDoubleArray
>
dArray
;
vtkNew
<
vtkPolyData
>
pData
;
MESSAGE
(
"---- TestSendReceiveDataArray ----"
)
for
(
int
cc
=
0
;
cc
<
2
;
cc
++
)
{
MESSAGE
(
"---- Test stage "
<<
cc
<<
"----"
);
if
(
is_server
)
{
idata
=
10
;
ddata
=
10.0
;
dArray
->
SetNumberOfTuples
(
10
);
dArray
->
FillComponent
(
0
,
10.0
);
pData
->
Initialize
();
controller
->
Send
(
&
idata
,
1
,
1
,
101011
);
controller
->
Send
(
&
ddata
,
1
,
1
,
101012
);
controller
->
Send
(
dArray
,
1
,
101013
);
controller
->
Send
(
pData
,
1
,
101014
);
}
else
{
controller
->
Receive
(
&
idata
,
1
,
1
,
101011
);
controller
->
Receive
(
&
ddata
,
1
,
1
,
101012
);
controller
->
Receive
(
dArray
,
1
,
101013
);
controller
->
Receive
(
pData
,
1
,
101014
);
if
(
idata
!=
10
||
ddata
!=
10.0
||
dArray
->
GetNumberOfTuples
()
!=
10
||
dArray
->
GetValue
(
9
)
!=
10.0
)
{
MESSAGE
(
"ERROR: Communication failed!!!"
);
return
false
;
}
}
MESSAGE
(
" .... PASSED!"
);
// switch the flags so server becomes client and client becomes server and
// ship messages around.
is_server
=
!
is_server
;
}
MESSAGE
(
"All's well!"
);
return
true
;
}
//-----------------------------------------------------------------------------
// This unit test make sure that it is correctly checked, especially on Windows as it previously the
// server hangs indefinitely.
bool
TestConnectionAbortHandling
(
vtkSocketController
*
controller
,
bool
&
is_server
)
{
MESSAGE
(
"---- TestConnectionAbortHandling ----"
)
MESSAGE
(
"Check support of connection failure..."
)
vtkNew
<
vtkDoubleArray
>
dArray
;
if
(
is_server
)
{
controller
->
Receive
(
dArray
,
1
,
101013
);
MESSAGE
(
"Error is expected, continue."
)
}
else
{
MESSAGE
(
"Kill the client"
)
controller
->
TriggerBreakRMIs
();
}
return
true
;
}
//-----------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[])
{
vtkNew
<
vtkTesting
>
testing
;
...
...
@@ -54,45 +128,14 @@ int main(int argc, char* argv[])
}
MESSAGE
(
"Connected."
);
int
idata
=
0
;
double
ddata
=
0
;
vtkNew
<
vtkDoubleArray
>
dArray
;
vtkNew
<
vtkPolyData
>
pData
;
bool
succeed
=
true
;
succeed
&=
::
TestSendReceiveDataArray
(
controller
,
is_server
);
succeed
&=
::
TestConnectionAbortHandling
(
controller
,
is_server
);
for
(
int
cc
=
0
;
cc
<
2
;
cc
++
)
if
(
succeed
)
{
MESSAGE
(
"---- Test stage "
<<
cc
<<
"----"
);
if
(
is_server
)
{
idata
=
10
;
ddata
=
10.0
;
dArray
->
SetNumberOfTuples
(
10
);
dArray
->
FillComponent
(
0
,
10.0
);
pData
->
Initialize
();
controller
->
Send
(
&
idata
,
1
,
1
,
101011
);
controller
->
Send
(
&
ddata
,
1
,
1
,
101012
);
controller
->
Send
(
dArray
,
1
,
101013
);
controller
->
Send
(
pData
,
1
,
101014
);
}
else
{
controller
->
Receive
(
&
idata
,
1
,
1
,
101011
);
controller
->
Receive
(
&
ddata
,
1
,
1
,
101012
);
controller
->
Receive
(
dArray
,
1
,
101013
);
controller
->
Receive
(
pData
,
1
,
101014
);
if
(
idata
!=
10
||
ddata
!=
10.0
||
dArray
->
GetNumberOfTuples
()
!=
10
||
dArray
->
GetValue
(
9
)
!=
10.0
)
{
MESSAGE
(
"ERROR: Communication failed!!!"
);
return
EXIT_FAILURE
;
}
}
MESSAGE
(
" .... PASSED!"
);
// switch the flags so server becomes client and client becomes server and
// ship messages around.
is_server
=
!
is_server
;
return
EXIT_SUCCESS
;
}
MESSAGE
(
"All's well!"
);
return
EXIT_
SUCCESS
;
return
EXIT_
FAILURE
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment