Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
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
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
164cdd5c
Commit
164cdd5c
authored
8 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
UTScapy: fix keywords handling / inheritance
parent
6957d3c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/tools/UTscapy.py
+17
-9
17 additions, 9 deletions
scapy/tools/UTscapy.py
with
17 additions
and
9 deletions
scapy/tools/UTscapy.py
+
17
−
9
View file @
164cdd5c
...
@@ -112,11 +112,17 @@ class Format(EnumClass):
...
@@ -112,11 +112,17 @@ class Format(EnumClass):
class
TestClass
:
class
TestClass
:
def
__getitem__
(
self
,
item
):
def
__getitem__
(
self
,
item
):
return
getattr
(
self
,
item
)
return
getattr
(
self
,
item
)
def
add_keywords
(
self
,
kw
):
def
add_keywords
(
self
,
kws
):
if
kw
is
str
:
if
isinstance
(
kws
,
basestring
):
self
.
keywords
.
append
(
kw
)
kws
=
[
kws
]
else
:
for
kwd
in
kws
:
self
.
keywords
+=
kw
if
kwd
.
startswith
(
'
-
'
):
try
:
self
.
keywords
.
remove
(
kwd
[
1
:])
except
KeyError
:
pass
else
:
self
.
keywords
.
add
(
kwd
)
class
TestCampaign
(
TestClass
):
class
TestCampaign
(
TestClass
):
def
__init__
(
self
,
title
):
def
__init__
(
self
,
title
):
...
@@ -124,13 +130,14 @@ class TestCampaign(TestClass):
...
@@ -124,13 +130,14 @@ class TestCampaign(TestClass):
self
.
filename
=
None
self
.
filename
=
None
self
.
headcomments
=
""
self
.
headcomments
=
""
self
.
campaign
=
[]
self
.
campaign
=
[]
self
.
keywords
=
[]
self
.
keywords
=
set
()
self
.
crc
=
None
self
.
crc
=
None
self
.
sha
=
None
self
.
sha
=
None
self
.
preexec
=
None
self
.
preexec
=
None
self
.
preexec_output
=
None
self
.
preexec_output
=
None
def
add_testset
(
self
,
testset
):
def
add_testset
(
self
,
testset
):
self
.
campaign
.
append
(
testset
)
self
.
campaign
.
append
(
testset
)
testset
.
keywords
.
update
(
self
.
keywords
)
def
__iter__
(
self
):
def
__iter__
(
self
):
return
self
.
campaign
.
__iter__
()
return
self
.
campaign
.
__iter__
()
def
all_tests
(
self
):
def
all_tests
(
self
):
...
@@ -143,11 +150,12 @@ class TestSet(TestClass):
...
@@ -143,11 +150,12 @@ class TestSet(TestClass):
self
.
name
=
name
self
.
name
=
name
self
.
tests
=
[]
self
.
tests
=
[]
self
.
comments
=
""
self
.
comments
=
""
self
.
keywords
=
[]
self
.
keywords
=
set
()
self
.
crc
=
None
self
.
crc
=
None
self
.
expand
=
1
self
.
expand
=
1
def
add_test
(
self
,
test
):
def
add_test
(
self
,
test
):
self
.
tests
.
append
(
test
)
self
.
tests
.
append
(
test
)
test
.
keywords
.
update
(
self
.
keywords
)
def
__iter__
(
self
):
def
__iter__
(
self
):
return
self
.
tests
.
__iter__
()
return
self
.
tests
.
__iter__
()
...
@@ -160,7 +168,7 @@ class UnitTest(TestClass):
...
@@ -160,7 +168,7 @@ class UnitTest(TestClass):
self
.
res
=
True
# must be True at init to have a different truth value than None
self
.
res
=
True
# must be True at init to have a different truth value than None
self
.
output
=
""
self
.
output
=
""
self
.
num
=
-
1
self
.
num
=
-
1
self
.
keywords
=
[]
self
.
keywords
=
set
()
self
.
crc
=
None
self
.
crc
=
None
self
.
expand
=
1
self
.
expand
=
1
def
__nonzero__
(
self
):
def
__nonzero__
(
self
):
...
@@ -180,7 +188,7 @@ def parse_campaign_file(campaign_file):
...
@@ -180,7 +188,7 @@ def parse_campaign_file(campaign_file):
if
l
[
0
]
==
'
#
'
:
if
l
[
0
]
==
'
#
'
:
continue
continue
if
l
[
0
]
==
"
~
"
:
if
l
[
0
]
==
"
~
"
:
(
test
or
testset
or
campaign
_file
).
add_keywords
(
l
[
1
:].
split
())
(
test
or
testset
or
test_
campaign
).
add_keywords
(
l
[
1
:].
split
())
elif
l
[
0
]
==
"
%
"
:
elif
l
[
0
]
==
"
%
"
:
test_campaign
.
title
=
l
[
1
:].
strip
()
test_campaign
.
title
=
l
[
1
:].
strip
()
elif
l
[
0
]
==
"
+
"
:
elif
l
[
0
]
==
"
+
"
:
...
...
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