Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
e78d25e8
Commit
e78d25e8
authored
Sep 02, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few more tests
parent
b0cc1e34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
test/test_protocol.py
test/test_protocol.py
+12
-0
test/test_subprocess.py
test/test_subprocess.py
+22
-0
No files found.
test/test_protocol.py
View file @
e78d25e8
...
@@ -11,6 +11,16 @@ class TestServer(unittest.TestCase):
...
@@ -11,6 +11,16 @@ class TestServer(unittest.TestCase):
(
s0
,
s1
)
=
socket
.
socketpair
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
,
0
)
(
s0
,
s1
)
=
socket
.
socketpair
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
,
0
)
(
s2
,
s3
)
=
socket
.
socketpair
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
,
0
)
(
s2
,
s3
)
=
socket
.
socketpair
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
,
0
)
def
test_help
(
fd
):
fd
.
write
(
"HELP
\
n
"
)
# should be more than one line
self
.
assertEquals
(
fd
.
readline
()[
0
:
4
],
"200-"
)
while
True
:
l
=
fd
.
readline
()
self
.
assertEquals
(
l
[
0
:
3
],
"200"
)
if
l
[
3
]
==
' '
:
break
def
run_server
():
def
run_server
():
srv
=
netns
.
protocol
.
Server
(
s0
,
s0
)
srv
=
netns
.
protocol
.
Server
(
s0
,
s0
)
srv
.
run
()
srv
.
run
()
...
@@ -22,11 +32,13 @@ class TestServer(unittest.TestCase):
...
@@ -22,11 +32,13 @@ class TestServer(unittest.TestCase):
s
=
os
.
fdopen
(
s1
.
fileno
(),
"r+"
,
1
)
s
=
os
.
fdopen
(
s1
.
fileno
(),
"r+"
,
1
)
self
.
assertEquals
(
s
.
readline
()[
0
:
4
],
"220 "
)
self
.
assertEquals
(
s
.
readline
()[
0
:
4
],
"220 "
)
test_help
(
s
)
s
.
close
()
s
.
close
()
s0
.
close
()
s0
.
close
()
s
=
os
.
fdopen
(
s3
.
fileno
(),
"r+"
,
1
)
s
=
os
.
fdopen
(
s3
.
fileno
(),
"r+"
,
1
)
self
.
assertEquals
(
s
.
readline
()[
0
:
4
],
"220 "
)
self
.
assertEquals
(
s
.
readline
()[
0
:
4
],
"220 "
)
test_help
(
s
)
s
.
close
()
s
.
close
()
s2
.
close
()
s2
.
close
()
t
.
join
()
t
.
join
()
...
...
test/test_subprocess.py
View file @
e78d25e8
...
@@ -172,6 +172,28 @@ class TestSubprocess(unittest.TestCase):
...
@@ -172,6 +172,28 @@ class TestSubprocess(unittest.TestCase):
self
.
assertEquals
(
p
.
wait
(),
-
signal
.
SIGTERM
)
# no-op
self
.
assertEquals
(
p
.
wait
(),
-
signal
.
SIGTERM
)
# no-op
self
.
assertEquals
(
p
.
poll
(),
-
signal
.
SIGTERM
)
# no-op
self
.
assertEquals
(
p
.
poll
(),
-
signal
.
SIGTERM
)
# no-op
# destroy
p
=
Subprocess
(
node
,
[
'sleep'
,
'100'
])
pid
=
p
.
pid
os
.
kill
(
pid
,
0
)
# verify process still there
p
.
destroy
()
self
.
assertRaises
(
OSError
,
os
.
kill
,
pid
,
0
)
# should be dead by now
# forceful destroy
# Command: ignore SIGTERM, write \n to synchronise and then sleep while
# closing stdout (so _readall finishes)
cmd
=
'trap "" SIGTERM; echo; exec sleep 100 > /dev/null'
r
,
w
=
os
.
pipe
()
p
=
Subprocess
(
node
,
cmd
,
shell
=
True
,
stdout
=
w
)
os
.
close
(
w
)
self
.
assertEquals
(
_readall
(
r
),
"
\
n
"
)
# wait for trap to be installed
os
.
close
(
r
)
pid
=
p
.
pid
os
.
kill
(
pid
,
0
)
# verify process still there
p
.
destroy
()
self
.
assertRaises
(
OSError
,
os
.
kill
,
pid
,
0
)
# should be dead by now
p
=
Subprocess
(
node
,
[
'sleep'
,
'100'
])
p
=
Subprocess
(
node
,
[
'sleep'
,
'100'
])
os
.
kill
(
p
.
pid
,
signal
.
SIGTERM
)
os
.
kill
(
p
.
pid
,
signal
.
SIGTERM
)
time
.
sleep
(
0.2
)
time
.
sleep
(
0.2
)
...
...
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