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
48812b4f
Commit
48812b4f
authored
Jul 22, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for foreign interfaces
parent
2436e476
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
21 deletions
+49
-21
t/test_interfaces.py
t/test_interfaces.py
+49
-21
No files found.
t/test_interfaces.py
View file @
48812b4f
...
@@ -32,13 +32,17 @@ class TestInterfaces(unittest.TestCase):
...
@@ -32,13 +32,17 @@ class TestInterfaces(unittest.TestCase):
self
.
assertFalse
(
devs
[
'lo'
][
'up'
])
self
.
assertFalse
(
devs
[
'lo'
][
'up'
])
self
.
assertTrue
(
ifaces
[
i
].
name
in
devs
)
self
.
assertTrue
(
ifaces
[
i
].
name
in
devs
)
node_devs
=
set
(
node0
.
get_interfaces
())
self
.
assertTrue
(
set
(
ifaces
).
issubset
(
node_devs
))
loopback
=
node_devs
-
set
(
ifaces
)
# should be!
self
.
assertEquals
(
len
(
loopback
),
1
)
self
.
assertEquals
(
loopback
.
pop
().
name
,
'lo'
)
devs
=
get_devs
()
devs
=
get_devs
()
for
i
in
range
(
5
):
for
i
in
range
(
5
):
peer_name
=
netns
.
iproute
.
get_if
(
ifaces
[
i
].
control_index
).
name
peer_name
=
netns
.
iproute
.
get_if
(
ifaces
[
i
].
control_index
).
name
self
.
assertTrue
(
peer_name
in
devs
)
self
.
assertTrue
(
peer_name
in
devs
)
self
.
assertEquals
(
set
(
ifaces
),
set
(
node0
.
get_interfaces
()))
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
def
test_interface_settings
(
self
):
def
test_interface_settings
(
self
):
node0
=
netns
.
Node
()
node0
=
netns
.
Node
()
...
@@ -84,25 +88,6 @@ class TestInterfaces(unittest.TestCase):
...
@@ -84,25 +88,6 @@ class TestInterfaces(unittest.TestCase):
# FIXME: get_stats
# FIXME: get_stats
#@test_util.skipUnless(os.getuid() == 0, "Test requires root privileges")
@
test_util
.
skip
(
"Not implemented"
)
def
test_interface_migration
(
self
):
node0
=
netns
.
Node
()
dummyname
=
"dummy%d"
%
os
.
getpid
()
self
.
assertEquals
(
os
.
system
(
"ip link add name %s type dummy"
%
dummyname
),
0
)
devs
=
get_devs
()
self
.
assertTrue
(
dummyname
in
devs
)
if0
=
node0
.
import_if
(
dummyname
)
if0
.
lladdr
=
'42:71:e0:90:ca:43'
if0
.
mtu
=
1400
devs
=
get_devs_netns
(
node0
)
self
.
assertTrue
(
if0
.
name
in
devs
)
self
.
assertEquals
(
devs
[
if0
.
name
][
'lladdr'
],
if0
.
lladdr
)
self
.
assertEquals
(
devs
[
if0
.
name
][
'mtu'
],
if0
.
mtu
)
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
def
test_interface_addresses
(
self
):
def
test_interface_addresses
(
self
):
node0
=
netns
.
Node
()
node0
=
netns
.
Node
()
...
@@ -130,6 +115,49 @@ class TestInterfaces(unittest.TestCase):
...
@@ -130,6 +115,49 @@ class TestInterfaces(unittest.TestCase):
self
.
assertTrue
(
len
(
if0
.
get_addresses
())
>=
2
)
self
.
assertTrue
(
len
(
if0
.
get_addresses
())
>=
2
)
self
.
assertEquals
(
if0
.
get_addresses
(),
devs
[
if0
.
name
][
'addr'
])
self
.
assertEquals
(
if0
.
get_addresses
(),
devs
[
if0
.
name
][
'addr'
])
class
TestWithDummy
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
cleanup
=
[]
@
test_util
.
skipUnless
(
os
.
getuid
()
==
0
,
"Test requires root privileges"
)
def
test_interface_migration
(
self
):
node
=
netns
.
Node
(
debug
=
1
)
dummyname
=
"dummy%d"
%
os
.
getpid
()
self
.
assertEquals
(
os
.
system
(
"ip link add name %s type dummy"
%
dummyname
),
0
)
devs
=
get_devs
()
self
.
assertTrue
(
dummyname
in
devs
)
dummyidx
=
devs
[
dummyname
][
'idx'
]
self
.
cleanup
+=
[(
dummyidx
,
None
)]
# Move manually
# import pdb; pdb.set_trace()
netns
.
iproute
.
change_netns
(
dummyidx
,
node
.
pid
)
self
.
cleanup
.
remove
((
dummyidx
,
None
))
self
.
cleanup
+=
[(
dummyidx
,
node
)]
node_devs
=
dict
([(
i
.
index
,
i
)
for
i
in
node
.
get_interfaces
()])
self
.
assertTrue
(
devs
[
dummyname
][
'idx'
]
in
node_devs
)
if0
=
node_devs
[
devs
[
dummyname
][
'idx'
]]
if0
.
lladdr
=
'42:71:e0:90:ca:43'
if0
.
mtu
=
1400
devs
=
get_devs_netns
(
node
)
self
.
assertTrue
(
if0
.
name
in
devs
)
self
.
assertEquals
(
devs
[
if0
.
name
][
'lladdr'
],
if0
.
lladdr
)
self
.
assertEquals
(
devs
[
if0
.
name
][
'mtu'
],
if0
.
mtu
)
def
tearDown
(
self
):
for
(
i
,
n
)
in
self
.
cleanup
:
if
n
:
j
=
[
j
for
j
in
n
.
get_interfaces
()
if
j
.
index
==
i
][
0
]
n
.
del_if
(
j
)
n
.
_slave
.
change_netns
(
i
,
os
.
getpid
())
iface
=
netns
.
iproute
.
get_if
(
i
)
#os.system("ip link del %s" % iface.name)
# FIXME: Links
# FIXME: Links
if
__name__
==
'__main__'
:
if
__name__
==
'__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