Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Olaf Bergmann
mininet
Commits
43f058df
Commit
43f058df
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
cleaned up and commented test_bind.py; added one new test
parent
01c0ef00
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
examples/test/test_bind.py
+32
-24
32 additions, 24 deletions
examples/test/test_bind.py
with
32 additions
and
24 deletions
examples/test/test_bind.py
+
32
−
24
View file @
43f058df
#!/usr/bin/env python
"""
TEST
"""
"""
Tests for bind.py
"""
import
unittest
import
pexpect
from
time
import
sleep
from
mininet.log
import
setLogLevel
from
mininet.clean
import
cleanup
,
sh
class
testBind
(
unittest
.
TestCase
):
"
Test ping with single switch topology (common code).
"
prompt
=
'
mininet>
'
def
connected
(
self
,
ip
):
"
check connected
"
p
=
pexpect
.
spawn
(
'
ssh -i /tmp/ssh/test_rsa %s
'
%
ip
)
while
True
:
index
=
p
.
expect
(
self
.
opts
)
if
index
==
0
:
print
p
.
match
.
group
(
0
)
p
.
sendline
(
'
yes
'
)
elif
index
==
1
:
return
False
elif
index
==
2
:
p
.
sendline
(
'
exit
'
)
p
.
wait
()
return
True
else
:
return
False
def
setUp
(
self
):
self
.
net
=
pexpect
.
spawn
(
'
python -m mininet.examples.bind
'
)
self
.
net
.
expect
(
"
Private Directories: \[([\w\s,
'
/]+)\]
"
)
...
...
@@ -41,11 +22,39 @@ def setUp( self ):
self
.
assertTrue
(
len
(
self
.
directories
)
>
0
)
def
testCreateFile
(
self
):
"
Create a file, a.txt, in the first private directory and verify
"
fileName
=
'
a.txt
'
directory
=
self
.
directories
[
0
]
self
.
net
.
sendline
(
'
h1 touch %s/%s; ls %s
'
%
(
directory
,
fileName
,
directory
)
)
path
=
directory
+
'
/
'
+
fileName
self
.
net
.
sendline
(
'
h1 touch %s; ls %s
'
%
(
path
,
directory
)
)
index
=
self
.
net
.
expect
(
[
fileName
,
self
.
prompt
]
)
self
.
assertTrue
(
index
==
0
)
self
.
net
.
expect
(
self
.
prompt
)
self
.
net
.
sendline
(
'
h1 rm %s
'
%
path
)
self
.
net
.
expect
(
self
.
prompt
)
def
testIsolation
(
self
):
"
Create a file in two hosts and verify that contents are different
"
fileName
=
'
b.txt
'
directory
=
self
.
directories
[
0
]
path
=
directory
+
'
/
'
+
fileName
contents
=
{
'
h1
'
:
'
1
'
,
'
h2
'
:
'
2
'
}
# Verify file doesn't exist, then write private copy of file
for
host
in
contents
:
value
=
contents
[
host
]
self
.
net
.
sendline
(
'
%s cat %s
'
%
(
host
,
path
)
)
self
.
net
.
expect
(
'
No such file
'
)
self
.
net
.
expect
(
self
.
prompt
)
self
.
net
.
sendline
(
'
%s echo %s > %s
'
%
(
host
,
value
,
path
)
)
self
.
net
.
expect
(
self
.
prompt
)
# Verify file contents
for
host
in
contents
:
value
=
contents
[
host
]
self
.
net
.
sendline
(
'
%s cat %s
'
%
(
host
,
path
)
)
self
.
net
.
expect
(
value
)
self
.
net
.
expect
(
self
.
prompt
)
self
.
net
.
sendline
(
'
%s rm %s
'
%
(
host
,
path
)
)
self
.
net
.
expect
(
self
.
prompt
)
# TODO: need more tests
...
...
@@ -54,6 +63,5 @@ def tearDown( self ):
self
.
net
.
wait
()
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
warning
'
)
unittest
.
main
()
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