Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
e10019db
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e10019db
编写于
4月 19, 2017
作者:
A
Amador Pahim
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'ldoktor-mux-ids'
Signed-off-by:
N
Amador Pahim
<
apahim@redhat.com
>
上级
63ec0724
dd1919d4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
95 addition
and
5 deletion
+95
-5
avocado/core/mux.py
avocado/core/mux.py
+16
-2
avocado/core/tree.py
avocado/core/tree.py
+17
-2
selftests/functional/test_multiplex.py
selftests/functional/test_multiplex.py
+1
-1
selftests/unit/test_mux.py
selftests/unit/test_mux.py
+61
-0
未找到文件。
avocado/core/mux.py
浏览文件 @
e10019db
...
...
@@ -24,6 +24,7 @@ a custom Varianter plugin.
import
collections
import
itertools
import
re
import
sha
from
.
import
output
from
.
import
tree
...
...
@@ -163,6 +164,16 @@ class MuxPlugin(object):
self
.
root
=
root
self
.
mux_path
=
mux_path
self
.
debug
=
debug
self
.
variant_ids
=
self
.
_get_variant_ids
()
def
_get_variant_ids
(
self
):
variant_ids
=
[]
for
variant
in
MuxTree
(
self
.
root
):
variant
.
sort
(
key
=
lambda
x
:
x
.
path
)
fingerprint
=
"-"
.
join
(
_
.
fingerprint
()
for
_
in
variant
)
variant_ids
.
append
(
"-"
.
join
(
node
.
name
for
node
in
variant
)
+
'-'
+
sha
.
sha
(
fingerprint
).
hexdigest
()[:
4
])
return
variant_ids
def
__iter__
(
self
):
"""
...
...
@@ -170,8 +181,8 @@ class MuxPlugin(object):
"""
if
self
.
root
is
None
:
return
for
i
,
variant
in
enumerate
(
self
.
variants
,
1
):
yield
{
"variant_id"
:
i
,
for
vid
,
variant
in
itertools
.
izip
(
self
.
variant_ids
,
self
.
variants
):
yield
{
"variant_id"
:
vid
,
"variant"
:
variant
,
"mux_path"
:
self
.
mux_path
}
...
...
@@ -269,6 +280,9 @@ class MuxTreeNode(tree.TreeNode):
def
__repr__
(
self
):
return
'%s(name=%r)'
%
(
self
.
__class__
.
__name__
,
self
.
name
)
def
fingerprint
(
self
):
return
"%s%s"
%
(
super
(
MuxTreeNode
,
self
).
fingerprint
(),
self
.
ctrl
)
def
merge
(
self
,
other
):
"""
Merges `other` node into this one without checking the name of the
...
...
avocado/core/tree.py
浏览文件 @
e10019db
...
...
@@ -78,8 +78,17 @@ class TreeEnvironment(dict):
return
cpy
def
__str__
(
self
):
return
","
.
join
((
super
(
TreeEnvironment
,
self
).
__str__
(),
str
(
self
.
origin
),
str
(
self
.
filter_only
),
# Use __str__ instead of __repr__ to improve readability
if
self
:
_values
=
[
"%s: %s"
%
_
for
_
in
self
.
iteritems
()]
values
=
"{%s}"
%
", "
.
join
(
_values
)
_origin
=
[
"%s: %s"
%
(
key
,
node
.
path
)
for
key
,
node
in
self
.
origin
.
iteritems
()]
origin
=
"{%s}"
%
", "
.
join
(
_origin
)
else
:
values
=
"{}"
origin
=
"{}"
return
","
.
join
((
values
,
origin
,
str
(
self
.
filter_only
),
str
(
self
.
filter_out
)))
...
...
@@ -133,6 +142,12 @@ class TreeNode(object):
""" Inverted eq """
return
not
self
==
other
def
fingerprint
(
self
):
"""
Reports string which represents the value of this node.
"""
return
"%s%s"
%
(
self
.
path
,
self
.
environment
)
def
add_child
(
self
,
node
):
"""
Append node as child. Nodes with the same name gets merged into the
...
...
selftests/functional/test_multiplex.py
浏览文件 @
e10019db
...
...
@@ -15,7 +15,7 @@ basedir = os.path.abspath(basedir)
AVOCADO
=
os
.
environ
.
get
(
"UNITTEST_AVOCADO_CMD"
,
"./scripts/avocado"
)
DEBUG_OUT
=
"""Variant
16
: amd@examples/mux-environment.yaml, virtio@examples/mux-environment.yaml, mint@examples/mux-environment.yaml, debug@examples/mux-environment.yaml
DEBUG_OUT
=
"""Variant
mint-debug-amd-virtio-5e02
: amd@examples/mux-environment.yaml, virtio@examples/mux-environment.yaml, mint@examples/mux-environment.yaml, debug@examples/mux-environment.yaml
/distro/mint:init => systemv@examples/mux-environment.yaml:/distro/mint
/env/debug:opt_CFLAGS => -O0 -g@examples/mux-environment.yaml:/env/debug
/hw/cpu/amd:cpu_CFLAGS => -march=athlon64@examples/mux-environment.yaml:/hw/cpu/amd
...
...
selftests/unit/test_mux.py
浏览文件 @
e10019db
...
...
@@ -204,6 +204,27 @@ class TestMuxTree(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
self
.
tree
.
get_node
,
'/non-existing-node'
)
def
test_fingerprint_order
(
self
):
"""
Checks whether different order changes the fingerprint
"""
children1
=
(
tree
.
TreeNode
(
"child1"
),
tree
.
TreeNode
(
"child2"
))
tree1
=
tree
.
TreeNode
(
"root"
,
children
=
children1
)
children2
=
(
tree
.
TreeNode
(
"child2"
),
tree
.
TreeNode
(
"child1"
))
tree2
=
tree
.
TreeNode
(
"root"
,
children
=
children2
)
mux1
=
mux
.
MuxPlugin
()
mux2
=
mux
.
MuxPlugin
()
mux1
.
initialize_mux
(
tree1
,
""
,
False
)
mux2
.
initialize_mux
(
tree2
,
""
,
False
)
mux1
.
update_defaults
(
tree
.
TreeNode
())
mux2
.
update_defaults
(
tree
.
TreeNode
())
variant1
=
iter
(
mux1
).
next
()
variant2
=
iter
(
mux2
).
next
()
self
.
assertNotEqual
(
variant1
,
variant2
)
self
.
assertEqual
(
str
(
variant1
),
"{'mux_path': '', 'variant': "
"[TreeNode(name='child1'), TreeNode(name="
"'child2')], 'variant_id': 'child1-child2-9154'}"
)
class
TestMultiplex
(
unittest
.
TestCase
):
...
...
@@ -493,5 +514,45 @@ class TestPathParent(unittest.TestCase):
self
.
assertNotEqual
(
mux
.
path_parent
(
'/os/linux'
),
'/'
)
class
TestFingerprint
(
unittest
.
TestCase
):
def
test_fingerprint
(
self
):
"""
Verifies the fingerprint is correctly evaluated
"""
node1
=
tree
.
TreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
node1_fingerprint
=
node1
.
fingerprint
()
node1duplicate
=
tree
.
TreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
self
.
assertEqual
(
node1_fingerprint
,
node1duplicate
.
fingerprint
())
node1b_value
=
tree
.
TreeNode
(
"node1"
,
{
"foo"
:
"baz"
})
self
.
assertNotEqual
(
node1_fingerprint
,
node1b_value
.
fingerprint
())
node1b_name
=
tree
.
TreeNode
(
"node2"
,
{
"foo"
:
"bar"
})
self
.
assertNotEqual
(
node1_fingerprint
,
node1b_name
)
node1b_path
=
tree
.
TreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
tree
.
TreeNode
(
"root"
,
children
=
(
node1b_path
,))
self
.
assertNotEqual
(
node1_fingerprint
,
node1b_path
.
fingerprint
())
node1b_env_orig
=
tree
.
TreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
tree
.
TreeNode
(
"root"
,
{
"bar"
:
"baz"
},
children
=
(
node1b_env_orig
))
node1b_env_origb
=
tree
.
TreeNode
(
"node1"
,
{
"foo"
:
"bar"
,
"bar"
:
"baz"
})
tree
.
TreeNode
(
"root"
,
children
=
(
node1b_env_origb
,))
self
.
assertNotEqual
(
node1b_env_orig
.
fingerprint
(),
node1b_env_origb
.
fingerprint
())
def
test_tree_mux_node
(
self
):
"""
Check the extension of fingerprint in MuxTreeNode
"""
node1
=
tree
.
TreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
node1m
=
mux
.
MuxTreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
node1m_fingerprint
=
node1m
.
fingerprint
()
self
.
assertNotEqual
(
node1
.
fingerprint
(),
node1m_fingerprint
)
node1mduplicate
=
mux
.
MuxTreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
self
.
assertEqual
(
node1m_fingerprint
,
node1mduplicate
.
fingerprint
())
node1mb_ctrl
=
mux
.
MuxTreeNode
(
"node1"
,
{
"foo"
:
"bar"
})
node1mb_ctrl
.
ctrl
=
[
mux
.
Control
(
0
,
0
)]
self
.
assertNotEqual
(
node1m_fingerprint
,
node1mb_ctrl
.
fingerprint
())
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录