Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pavel Zhukov
Kea
Commits
a2a812ed
Commit
a2a812ed
authored
Jan 25, 2011
by
Michal 'vorner' Vaner
Browse files
Merge branch 'bug/msgq/test'
parents
3e5f7726
acc6a3ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/bin/msgq/tests/msgq_test.py
View file @
a2a812ed
...
...
@@ -117,7 +117,7 @@ class SendNonblock(unittest.TestCase):
Tests that the whole thing will not get blocked if someone does not read.
"""
def
terminate_check
(
self
,
task
,
timeout
=
1
):
def
terminate_check
(
self
,
task
,
timeout
=
1
0
):
"""
Runs task in separate process (task is a function) and checks
it terminates sooner than timeout.
...
...
@@ -161,16 +161,22 @@ class SendNonblock(unittest.TestCase):
Tries sending messages (and not reading them) until it either times
out (in blocking call, wrong) or closes it (correct).
"""
data
=
"data"
for
i
in
range
(
1
,
10
):
data
+=
data
self
.
terminate_check
(
lambda
:
self
.
infinite_sender
(
lambda
msgq
,
socket
:
msgq
.
sendmsg
(
socket
,
{},
{
"message"
:
"x"
})))
lambda
msgq
,
socket
:
msgq
.
sendmsg
(
socket
,
{},
{
"message"
:
data
})))
def
test_infinite_sendprepared
(
self
):
"""
Tries sending data (and not reading them) until it either times
out (in blocking call, wrong) or closes it (correct).
"""
data
=
b
"data"
for
i
in
range
(
1
,
10
):
data
+=
data
self
.
terminate_check
(
lambda
:
self
.
infinite_sender
(
lambda
msgq
,
socket
:
msgq
.
send_prepared_msg
(
socket
,
b
"
data
"
)))
lambda
msgq
,
socket
:
msgq
.
send_prepared_msg
(
socket
,
data
)))
def
send_many
(
self
,
data
):
"""
...
...
@@ -189,7 +195,7 @@ class SendNonblock(unittest.TestCase):
length
=
len
(
data
)
queue_pid
=
os
.
fork
()
if
queue_pid
==
0
:
signal
.
alarm
(
1
0
)
signal
.
alarm
(
3
0
)
msgq
.
register_socket
(
queue
)
msgq
.
run
()
else
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment