Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
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
Kirill Smelkov
pyrasite
Commits
8b3ae4c3
Commit
8b3ae4c3
authored
Mar 20, 2012
by
Luke Macken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for the PyrasiteIPC
parent
27bddfa5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
tests/test_ipc.py
tests/test_ipc.py
+63
-0
No files found.
tests/test_ipc.py
0 → 100644
View file @
8b3ae4c3
# This file is part of pyrasite.
#
# pyrasite is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyrasite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyrasite. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2011, 2012 Red Hat, Inc.
import
os
import
unittest
import
subprocess
import
pyrasite
class
TestIPC
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
p
=
subprocess
.
Popen
(
'python -c "import time; time.sleep(5.0)"'
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
self
.
ipc
=
pyrasite
.
PyrasiteIPC
(
self
.
p
.
pid
)
def
tearDown
(
self
):
self
.
p
.
kill
()
self
.
ipc
.
close
()
def
test_listen
(
self
):
self
.
ipc
.
listen
()
assert
self
.
ipc
.
server_sock
assert
self
.
ipc
.
hostname
assert
self
.
ipc
.
port
assert
self
.
ipc
.
server_sock
.
getsockname
()[
1
]
==
self
.
ipc
.
port
def
test_create_payload
(
self
):
self
.
ipc
.
listen
()
payload
=
self
.
ipc
.
create_payload
()
assert
os
.
path
.
exists
(
payload
)
code
=
open
(
payload
)
compile
(
code
.
read
(),
payload
,
'exec'
)
code
.
close
()
os
.
unlink
(
payload
)
def
test_connect
(
self
):
self
.
ipc
.
connect
()
assert
self
.
ipc
.
sock
assert
self
.
ipc
.
address
def
test_cmd
(
self
):
self
.
ipc
.
connect
()
assert
self
.
ipc
.
cmd
(
'print("mu")'
)
==
'mu
\
n
'
if
__name__
==
'__main__'
:
unittest
.
main
()
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