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
12450b7c
Commit
12450b7c
authored
Jan 04, 2012
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for tun interfaces
parent
f3f5f8d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
32 deletions
+41
-32
test/test_core.py
test/test_core.py
+41
-32
No files found.
test/test_core.py
View file @
12450b7c
...
...
@@ -121,10 +121,44 @@ class TestGlobal(unittest.TestCase):
self
.
assertEquals
(
a1
.
wait
(),
0
)
self
.
assertEquals
(
a2
.
wait
(),
0
)
def
_forward_packets
(
self
,
subproc
,
if1
,
if2
):
while
(
True
):
ready
=
select
.
select
([
if1
.
fd
,
if2
.
fd
],
[],
[],
0.1
)[
0
]
if
ready
:
s
=
os
.
read
(
ready
[
0
],
65536
)
if
ready
[
0
]
==
if1
.
fd
:
os
.
write
(
if2
.
fd
,
s
)
else
:
os
.
write
(
if1
.
fd
,
s
)
if
not
s
:
break
if
subproc
.
poll
()
!=
None
:
break
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
def
test_run_ping_tun
(
self
):
"""This test simulates a point to point connection between two hosts
using two tun devices."""
n1
=
nemu
.
Node
()
n2
=
nemu
.
Node
()
# Use PI, so that's tested too.
tun1
=
n1
.
add_tun
(
use_pi
=
True
)
tun2
=
n2
.
add_tun
(
use_pi
=
True
)
tun1
.
up
=
tun2
.
up
=
True
tun1
.
add_v4_address
(
'10.0.1.1'
,
24
)
tun2
.
add_v4_address
(
'10.0.1.2'
,
24
)
null
=
file
(
'/dev/null'
,
'wb'
)
a
=
n1
.
Popen
([
'ping'
,
'-qc1'
,
'10.0.1.2'
],
stdout
=
null
)
self
.
_forward_packets
(
a
,
tun1
,
tun2
)
self
.
assertEquals
(
a
.
wait
(),
0
)
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
def
test_run_ping_tap
(
self
):
"""This test simulates a point to point connection between two hosts
using two tap devices"""
using two tap devices
.
"""
n1
=
nemu
.
Node
()
n2
=
nemu
.
Node
()
...
...
@@ -134,34 +168,22 @@ class TestGlobal(unittest.TestCase):
tap1
.
add_v4_address
(
'10.0.1.1'
,
24
)
tap2
.
add_v4_address
(
'10.0.1.2'
,
24
)
null
=
file
(
'/dev/null'
,
'wb'
)
a
=
n1
.
Popen
([
'ping'
,
'-qc1'
,
'10.0.1.2'
],
stdout
=
null
)
while
(
True
):
ready
=
select
.
select
([
tap1
.
fd
,
tap2
.
fd
],
[],
[],
0.1
)[
0
]
if
ready
:
s
=
os
.
read
(
ready
[
0
],
65536
)
if
ready
[
0
]
==
tap1
.
fd
:
os
.
write
(
tap2
.
fd
,
s
)
else
:
os
.
write
(
tap1
.
fd
,
s
)
if
not
s
:
break
if
a
.
poll
()
!=
None
:
break
self
.
_forward_packets
(
a
,
tap1
,
tap2
)
self
.
assertEquals
(
a
.
wait
(),
0
)
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
def
test_run_ping_tap_routing
(
self
):
"""This test simulates a point to point connection between two hosts
using two tap devices"""
using two tap devices, and normal connections with other two, to use
routing."""
n1
=
nemu
.
Node
()
n2
=
nemu
.
Node
()
n3
=
nemu
.
Node
()
n4
=
nemu
.
Node
()
i1
=
n1
.
add_if
()
i2
=
n2
.
add_if
()
tap1
=
n2
.
add_tap
()
...
...
@@ -197,20 +219,7 @@ class TestGlobal(unittest.TestCase):
null
=
file
(
'/dev/null'
,
'wb'
)
a
=
n1
.
Popen
([
'ping'
,
'-qc1'
,
'10.0.2.2'
],
stdout
=
null
)
while
(
True
):
ready
=
select
.
select
([
tap1
.
fd
,
tap2
.
fd
],
[],
[],
0.1
)[
0
]
if
ready
:
s
=
os
.
read
(
ready
[
0
],
65536
)
if
ready
[
0
]
==
tap1
.
fd
:
os
.
write
(
tap2
.
fd
,
s
)
else
:
os
.
write
(
tap1
.
fd
,
s
)
if
not
s
:
break
if
a
.
poll
()
!=
None
:
break
self
.
_forward_packets
(
a
,
tap1
,
tap2
)
self
.
assertEquals
(
a
.
wait
(),
0
)
class
TestX11
(
unittest
.
TestCase
):
...
...
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