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
7239f65b
Commit
7239f65b
authored
May 26, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename
parent
58c62d73
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1 addition
and
61 deletions
+1
-61
t/test_core.py
t/test_core.py
+0
-0
t/test_interfaces.py
t/test_interfaces.py
+1
-61
t/test_node.py
t/test_node.py
+0
-0
t/test_routing.py
t/test_routing.py
+0
-0
t/test_subprocess.py
t/test_subprocess.py
+0
-0
No files found.
t/core.py
→
t/
test_
core.py
View file @
7239f65b
File moved
t/interfaces.py
→
t/
test_
interfaces.py
View file @
7239f65b
#!/usr/bin/env python
# vim:ts=4:sw=4:et:ai:sts=4
from
test_util
import
get_devs
,
get_devs_netns
import
netns
import
os
import
re
import
subprocess
import
unittest
def
process_ipcmd
(
str
):
cur
=
None
out
=
{}
for
line
in
str
.
split
(
"
\
n
"
):
if
line
==
""
:
cur
=
None
continue
match
=
re
.
search
(
r'^(\
d+): (
\S+): <(\
S+)> m
tu (\
d+) qdisc (
\S+)'
,
line
)
if
match
!=
None
:
cur
=
match
.
group
(
2
)
out
[
cur
]
=
{
'idx'
:
match
.
group
(
1
),
'flags'
:
match
.
group
(
3
).
split
(
","
),
'mtu'
:
match
.
group
(
4
),
'qdisc'
:
match
.
group
(
5
),
'addr'
:
[]
}
out
[
cur
][
'up'
]
=
'UP'
in
out
[
cur
][
'flags'
]
continue
# Assume cur is defined
assert
cur
!=
None
match
=
re
.
search
(
r'^\
s+li
nk/\
S* ([
0-9a-f:]+)(?: |$)'
,
line
)
if
match
!=
None
:
out
[
cur
][
'lladdr'
]
=
match
.
group
(
1
)
continue
match
=
re
.
search
(
r'^\
s+i
net ([0-9.]+)/(\
d+)(?:
brd ([0-9.]+))?'
,
line
)
if
match
!=
None
:
out
[
cur
][
'addr'
].
append
({
'addr'
:
match
.
group
(
1
),
'plen'
:
int
(
match
.
group
(
2
)),
'bcast'
:
match
.
group
(
3
),
'family'
:
'inet'
})
continue
match
=
re
.
search
(
r'^\
s+i
net6 ([0-9a-f:]+)/(\
d+)(?: |$)
', line)
if match != None:
out[cur]['
addr
'].append({
'
addr
': match.group(1),
'
plen
': int(match.group(2)),
'
family
': '
inet6
'})
continue
match = re.search(r'
^
\
s
{
6
}
', line)
assert match != None
return out
def get_devs():
ipcmd = subprocess.Popen(["ip", "addr", "list"],
stdout = subprocess.PIPE)
(outdata, errdata) = ipcmd.communicate()
ipcmd.wait()
return process_ipcmd(outdata)
def get_devs_netns(node):
(outdata, errdata) = node.run_process(["ip", "addr", "list"])
return process_ipcmd(outdata)
class
TestInterfaces
(
unittest
.
TestCase
):
def
test_util
(
self
):
devs
=
get_devs
()
...
...
t/node.py
→
t/
test_
node.py
View file @
7239f65b
File moved
t/routing.py
→
t/
test_
routing.py
View file @
7239f65b
File moved
t/subprocess.py
→
t/
test_
subprocess.py
View file @
7239f65b
File moved
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