Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
32aac2be
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,发现更多精彩内容 >>
未验证
提交
32aac2be
编写于
8月 31, 2016
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'ldoktor/mux-yes2true2'
上级
f004abe2
6593c2d2
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
89 addition
and
27 deletion
+89
-27
avocado/core/multiplexer.py
avocado/core/multiplexer.py
+10
-15
avocado/core/runner.py
avocado/core/runner.py
+25
-1
avocado/core/tree.py
avocado/core/tree.py
+9
-2
avocado/utils/partition.py
avocado/utils/partition.py
+2
-1
docs/source/MultiplexConfig.rst
docs/source/MultiplexConfig.rst
+8
-0
examples/mux-selftest-advanced.yaml
examples/mux-selftest-advanced.yaml
+5
-0
selftests/unit/test_tree.py
selftests/unit/test_tree.py
+4
-1
selftests/unit/test_utils_partition.py
selftests/unit/test_utils_partition.py
+26
-7
未找到文件。
avocado/core/multiplexer.py
浏览文件 @
32aac2be
...
...
@@ -412,22 +412,17 @@ class Mux(object):
else
:
return
len
(
test_suite
)
def
itertests
(
self
,
template
):
def
itertests
(
self
):
"""
Processes the template and yields test definition with proper params
Yield variant-id and test params
:yield (variant-id, (list of leaves, list of multiplex paths))
"""
if
self
.
variants
:
# Copy template and modify it's params
i
=
None
i
f
self
.
_has_multiple_variants
:
for
i
,
variant
in
enumerate
(
self
.
variants
,
1
):
test_factory
=
[
template
[
0
],
template
[
1
].
copy
()]
if
"params"
in
test_factory
[
1
]:
msg
=
(
"Unable to multiplex test %s, params are already "
"present in test factory: %s"
%
(
test_factory
[
0
],
test_factory
[
1
]))
raise
ValueError
(
msg
)
test_factory
[
1
][
'params'
]
=
(
variant
,
self
.
_mux_path
)
yield
test_factory
,
i
if
self
.
_has_multiple_variants
else
None
if
i
is
None
:
# No variants, use template
yield
template
,
None
yield
i
,
(
variant
,
self
.
_mux_path
)
else
:
yield
None
,
(
iter
(
self
.
variants
).
next
(),
self
.
_mux_path
)
else
:
# No variants, use template
yield
templat
e
,
None
yield
Non
e
,
None
avocado/core/runner.py
浏览文件 @
32aac2be
...
...
@@ -454,6 +454,29 @@ class TestRunner(object):
return
False
return
True
@
staticmethod
def
_iter_variants
(
template
,
mux
):
"""
Iterate through variants and set the params/variants accordingly.
:param template: test template
:param mux: the Mux object containing the variants
:return: Yields tuple(test_factory including params, variant id)
:raises ValueError: When variant and template declare params.
"""
for
variant
,
params
in
mux
.
itertests
():
if
params
:
if
"params"
in
template
[
1
]:
msg
=
(
"Unable to multiplex test %s, params are already "
"present in test factory: %s"
%
(
template
[
0
],
template
[
1
]))
raise
ValueError
(
msg
)
factory
=
[
template
[
0
],
template
[
1
].
copy
()]
factory
[
1
][
"params"
]
=
params
else
:
factory
=
template
yield
factory
,
variant
def
run_suite
(
self
,
test_suite
,
mux
,
timeout
=
0
,
replay_map
=
None
,
test_result_total
=
0
):
"""
...
...
@@ -483,7 +506,8 @@ class TestRunner(object):
test_template
[
1
][
'base_logdir'
]
=
self
.
job
.
logdir
test_template
[
1
][
'job'
]
=
self
.
job
break_loop
=
False
for
test_factory
,
variant
in
mux
.
itertests
(
test_template
):
for
test_factory
,
variant
in
self
.
_iter_variants
(
test_template
,
mux
):
index
+=
1
test_parameters
=
test_factory
[
1
]
name
=
test_parameters
.
get
(
"name"
)
...
...
avocado/core/tree.py
浏览文件 @
32aac2be
...
...
@@ -373,7 +373,14 @@ def _create_from_yaml(path, cls_node=TreeNode):
def
mapping_to_tree_loader
(
loader
,
node
):
""" Maps yaml mapping tag to TreeNode structure """
_value
=
loader
.
construct_pairs
(
node
)
_value
=
[]
for
key_node
,
value_node
in
node
.
value
:
if
key_node
.
tag
.
startswith
(
'!'
):
# reflect tags everywhere
key
=
loader
.
construct_object
(
key_node
)
else
:
key
=
loader
.
construct_python_str
(
key_node
)
value
=
loader
.
construct_object
(
value_node
)
_value
.
append
((
key
,
value
))
objects
=
ListOfNodeObjects
()
for
name
,
values
in
_value
:
if
isinstance
(
values
,
ListOfNodeObjects
):
# New node from list
...
...
@@ -712,7 +719,7 @@ def tree_view(root, verbose=None, use_utf8=None):
else
:
val_prefix
=
' '
for
key
,
value
in
values
:
out
.
extend
(
prefixed_write
(
val_prefix
,
val
+
key
+
': '
,
out
.
extend
(
prefixed_write
(
val_prefix
,
"%s%s: "
%
(
val
,
key
)
,
value
))
if
node
.
children
:
for
child
in
node
.
children
[:
-
1
]:
...
...
avocado/utils/partition.py
浏览文件 @
32aac2be
...
...
@@ -159,7 +159,8 @@ class Partition(object):
"""
Format a partition to filesystem type
:param fstype: the filesystem type, e.g.. "ext3", "ext2"
:param fstype: the filesystem type, such as "ext3", "ext2". Defaults
to previously set type or "ext2" if none has set.
:param args: arguments to be passed to mkfs command.
"""
...
...
docs/source/MultiplexConfig.rst
浏览文件 @
32aac2be
...
...
@@ -54,6 +54,10 @@ They define context of the key=>value pairs allowing us to easily identify
for what this values might be used for and also it makes possible to define
multiple values of the same keys with different scope.
Due to their purpose the YAML automatic type conversion for nodes names
is disabled, so the value of node name is always as written in the yaml
file (unlike values, where `yes` converts to `True` and such).
Nodes are organized in parent-child relationship and together they create
a tree. To view this structure use ``avocado multiplex --tree <file>``::
...
...
@@ -117,6 +121,10 @@ The environment created for the nodes ``fedora`` and ``osx`` are:
- Node ``//devtools/fedora`` environment ``compiler: 'gcc'``, ``flags: ['-O2', '-Wall']``
- Node ``//devtools/osx`` environment ``compiler: 'clang'``, ``flags: ['-O2', '-arch i386', '-arch x86_64']``
Note that due to different usage of key and values in environment we disabled
the automatic value conversion for keys while keeping it enabled for values.
This means that the value can be of any YAML supported value, eg. bool, None,
list or custom type, while the key is always string.
Variants
========
...
...
examples/mux-selftest-advanced.yaml
浏览文件 @
32aac2be
...
...
@@ -28,3 +28,8 @@ new_node:
# not even planned)
!using
:
/absolutely/fresh/
new_value
:
"
something"
# Check that mapping keys are not converted to values, while values are
# while value between quotes stays as string.
on
:
on
:
on
true
:
"
true"
selftests/unit/test_tree.py
浏览文件 @
32aac2be
...
...
@@ -163,7 +163,7 @@ class TestTree(unittest.TestCase):
tree2
=
tree
.
create_from_yaml
([
'/:'
+
PATH_PREFIX
+
'examples/mux-'
'selftest-advanced.yaml'
])
exp
=
[
'intel'
,
'amd'
,
'arm'
,
'scsi'
,
'virtio'
,
'fedora'
,
'6'
,
'7'
,
'gentoo'
,
'mint'
,
'prod'
,
'new_node'
]
'7'
,
'gentoo'
,
'mint'
,
'prod'
,
'new_node'
,
'on'
]
act
=
tree2
.
get_leaves
()
oldroot
=
tree2
.
children
[
0
]
self
.
assertEqual
(
exp
,
act
)
...
...
@@ -176,6 +176,9 @@ class TestTree(unittest.TestCase):
oldroot
.
children
[
1
].
children
[
2
].
value
)
self
.
assertEqual
({
'new_value'
:
'something'
},
oldroot
.
children
[
3
].
children
[
0
].
children
[
0
].
value
)
# Convert values, but not keys
self
.
assertEqual
({
'on'
:
True
,
"true"
:
"true"
},
oldroot
.
children
[
4
].
value
)
# multiplex root (always True)
self
.
assertEqual
(
tree2
.
multiplex
,
None
)
# multiplex /virt/
...
...
selftests/unit/test_utils_partition.py
浏览文件 @
32aac2be
...
...
@@ -13,6 +13,7 @@ import time
from
flexmock
import
flexmock
,
flexmock_teardown
from
avocado.utils
import
partition
,
process
from
avocado.utils
import
path
as
utils_path
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
import
unittest2
as
unittest
# pylint: disable=E0401
...
...
@@ -20,19 +21,37 @@ else:
import
unittest
# pylint: disable=C0411
def
missing_binary
(
binary
):
try
:
utils_path
.
find_command
(
binary
)
return
False
except
utils_path
.
CmdNotFoundError
:
return
True
def
cannot_sudo
(
command
):
try
:
process
.
run
(
command
,
sudo
=
True
)
False
except
process
.
CmdError
:
return
True
class
TestPartition
(
unittest
.
TestCase
):
"""
Unit tests for avocado.utils.partition
"""
@
unittest
.
skipIf
(
process
.
system
(
"which mkfs.ext3"
,
ignore_status
=
True
),
"mkfs.ext3 is required for these tests to run."
)
@
unittest
.
skipIf
(
missing_binary
(
'mkfs.ext2'
),
"mkfs.ext2 is required for these tests to run."
)
@
unittest
.
skipIf
(
missing_binary
(
'sudo'
),
"sudo is required for these tests to run."
)
@
unittest
.
skipIf
(
cannot_sudo
(
'mount'
),
'current user must be allowed to run "mount" under sudo'
)
@
unittest
.
skipIf
(
cannot_sudo
(
'mkfs.ext2 -V'
),
'current user must be allowed to run "mkfs.ext2" under sudo'
)
def
setUp
(
self
):
try
:
process
.
system
(
"/bin/true"
,
sudo
=
True
)
except
process
.
CmdError
:
self
.
skipTest
(
"Sudo not available"
)
self
.
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
"avocado_"
+
__name__
)
self
.
mountpoint
=
os
.
path
.
join
(
self
.
tmpdir
,
"disk"
)
os
.
mkdir
(
self
.
mountpoint
)
...
...
@@ -63,7 +82,7 @@ class TestPartition(unittest.TestCase):
def
test_double_mount
(
self
):
""" Check the attempt for second mount fails """
self
.
disk
.
mkfs
(
"ext2"
)
self
.
disk
.
mkfs
()
self
.
disk
.
mount
()
self
.
assertIn
(
self
.
mountpoint
,
open
(
"/proc/mounts"
).
read
())
self
.
assertRaises
(
partition
.
PartitionError
,
self
.
disk
.
mount
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录