Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-orbit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Katerina Roukounaki
cloud-orbit
Commits
006a680d
Commit
006a680d
authored
Nov 25, 2014
by
Yiannis Tsiouris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix indentation + warnings
parent
7dd65e2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
33 deletions
+29
-33
Tests.hs
Tests.hs
+29
-33
No files found.
Tests.hs
View file @
006a680d
import
Control.Concurrent.MVar
(
MVar
,
putMVar
,
newEmptyMVar
,
takeMVar
)
import
Control.Concurrent.MVar
(
MVar
,
putMVar
,
newEmptyMVar
,
takeMVar
)
import
Control.Distributed.Process
import
Control.Distributed.Process
import
Control.Distributed.Process.Node
import
Control.Distributed.Process.Node
import
qualified
Network.Transport
as
NT
(
Transport
)
import
qualified
Network.Transport
as
NT
(
Transport
)
import
Network.Transport.TCP
import
Network.Transport.TCP
import
Prelude
hiding
(
seq
)
import
Prelude
hiding
(
seq
)
import
Test.Framework
(
Test
,
testGroup
,
defaultMain
)
import
Test.Framework
(
Test
,
testGroup
,
defaultMain
)
import
Test.Framework.Providers.HUnit
(
testCase
)
import
Test.Framework.Providers.HUnit
(
testCase
)
import
Test.HUnit
(
Assertion
,
assertFailure
)
import
Test.HUnit
(
Assertion
)
import
Test.HUnit.Base
(
assertBool
)
import
Test.HUnit.Base
(
assertBool
)
import
Bench
(
seq
)
import
Bench
(
seq
)
...
@@ -17,36 +19,30 @@ import Utils
...
@@ -17,36 +19,30 @@ import Utils
testSeqShort
::
TestResult
String
->
Process
()
testSeqShort
::
TestResult
String
->
Process
()
testSeqShort
result
=
do
testSeqShort
result
=
do
r
<-
seq
gg13
11
x
<-
seq
gg13
11
stash
result
r
stash
result
x
testSeqIntermediate
::
TestResult
String
->
Process
()
testSeqIntermediate
::
TestResult
String
->
Process
()
testSeqIntermediate
result
=
do
testSeqIntermediate
result
=
do
r
<-
seq
gg124
157
x
<-
seq
gg124
157
stash
result
r
stash
result
x
testSeqLong
::
TestResult
String
->
Process
()
testSeqLong
::
TestResult
String
->
Process
()
testSeqLong
result
=
do
testSeqLong
result
=
do
r
<-
seq
gg1245
157
x
<-
seq
gg1245
157
stash
result
r
stash
result
x
-- Batch the tests
-- Batch the tests
tests
::
LocalNode
->
[
Test
]
tests
::
LocalNode
->
[
Test
]
tests
localNode
=
[
tests
localNode
=
[
testGroup
"Sequential Tests"
[
testGroup
"Sequential Tests"
[
testCase
"testSeqShort"
testCase
"testSeqShort"
(
delayedAssertion
(
delayedAssertion
"short"
localNode
"{size,10}"
testSeqShort
)
"short"
,
testCase
"testSeqIntermediate"
localNode
"{size,10}"
testSeqShort
)
(
delayedAssertion
"intermediate"
localNode
"{size,133}"
testSeqIntermediate
)
,
testCase
"testSeqIntermediate"
,
testCase
"testSeqLong"
(
delayedAssertion
(
delayedAssertion
"long"
localNode
"{size,134}"
testSeqLong
)
"intermediate"
localNode
"{size,133}"
testSeqIntermediate
)
,
testCase
"testSeqLong"
(
delayedAssertion
"long"
localNode
"{size,134}"
testSeqLong
)
]
]
]
]
...
@@ -54,9 +50,9 @@ tests localNode = [
...
@@ -54,9 +50,9 @@ tests localNode = [
orbitTests
::
NT
.
Transport
->
IO
[
Test
]
orbitTests
::
NT
.
Transport
->
IO
[
Test
]
orbitTests
transport
=
do
orbitTests
transport
=
do
localNode
<-
newLocalNode
transport
rtable
localNode
<-
newLocalNode
transport
rtable
let
testData
=
tests
localNode
let
testData
=
tests
localNode
return
testData
return
testData
where
rtable
::
RemoteTable
where
rtable
::
RemoteTable
rtable
=
MasterWorker
.
__remoteTable
initRemoteTable
rtable
=
MasterWorker
.
__remoteTable
initRemoteTable
...
@@ -78,20 +74,20 @@ stash mvar x = liftIO $ putMVar mvar x
...
@@ -78,20 +74,20 @@ stash mvar x = liftIO $ putMVar mvar x
delayedAssertion
::
(
Eq
a
)
=>
String
->
LocalNode
->
a
->
delayedAssertion
::
(
Eq
a
)
=>
String
->
LocalNode
->
a
->
(
TestResult
a
->
Process
()
)
->
Assertion
(
TestResult
a
->
Process
()
)
->
Assertion
delayedAssertion
note
localNode
expected
testProc
=
do
delayedAssertion
note
localNode
expected
testProc
=
do
result
<-
newEmptyMVar
result
<-
newEmptyMVar
_
<-
forkProcess
localNode
$
testProc
result
_
<-
forkProcess
localNode
$
testProc
result
assertComplete
note
result
expected
assertComplete
note
result
expected
-- | Takes the value of @mv@ (using @takeMVar@) and asserts that it matches @a@
-- | Takes the value of @mv@ (using @takeMVar@) and asserts that it matches @a@
assertComplete
::
(
Eq
a
)
=>
String
->
MVar
a
->
a
->
IO
()
assertComplete
::
(
Eq
a
)
=>
String
->
MVar
a
->
a
->
IO
()
assertComplete
msg
mv
a
=
do
assertComplete
msg
mv
a
=
do
b
<-
takeMVar
mv
b
<-
takeMVar
mv
assertBool
msg
(
a
==
b
)
assertBool
msg
(
a
==
b
)
-- | Given a @builder@ function, make and run a test suite on a single transport
-- | Given a @builder@ function, make and run a test suite on a single transport
testMain
::
(
NT
.
Transport
->
IO
[
Test
])
->
IO
()
testMain
::
(
NT
.
Transport
->
IO
[
Test
])
->
IO
()
testMain
builder
=
do
testMain
builder
=
do
Right
(
transport
,
_
)
<-
createTransportExposeInternals
Right
(
transport
,
_
)
<-
"127.0.0.1"
"10501"
defaultTCPParameters
createTransportExposeInternals
"127.0.0.1"
"10501"
defaultTCPParameters
testData
<-
builder
transport
testData
<-
builder
transport
defaultMain
testData
defaultMain
testData
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment