Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
a5ba88f0
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,发现更多精彩内容 >>
提交
a5ba88f0
编写于
5月 16, 2015
作者:
R
Rudá Moura
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #600 from ldoktor/mymux3
avocado.multiplexer: Use !mux and support for recursive mux [v3]
上级
2bfbfdc6
d727bfe0
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
628 addition
and
593 deletion
+628
-593
avocado/core/tree.py
avocado/core/tree.py
+12
-10
avocado/multiplexer.py
avocado/multiplexer.py
+75
-117
docs/source/MultiplexConfig.rst
docs/source/MultiplexConfig.rst
+317
-282
docs/source/WritingTests.rst
docs/source/WritingTests.rst
+103
-60
examples/mux-environment.yaml
examples/mux-environment.yaml
+4
-4
examples/mux-selftest-advanced.yaml
examples/mux-selftest-advanced.yaml
+2
-9
examples/mux-selftest-distro.yaml
examples/mux-selftest-distro.yaml
+3
-2
examples/mux-selftest-params.yaml
examples/mux-selftest-params.yaml
+2
-2
examples/mux-selftest.yaml
examples/mux-selftest.yaml
+6
-6
examples/tests/cabort.py
examples/tests/cabort.py
+1
-1
examples/tests/datadir.py
examples/tests/datadir.py
+2
-1
examples/tests/doublefree.py
examples/tests/doublefree.py
+2
-1
examples/tests/doublefree_nasty.py
examples/tests/doublefree_nasty.py
+1
-1
examples/tests/doublefree_nasty.py.data/iterations.yaml
examples/tests/doublefree_nasty.py.data/iterations.yaml
+1
-1
examples/tests/env_variables.sh.data/env_variables.yaml
examples/tests/env_variables.sh.data/env_variables.yaml
+1
-0
examples/tests/fiotest.py
examples/tests/fiotest.py
+3
-2
examples/tests/linuxbuild.py
examples/tests/linuxbuild.py
+2
-2
examples/tests/modify_variable.py
examples/tests/modify_variable.py
+1
-1
examples/tests/multiplextest.py
examples/tests/multiplextest.py
+14
-12
examples/tests/multiplextest.py.data/multiplextest.yaml
examples/tests/multiplextest.py.data/multiplextest.yaml
+11
-11
examples/tests/raise.py
examples/tests/raise.py
+3
-2
examples/tests/raise.py.data/raise.yaml
examples/tests/raise.py.data/raise.yaml
+1
-0
examples/tests/sleeptenmin.py
examples/tests/sleeptenmin.py
+3
-3
examples/tests/sleeptenmin.py.data/sleeptenmin.mplx
examples/tests/sleeptenmin.py.data/sleeptenmin.mplx
+0
-20
examples/tests/sleeptenmin.py.data/sleeptenmin.yaml
examples/tests/sleeptenmin.py.data/sleeptenmin.yaml
+18
-0
examples/tests/sleeptest.py.data/sleeptest.yaml
examples/tests/sleeptest.py.data/sleeptest.yaml
+1
-1
examples/tests/synctest.py
examples/tests/synctest.py
+4
-4
examples/tests/synctest.py.data/synctest.yaml
examples/tests/synctest.py.data/synctest.yaml
+2
-2
examples/tests/timeouttest.py
examples/tests/timeouttest.py
+1
-1
examples/tests/whiteboard.py
examples/tests/whiteboard.py
+4
-4
examples/tests/whiteboard.py.data/whiteboard.yaml
examples/tests/whiteboard.py.data/whiteboard.yaml
+3
-3
selftests/all/unit/avocado/multiplexer_unittest.py
selftests/all/unit/avocado/multiplexer_unittest.py
+18
-21
selftests/all/unit/avocado/tree_unittest.py
selftests/all/unit/avocado/tree_unittest.py
+7
-7
未找到文件。
avocado/core/tree.py
浏览文件 @
a5ba88f0
...
...
@@ -56,7 +56,7 @@ YAML_INCLUDE = 0
YAML_USING
=
1
YAML_REMOVE_NODE
=
2
YAML_REMOVE_VALUE
=
3
YAML_
JOIN
=
4
YAML_
MUX
=
4
__RE_FILE_SPLIT
=
re
.
compile
(
r
'(?<!\\):'
)
# split by ':' but not '\\:'
__RE_FILE_SUBS
=
re
.
compile
(
r
'(?<!\\)\\:'
)
# substitute '\\:' but not '\\\\:'
...
...
@@ -89,7 +89,7 @@ class TreeNode(object):
self
.
_environment
=
None
self
.
environment_origin
=
{}
self
.
ctrl
=
[]
self
.
multiplex
=
Tru
e
self
.
multiplex
=
Fals
e
for
child
in
children
:
self
.
add_child
(
child
)
...
...
@@ -159,7 +159,7 @@ class TreeNode(object):
remove
.
append
(
key
)
for
key
in
remove
:
self
.
value
.
pop
(
key
,
None
)
self
.
multiplex
&
=
other
.
multiplex
self
.
multiplex
=
other
.
multiplex
self
.
value
.
update
(
other
.
value
)
for
child
in
other
.
children
:
self
.
add_child
(
child
)
...
...
@@ -294,6 +294,8 @@ class TreeNode(object):
node_name
=
', '
.
join
(
map
(
str
,
[
getattr
(
self
,
v
)
for
v
in
attributes
if
hasattr
(
self
,
v
)]))
if
self
.
multiplex
:
node_name
+=
"-<>"
length
=
max
(
2
,
(
len
(
node_name
)
+
1
)
if
not
self
.
children
or
show_internal
else
3
)
pad
=
' '
*
length
...
...
@@ -384,8 +386,8 @@ def _create_from_yaml(path, cls_node=TreeNode):
elif
value
[
0
].
code
==
YAML_REMOVE_VALUE
:
value
[
0
].
value
=
value
[
1
]
# set the name
node
.
ctrl
.
append
(
value
[
0
])
elif
value
[
0
].
code
==
YAML_
JOIN
:
node
.
multiplex
=
Fals
e
elif
value
[
0
].
code
==
YAML_
MUX
:
node
.
multiplex
=
Tru
e
else
:
node
.
value
[
value
[
0
]]
=
value
[
1
]
if
using
:
...
...
@@ -416,15 +418,15 @@ def _create_from_yaml(path, cls_node=TreeNode):
objects
.
append
(
Value
((
name
,
values
)))
return
objects
def
join
_loader
(
loader
,
obj
):
def
mux
_loader
(
loader
,
obj
):
"""
Special !
join loader which allows to tag node as 'multiplex = Fals
e'.
Special !
mux loader which allows to tag node as 'multiplex = Tru
e'.
"""
if
not
isinstance
(
obj
,
yaml
.
ScalarNode
):
objects
=
mapping_to_tree_loader
(
loader
,
obj
)
else
:
# This means it's empty node. Don't call mapping_to_tree_loader
objects
=
ListOfNodeObjects
()
objects
.
append
((
Control
(
YAML_
JOIN
),
None
))
objects
.
append
((
Control
(
YAML_
MUX
),
None
))
return
objects
Loader
.
add_constructor
(
u
'!include'
,
...
...
@@ -435,7 +437,7 @@ def _create_from_yaml(path, cls_node=TreeNode):
lambda
loader
,
node
:
Control
(
YAML_REMOVE_NODE
))
Loader
.
add_constructor
(
u
'!remove_value'
,
lambda
loader
,
node
:
Control
(
YAML_REMOVE_VALUE
))
Loader
.
add_constructor
(
u
'!
join'
,
join
_loader
)
Loader
.
add_constructor
(
u
'!
mux'
,
mux
_loader
)
Loader
.
add_constructor
(
yaml
.
resolver
.
BaseResolver
.
DEFAULT_MAPPING_TAG
,
mapping_to_tree_loader
)
...
...
@@ -456,7 +458,7 @@ def _create_from_yaml(path, cls_node=TreeNode):
# Add prefix
if
using
:
loaded_tree
=
cls_node
(
using
.
pop
(),
children
=
loaded_tree
.
children
)
loaded_tree
.
name
=
using
.
pop
(
)
while
True
:
if
not
using
:
break
...
...
avocado/multiplexer.py
浏览文件 @
a5ba88f0
...
...
@@ -19,6 +19,7 @@
Multiplex and create variants.
"""
import
collections
import
itertools
import
logging
import
re
...
...
@@ -29,47 +30,68 @@ from avocado.core import tree
MULTIPLEX_CAPABLE
=
tree
.
MULTIPLEX_CAPABLE
def
tree2pools
(
node
,
mux
=
True
):
class
MuxTree
(
object
):
"""
Process tree and flattens the structure to remaining leaves and
list of lists of leaves per each multiplex group.
:param node: Node to start with
:return: tuple(`leaves`, `pools`), where `leaves` are directly inherited
leaves of this node (no other multiplex in the middle). `pools` is list of
lists of directly inherited leaves of the nested multiplex domains.
Object representing part of the tree from the root to leaves or another
multiplex domain. Recursively it creates multiplexed variants of the full
tree.
"""
leaves
=
[]
pools
=
[]
if
mux
:
# TODO: Get this multiplex leaves filters and store them in this pool
# to support 2nd level filtering
new_leave
s
=
[]
for
child
in
node
.
children
:
if
child
.
is_leaf
:
new_leaves
.
append
(
child
)
def
__init__
(
self
,
root
):
"""
:param root: Root of this tree slice
"""
self
.
pool
s
=
[]
for
node
in
self
.
_iter_mux_leaves
(
root
)
:
if
node
.
is_leaf
:
self
.
pools
.
append
(
node
)
else
:
_leaves
,
_pools
=
tree2pools
(
child
,
node
.
multiplex
)
new_leaves
.
extend
(
_leaves
)
# TODO: For 2nd level filters store this separately in case
# this branch is filtered out
pools
.
extend
(
_pools
)
if
new_leaves
:
# TODO: Filter the new_leaves (and new_pools) before merging
# into pools
pools
.
append
(
new_leaves
)
else
:
for
child
in
node
.
children
:
if
child
.
is_leaf
:
leaves
.
append
(
child
)
pools
=
[]
for
mux_child
in
node
.
children
:
pools
.
append
(
MuxTree
(
mux_child
))
self
.
pools
.
append
(
pools
)
@
staticmethod
def
_iter_mux_leaves
(
node
):
""" yield leaves or muxes of the tree """
queue
=
collections
.
deque
()
while
node
is
not
None
:
if
node
.
is_leaf
or
node
.
multiplex
:
yield
node
else
:
_leaves
,
_pools
=
tree2pools
(
child
,
node
.
multiplex
)
leaves
.
extend
(
_leaves
)
pools
.
extend
(
_pools
)
return
leaves
,
pools
queue
.
extendleft
(
reversed
(
node
.
children
))
try
:
node
=
queue
.
popleft
()
except
IndexError
:
raise
StopIteration
def
__iter__
(
self
):
"""
Iterates through variants
"""
pools
=
[]
for
pool
in
self
.
pools
:
if
isinstance
(
pool
,
list
):
pools
.
append
(
itertools
.
chain
(
*
pool
))
else
:
pools
.
append
([
pool
])
pools
=
itertools
.
product
(
*
pools
)
while
True
:
# TODO: Implement 2nd level filteres here
# TODO: This part takes most of the time, optimize it
dirty
=
pools
.
next
()
ret
=
[]
for
pool
in
dirty
:
if
isinstance
(
pool
,
list
):
ret
.
extend
(
pool
)
else
:
ret
.
append
(
pool
)
yield
ret
def
parse
_yamls
(
input_yamls
,
filter_only
=
None
,
filter_out
=
None
,
debug
=
False
):
def
multiplex
_yamls
(
input_yamls
,
filter_only
=
None
,
filter_out
=
None
,
debug
=
False
):
if
filter_only
is
None
:
filter_only
=
[]
if
filter_out
is
None
:
...
...
@@ -77,20 +99,8 @@ def parse_yamls(input_yamls, filter_only=None, filter_out=None,
input_tree
=
tree
.
create_from_yaml
(
input_yamls
,
debug
)
# TODO: Process filters and multiplex simultaneously
final_tree
=
tree
.
apply_filters
(
input_tree
,
filter_only
,
filter_out
)
leaves
,
pools
=
tree2pools
(
final_tree
,
final_tree
.
multiplex
)
if
leaves
:
# Add remaining leaves (they are not variants, only endpoints
pools
.
extend
(
leaves
)
return
pools
def
multiplex_pools
(
pools
):
return
itertools
.
product
(
*
pools
)
def
multiplex_yamls
(
input_yamls
,
filter_only
=
None
,
filter_out
=
None
,
debug
=
False
):
pools
=
parse_yamls
(
input_yamls
,
filter_only
,
filter_out
,
debug
)
return
multiplex_pools
(
pools
)
result
=
MuxTree
(
final_tree
)
return
result
# TODO: Create multiplexer plugin and split these functions into multiple files
...
...
@@ -179,7 +189,8 @@ class AvocadoParams(object):
def
log
(
self
,
key
,
path
,
default
,
value
):
""" Predefined format for displaying params query """
self
.
_log
(
"PARAMS (key=%s, path=%s, default=%s) => %r"
,
key
,
path
,
default
,
value
)
self
.
_log
(
"PARAMS (key=%s, path=%s, default=%s) => %r"
,
key
,
path
,
default
,
value
)
def
_get_matching_leaves
(
self
,
path
,
leaves
):
"""
...
...
@@ -242,63 +253,14 @@ class AvocadoParams(object):
logging
.
getLogger
(
"avocado.test"
).
warn
(
msg
)
return
self
.
get
(
attr
)
def
get
(
self
,
*
args
,
**
kwargs
):
"""
Retrieve params
Old API: ``params.get(key, failobj=None)`` (any matching param)
New API: ``params.get(key, path=$MUX_ENTRY/*, default=None)``
As old and new API overlaps, you must use all 3 arguments or
explicitely use key argument "path" or "default".
"""
def
compatibility
(
args
,
kwargs
):
"""
Be 100% compatible with old API while allow _SOME OF_ the new APIs
calls:
OLD: get(key), get(key, default), get(key, failobj=default)
NEW: get(key, path, default), get(key, path=path),
get(key, default=default)
:warning: We are unable to distinguish old get(key, default) vs.
new get(key, path), therefor if you want to use the new
API you must specify path/default using named arguments
or supply all 3 arguments:
get(key, path, default), get(key, path=path),
get(key, default=default).
This will be removed in final version.
"""
if
len
(
args
)
<
1
:
raise
TypeError
(
"Incorrect arguments: params.get(%s, %s)"
%
(
args
,
kwargs
))
elif
'failobj'
in
kwargs
:
return
[
args
[
0
],
'/*'
,
kwargs
[
'failobj'
]]
# Old API
elif
len
(
args
)
>
2
or
'default'
in
kwargs
or
'path'
in
kwargs
:
try
:
if
'default'
in
kwargs
:
default
=
kwargs
[
'default'
]
elif
len
(
args
)
>
2
:
default
=
args
[
2
]
else
:
default
=
None
if
'path'
in
kwargs
:
path
=
kwargs
[
'path'
]
elif
len
(
args
)
>
1
:
path
=
args
[
1
]
else
:
path
=
None
key
=
args
[
0
]
return
[
key
,
path
,
default
]
except
IndexError
:
raise
TypeError
(
"Incorrect arguments: params.get(%s, %s)"
%
(
args
,
kwargs
))
else
:
# Old API
if
len
(
args
)
==
1
:
return
[
args
[
0
],
'/*'
,
None
]
else
:
return
[
args
[
0
],
'/*'
,
args
[
1
]]
key
,
path
,
default
=
compatibility
(
args
,
kwargs
)
def
get
(
self
,
key
,
path
=
None
,
default
=
None
):
"""
Retrieve value associated with key from params
:param key: Key you're looking for
:param path: namespace ['*']
:param default: default value when not found
:raise KeyError: In case of multiple different values (params clash)
"""
if
path
is
None
:
# default path is any relative path
path
=
'*'
try
:
...
...
@@ -357,10 +319,6 @@ class AvocadoParam(object):
"""
This is a single slice params. It can contain multiple leaves and tries to
find matching results.
Currently it doesn't care about params origin, it requires single result
or failure. In future it'll get the origin from LeafParam and if it's the
same it'll proceed, otherwise raise exception (as it can't decide which
variable is desired)
"""
def
__init__
(
self
,
leaves
,
name
):
...
...
@@ -438,9 +396,9 @@ class Mux(object):
filter_only
=
getattr
(
args
,
'filter_only'
,
None
)
filter_out
=
getattr
(
args
,
'filter_out'
,
None
)
if
mux_files
:
self
.
pools
=
parse
_yamls
(
mux_files
,
filter_only
,
filter_out
)
self
.
variants
=
multiplex
_yamls
(
mux_files
,
filter_only
,
filter_out
)
else
:
# no variants
self
.
pool
s
=
None
self
.
variant
s
=
None
self
.
_mux_entry
=
getattr
(
args
,
'mux_entry'
,
None
)
if
self
.
_mux_entry
is
None
:
self
.
_mux_entry
=
[
'/test/*'
]
...
...
@@ -450,9 +408,9 @@ class Mux(object):
:return: overall number of tests * multiplex variants
"""
# Currently number of tests is symetrical
if
self
.
pool
s
:
if
self
.
variant
s
:
return
(
len
(
test_suite
)
*
sum
(
1
for
_
in
multiplex_pools
(
self
.
pools
)
))
sum
(
1
for
_
in
self
.
variants
))
else
:
return
len
(
test_suite
)
...
...
@@ -460,9 +418,9 @@ class Mux(object):
"""
Processes the template and yields test definition with proper params
"""
if
self
.
pool
s
:
# Copy template and modify it's params
if
self
.
variant
s
:
# Copy template and modify it's params
i
=
None
for
i
,
variant
in
enumerate
(
multiplex_pools
(
self
.
pools
)
):
for
i
,
variant
in
enumerate
(
self
.
variants
):
test_factory
=
[
template
[
0
],
template
[
1
].
copy
()]
test_factory
[
1
][
'params'
]
=
(
variant
,
self
.
_mux_entry
)
yield
test_factory
...
...
docs/source/MultiplexConfig.rst
浏览文件 @
a5ba88f0
此差异已折叠。
点击以展开。
docs/source/WritingTests.rst
浏览文件 @
a5ba88f0
...
...
@@ -110,34 +110,66 @@ to analyze that particular benchmark result).
Accessing test parameters
=========================
Each test has a set of parameters that can be accessed through ``self.params.[param-name]``.
Avocado finds and populates ``self.params`` with all parameters you define on a Multiplex
Config file (see :doc:`MultiplexConfig`), in a way that they are available as attributes,
not just dict keys. This has the advantage of reducing the boilerplate code necessary to
access those parameters. As an example, consider the following multiplex file for sleeptest::
variants:
- sleeptest:
sleep_length_type = float
variants:
- short:
sleep_length = 0.5
- medium:
sleep_length = 1
- long:
sleep_length = 5
You may notice some things here: there is one test param to sleeptest, called ``sleep_length``. We could have named it
``length`` really, but I prefer to create a param namespace of sorts here. Then, I defined
``sleep_length_type``, that is used by the config system to convert a value (by default a
:class:`basestring`) to an appropriate value type (in this case, we need to pass a :class:`float`
to :func:`time.sleep` anyway). Note that this is an optional feature, and you can always use
:func:`float` to convert the string value coming from the configuration anyway.
Another important design detail is that sometimes we might not want to use the config system
at all (for example, when we run an avocado test as a stand alone test). To account for this
case, we have to specify a ``default_params`` dictionary that contains the default values
for when we are not providing config from a multiplex file.
Each test has a set of parameters that can be accessed through
``self.params.get($name, $path=None, $default=None)``.
Avocado finds and populates ``self.params`` with all parameters you define on
a Multiplex Config file (see :doc:`MultiplexConfig`). As an example, consider
the following multiplex file for sleeptest::
test:
sleeptest:
type: "builtin"
short:
sleep_length: 0.5
medium:
sleep_length: 1
long:
sleep_length: 5
In this example 3 variants are executed (see :doc:`MultiplexConfig` for
details). All of them contain variable "type" and "sleep_length". To obtain
current value, you need the name ("sleep_length") and its path. The path
differs for each variant so it's needed to use the most suitable portion
of the path, in this example: "/test/sleeptest/*" or perhaps "sleeptest/*"
might be enough. It depends on how your setups looks like.
The default value is optional, but always keep in mind to handle them nicely.
Someone might be executing your test with different params or without any
params at all. It should work fine.
So the complete example on how to access the "sleep_length" would be::
self.params.get("sleep_length", "/*/sleeptest/*", 1)
There is one way to make this even simpler. It's possible to define resolution
order, then for simple queries you can simply omit the path::
self.params.get("sleep_length", None, 1)
self.params.get("sleep_length", '*', 1)
self.params.get("sleep_length", default=1)
One should always try to avoid param clashes (multiple matching keys for given
path with different origin). If it's not possible (eg. when
you use multiple yaml files) you can modify the resolution order by modifying
``--mux-entry``. What it does is it slices the params and iterates through the
paths one by one. When there is a match in the first slice it returns
it without trying the other slices. Although relative queries only match
from ``--mux-entry`` slices.
There are many ways to use paths to separate clashing params or just to make
more clear what your query for. Usually in tests the usage of '*' is sufficient
and the namespacing is not necessarily, but it helps make advanced usage
clearer and easier to follow.
When thinking of the path always think about users. It's common to extend
default config with additional variants or combine them with different
ones to generate just the right scenarios they need. People might
simply inject the values elsewhere (eg. `/test/sleeptest` =>
`/upstream/test/sleeptest`) or they can merge other clashing file into the
default path, which won't generate clash, but would return their values
instead. Then you need to clarify the path (eg. `'*'` => `sleeptest/*`)
More details on that are in :doc:`MultiplexConfig`
Using a multiplex file
======================
...
...
@@ -145,14 +177,14 @@ Using a multiplex file
You may use the avocado runner with a multiplex file to provide params and matrix
generation for sleeptest just like::
$ avocado run sleeptest --multiplex examples/tests/sleeptest.py.data/sleeptest.yaml
$ avocado run sleeptest --multiplex
/test:
examples/tests/sleeptest.py.data/sleeptest.yaml
JOB ID : d565e8dec576d6040f894841f32a836c751f968f
JOB LOG : $HOME/avocado/job-results/job-2014-08-12T15.44-d565e8de/job.log
JOB HTML : $HOME/avocado/job-results/job-2014-08-12T15.44-d565e8de/html/results.html
TESTS : 3
(1/3) sleeptest
.short
: PASS (0.50 s)
(2/3) sleeptest.
medium
: PASS (1.01 s)
(3/3) sleeptest.
long
: PASS (5.01 s)
(1/3) sleeptest: PASS (0.50 s)
(2/3) sleeptest.
1
: PASS (1.01 s)
(3/3) sleeptest.
2
: PASS (5.01 s)
PASS : 3
ERROR : 0
FAIL : 0
...
...
@@ -161,30 +193,43 @@ generation for sleeptest just like::
INTERRUPT : 0
TIME : 6.52 s
The ``--multiplex`` accepts either only ``$FILE_LOCATION`` or ``$INJECT_TO:$FILE_LOCATION``.
By later you can combine multiple simple YAML files and inject them into a specific location
as shown in the example above. As you learned in previous section the ``/test`` location
is part of default ``mux-entry`` path thus sleeptest can access the values without specifying
the path. To understand the difference execute those commands::
$ avocado multiplex -t examples/tests/sleeptest.py.data/sleeptest.yaml
$ avocado multiplex -t /test:examples/tests/sleeptest.py.data/sleeptest.yaml
Note that, as your multiplex file specifies all parameters for sleeptest, you
can't leave the test ID empty::
$ scripts/avocado run --multiplex examples/tests/sleeptest/sleeptest.yaml
$ scripts/avocado run --multiplex
/test:
examples/tests/sleeptest/sleeptest.yaml
Empty test ID. A test path or alias must be provided
If you want to run some tests that don't require params set by the multiplex file, you can::
$ avocado run sleeptest synctest --multiplex examples/tests/sleeptest.py.data/sleeptest.yaml
JOB ID : dd91ea5f8b42b2f084702315688284f7e8aa220a
JOB LOG : $HOME/avocado/job-results/job-2014-08-12T15.49-dd91ea5f/job.log
JOB HTML : $HOME/avocado/job-results/job-2014-08-12T15.49-dd91ea5f/html/results.html
TESTS : 4
(1/4) sleeptest.short: PASS (0.50 s)
(2/4) sleeptest.medium: PASS (1.01 s)
(3/4) sleeptest.long: PASS (5.01 s)
(4/4) synctest.1: ERROR (1.85 s)
PASS : 3
ERROR : 1
FAIL : 0
SKIP : 0
WARN : 0
INTERRUPT : 0
TIME : 8.69 s
You can also execute multiple tests with the same multiplex file::
./scripts/avocado run sleeptest synctest --multiplex examples/tests/sleeptest.py.data/sleeptest.yaml
JOB ID : 72166988c13fec26fcc9c2e504beec8edaad4761
JOB LOG : /home/medic/avocado/job-results/job-2015-05-15T11.02-7216698/job.log
JOB HTML : /home/medic/avocado/job-results/job-2015-05-15T11.02-7216698/html/results.html
TESTS : 8
(1/8) sleeptest.py: PASS (1.00 s)
(2/8) sleeptest.py.1: PASS (1.00 s)
(3/8) sleeptest.py.2: PASS (1.00 s)
(4/8) sleeptest.py.3: PASS (1.00 s)
(5/8) synctest.py: PASS (1.31 s)
(6/8) synctest.py.1: PASS (1.48 s)
(7/8) synctest.py.2: PASS (3.36 s)
(8/8) synctest.py.3: PASS (3.59 s)
PASS : 8
ERROR : 0
FAIL : 0
SKIP : 0
WARN : 0
INTERRUPT : 0
TIME : 13.76 s
Avocado tests are also unittests
================================
...
...
@@ -542,16 +587,14 @@ impact your test grid. You can account for that possibility and set up a
::
variants:
- sleeptest:
sleep_length = 5
sleep_length_type = float
timeout = 3
timeout_type = float
sleep_length = 5
sleep_length_type = float
timeout = 3
timeout_type = float
::
$ avocado run sleeptest --multiplex /t
mp/sleeptest-example.mplx
$ avocado run sleeptest --multiplex /t
est:/tmp/sleeptest-example.yaml
JOB ID : 6d5a2ff16bb92395100fbc3945b8d253308728c9
JOB LOG : $HOME/avocado/job-results/job-2014-08-12T15.52-6d5a2ff1/job.log
JOB HTML : $HOME/avocado/job-results/job-2014-08-12T15.52-6d5a2ff1/html/results.html
...
...
@@ -572,8 +615,8 @@ impact your test grid. You can account for that possibility and set up a
15:52:51 test L0144 DEBUG|
15:52:51 test L0145 DEBUG| Test log: $HOME/avocado/job-results/job-2014-08-12T15.52-6d5a2ff1/sleeptest.1/test.log
15:52:51 test L0146 DEBUG| Test instance parameters:
15:52:51 test L0153 DEBUG| _name_map_file = {'sleeptest-example.
mplx
': 'sleeptest'}
15:52:51 test L0153 DEBUG| _short_name_map_file = {'sleeptest-example.
mplx
': 'sleeptest'}
15:52:51 test L0153 DEBUG| _name_map_file = {'sleeptest-example.
yaml
': 'sleeptest'}
15:52:51 test L0153 DEBUG| _short_name_map_file = {'sleeptest-example.
yaml
': 'sleeptest'}
15:52:51 test L0153 DEBUG| dep = []
15:52:51 test L0153 DEBUG| id = sleeptest
15:52:51 test L0153 DEBUG| name = sleeptest
...
...
examples/mux-environment.yaml
浏览文件 @
a5ba88f0
hw
:
cpu
:
cpu
:
!mux
intel
:
cpu_CFLAGS
:
'
-march=core2'
amd
:
cpu_CFLAGS
:
'
-march=athlon64'
arm
:
cpu_CFLAGS
:
'
-mabi=apcs-gnu
-march=armv8-a
-mtune=arm8'
disk
:
disk
:
!mux
scsi
:
disk_type
:
'
scsi'
virtio
:
disk_type
:
'
virtio'
distro
:
distro
:
!mux
fedora
:
init
:
'
systemd'
mint
:
init
:
'
systemv'
env
:
env
:
!mux
debug
:
opt_CFLAGS
:
'
-O0
-g'
prod
:
...
...
examples/mux-selftest-advanced.yaml
浏览文件 @
a5ba88f0
...
...
@@ -2,7 +2,7 @@
!using
:
virt
# Following line makes it look exactly as mux-selftest.yaml
!include
:
mux-selftest.yaml
distro
:
distro
:
!mux
# This line extends the distro branch using include
!include
:
mux-selftest-distro.yaml
# remove node called "mint"
...
...
@@ -19,14 +19,7 @@ distro:
# And this removes the original 'is_cool'
# Setting happens after ctrl so it should be created'
!remove_value
:
is_cool
# Following node is an empty node with only Control object. During merge
# it setls /env node as !join (disable multiplexation)
env
:
!join
distro
:
!join
# Set !join here, it won't be overwritten below as it's defined as
# &=.
mint
:
# This won't change anything
distro
:
distro
:
!mux
gentoo
:
# This won't change anything
# This creates new branch the usual way
new_node
:
...
...
examples/mux-selftest-distro.yaml
浏览文件 @
a5ba88f0
RHEL
:
!mux
RHEL
:
!mux
enterprise
:
true
6
:
init
:
'
systemv'
7
:
init
:
'
systemd'
gentoo
:
gentoo
:
!mux
is_cool
:
False
examples/mux-selftest-params.yaml
浏览文件 @
a5ba88f0
!join
root
:
"
root"
cache_test
:
'
cache'
diff_domain
:
"
text1"
...
...
@@ -7,12 +6,13 @@ ch0:
clash1
:
"
equal"
clash3
:
"
also
equal"
ch0.1
:
ch0.1.1
:
ch0.1.1
:
!mux
ch0.1.1.1
:
unique1
:
"
unique1"
clash1
:
"
equal"
ch0.1.1.2
:
unique1
:
"
unique1-2"
ch0.1b
:
!mux
ch0.1.2
:
unique3
:
"
unique3"
clash3
:
"
also
equal"
...
...
examples/mux-selftest.yaml
浏览文件 @
a5ba88f0
...
...
@@ -8,7 +8,7 @@
# /env/opt_CFLAGS: Should be present in merged node
# /env/prod/opt_CFLAGS: value should be overridden by latter node
hw
:
cpu
:
cpu
:
!mux
joinlist
:
-
first_item
intel
:
...
...
@@ -18,7 +18,7 @@ hw:
cpu_CFLAGS
:
'
-march=athlon64'
arm
:
cpu_CFLAGS
:
'
-mabi=apcs-gnu
-march=armv8-a
-mtune=arm8'
disk
:
disk
:
!mux
disk_type
:
'
virtio'
corruptlist
:
'
nonlist'
scsi
:
...
...
@@ -26,17 +26,17 @@ hw:
disk_type
:
'
scsi'
virtio
:
corruptlist
:
[
'
upper_node_list'
]
distro
:
# This node is set as !multiplex below
distro
:
!mux
# This node is set as !multiplex below
fedora
:
init
:
'
systemd'
env
:
env
:
!mux
opt_CFLAGS
:
'
-Os'
prod
:
opt_CFLAGS
:
'
THIS
SHOULD
GET
OVERWRITTEN'
env
:
env
:
!mux
prod
:
opt_CFLAGS
:
'
-O2'
distro
:
distro
:
!mux
mint
:
init
:
'
systemv'
examples/tests/cabort.py
浏览文件 @
a5ba88f0
...
...
@@ -19,7 +19,7 @@ class CAbort(test.Test):
"""
Build 'abort'.
"""
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
'abort.c'
))
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
default
=
'abort.c'
))
c_file_name
=
os
.
path
.
basename
(
c_file
)
dest_c_file
=
os
.
path
.
join
(
self
.
srcdir
,
c_file_name
)
shutil
.
copy
(
c_file
,
dest_c_file
)
...
...
examples/tests/datadir.py
浏览文件 @
a5ba88f0
...
...
@@ -19,7 +19,8 @@ class DataDirTest(test.Test):
"""
Build 'datadir'.
"""
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
'datadir.c'
))
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
default
=
'datadir.c'
))
c_file_name
=
os
.
path
.
basename
(
c_file
)
dest_c_file
=
os
.
path
.
join
(
self
.
srcdir
,
c_file_name
)
shutil
.
copy
(
c_file
,
dest_c_file
)
...
...
examples/tests/doublefree.py
浏览文件 @
a5ba88f0
...
...
@@ -20,7 +20,8 @@ class DoubleFreeTest(test.Test):
"""
Build 'doublefree'.
"""
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
'doublefree.c'
))
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
default
=
'doublefree.c'
))
c_file_name
=
os
.
path
.
basename
(
c_file
)
dest_c_file
=
os
.
path
.
join
(
self
.
srcdir
,
c_file_name
)
shutil
.
copy
(
c_file
,
dest_c_file
)
...
...
examples/tests/doublefree_nasty.py
浏览文件 @
a5ba88f0
...
...
@@ -21,7 +21,7 @@ class DoubleFreeTest(test.Test):
"""
Build 'doublefree'.
"""
source
=
self
.
params
.
get
(
'source'
,
'doublefree.c'
)
source
=
self
.
params
.
get
(
'source'
,
default
=
'doublefree.c'
)
c_file
=
self
.
get_data_path
(
source
)
shutil
.
copy
(
c_file
,
self
.
srcdir
)
self
.
__binary
=
source
.
rsplit
(
'.'
,
1
)[
0
]
...
...
examples/tests/doublefree_nasty.py.data/iterations.yaml
浏览文件 @
a5ba88f0
iterations
:
iterations
:
!mux
1
:
2
:
3
:
...
...
examples/tests/env_variables.sh.data/env_variables.yaml
浏览文件 @
a5ba88f0
!mux
short
:
CUSTOM_VARIABLE
:
A
medium
:
...
...
examples/tests/fiotest.py
浏览文件 @
a5ba88f0
...
...
@@ -22,7 +22,8 @@ class FioTest(test.Test):
"""
Build 'fio'.
"""
fio_tarball
=
self
.
params
.
get
(
'fio_tarball'
,
'fio-2.1.10.tar.bz2'
)
fio_tarball
=
self
.
params
.
get
(
'fio_tarball'
,
default
=
'fio-2.1.10.tar.bz2'
)
tarball_path
=
self
.
get_data_path
(
fio_tarball
)
archive
.
extract
(
tarball_path
,
self
.
srcdir
)
fio_version
=
fio_tarball
.
split
(
'.tar.'
)[
0
]
...
...
@@ -34,7 +35,7 @@ class FioTest(test.Test):
Execute 'fio' with appropriate parameters.
"""
os
.
chdir
(
self
.
srcdir
)
fio_job
=
self
.
params
.
get
(
'fio_job'
,
'fio-mixed.job'
)
fio_job
=
self
.
params
.
get
(
'fio_job'
,
default
=
'fio-mixed.job'
)
cmd
=
(
'./fio %s'
%
self
.
get_data_path
(
fio_job
))
process
.
system
(
cmd
)
...
...
examples/tests/linuxbuild.py
浏览文件 @
a5ba88f0
...
...
@@ -12,8 +12,8 @@ class LinuxBuildTest(test.Test):
"""
def
setUp
(
self
):
kernel_version
=
self
.
params
.
get
(
'linux_version'
,
'3.14.5'
)
linux_config
=
self
.
params
.
get
(
'linux_config'
,
'config'
)
kernel_version
=
self
.
params
.
get
(
'linux_version'
,
default
=
'3.14.5'
)
linux_config
=
self
.
params
.
get
(
'linux_config'
,
default
=
'config'
)
config_path
=
self
.
get_data_path
(
linux_config
)
self
.
linux_build
=
kernel_build
.
KernelBuild
(
kernel_version
,
config_path
,
...
...
examples/tests/modify_variable.py
浏览文件 @
a5ba88f0
...
...
@@ -24,7 +24,7 @@ class PrintVariableTest(test.Test):
"""
Build 'print_variable'.
"""
source
=
self
.
params
.
get
(
'source'
,
'print_variable.c'
)
source
=
self
.
params
.
get
(
'source'
,
default
=
'print_variable.c'
)
c_file
=
self
.
get_data_path
(
source
)
shutil
.
copy
(
c_file
,
self
.
srcdir
)
self
.
__binary
=
source
.
rsplit
(
'.'
,
1
)[
0
]
...
...
examples/tests/multiplextest.py
浏览文件 @
a5ba88f0
...
...
@@ -16,7 +16,7 @@ class MultiplexTest(test.Test):
self
.
set_numa_balance
()
self
.
assembly_vm
()
os_type
=
self
.
params
.
get
(
'os_type'
,
'linux'
)
os_type
=
self
.
params
.
get
(
'os_type'
,
default
=
'linux'
)
if
os_type
==
'windows'
:
self
.
log
.
info
(
'Preparing VM with Windows (%s)'
,
self
.
params
.
get
(
'win'
))
...
...
@@ -26,16 +26,17 @@ class MultiplexTest(test.Test):
def
compile_code
(
self
):
self
.
log
.
info
(
'Compile code'
)
self
.
log
.
info
(
'gcc %s %s'
,
self
.
params
.
get
(
'gcc_flags'
,
'-O2'
),
self
.
log
.
info
(
'gcc %s %s'
,
self
.
params
.
get
(
'gcc_flags'
,
default
=
'-O2'
),
'code.c'
)
def
set_hugepages
(
self
):
if
self
.
params
.
get
(
'huge_pages'
,
'yes'
)
==
'yes'
:
if
self
.
params
.
get
(
'huge_pages'
,
default
=
'yes'
)
==
'yes'
:
self
.
log
.
info
(
'Setting hugepages'
)
def
set_numa_balance
(
self
):
numa_balancing
=
self
.
params
.
get
(
'numa_balancing'
,
'yes'
)
numa_migrate
=
self
.
params
.
get
(
'numa_balancing_migrate_deferred'
,
'no'
)
numa_balancing
=
self
.
params
.
get
(
'numa_balancing'
,
default
=
'yes'
)
numa_migrate
=
self
.
params
.
get
(
'numa_balancing_migrate_deferred'
,
default
=
'no'
)
if
numa_balancing
:
self
.
log
.
info
(
'Numa balancing: %s'
,
numa_balancing
)
if
numa_migrate
:
...
...
@@ -43,9 +44,10 @@ class MultiplexTest(test.Test):
def
assembly_vm
(
self
):
self
.
log
.
info
(
'Assembling VM'
)
drive_format
=
self
.
params
.
get
(
'drive_format'
,
'virtio_blk'
)
nic_model
=
self
.
params
.
get
(
'nic_model'
,
'virtio_net'
)
enable_msx_vectors
=
self
.
params
.
get
(
'enable_msx_vectors'
,
'yes'
)
drive_format
=
self
.
params
.
get
(
'drive_format'
,
default
=
'virtio_blk'
)
nic_model
=
self
.
params
.
get
(
'nic_model'
,
default
=
'virtio_net'
)
enable_msx_vectors
=
self
.
params
.
get
(
'enable_msx_vectors'
,
default
=
'yes'
)
if
drive_format
:
self
.
log
.
info
(
'Drive format: %s'
,
drive_format
)
if
nic_model
:
...
...
@@ -56,13 +58,13 @@ class MultiplexTest(test.Test):
def
runTest
(
self
):
self
.
log
.
info
(
'Executing synctest...'
)
self
.
log
.
info
(
'synctest --timeout %s --tries %s'
,
self
.
params
.
get
(
'sync_timeout'
,
12
),
self
.
params
.
get
(
'sync_tries'
,
3
))
self
.
params
.
get
(
'sync_timeout'
,
default
=
12
),
self
.
params
.
get
(
'sync_tries'
,
default
=
3
))
self
.
log
.
info
(
'Executing ping test...'
)
cmdline
=
(
'ping --timeout %s --tries %s'
%
(
self
.
params
.
get
(
'ping_timeout'
,
10
),
self
.
params
.
get
(
'ping_tries'
,
5
)))
%
(
self
.
params
.
get
(
'ping_timeout'
,
default
=
10
),
self
.
params
.
get
(
'ping_tries'
,
default
=
5
)))
ping_flags
=
self
.
params
.
get
(
'ping_flags'
)
if
ping_flags
:
...
...
examples/tests/multiplextest.py.data/multiplextest.yaml
浏览文件 @
a5ba88f0
env
:
env
:
!mux
production
:
malloc_perturb
:
no
gcc_flags
:
-O3
...
...
@@ -8,11 +8,11 @@ env:
host
:
kernel_config
:
page_size
:
page_size
:
!mux
default
:
huge_pages
:
huge_pages
:
yes
numa
:
numa
:
!mux
default
:
numa_ballance_aggressive
:
numa_balancing
:
1
...
...
@@ -24,8 +24,8 @@ host:
numa_balancing_scan_size_mb
:
32
guest
:
os
:
!
join
windows
:
os
:
!
mux
windows
:
!mux
os_type
:
windows
xp
:
win
:
xp
...
...
@@ -33,7 +33,7 @@ guest:
win
:
2k12
7
:
win
:
7
linux
:
linux
:
!mux
os_type
:
linux
fedora
:
distro
:
fedora
...
...
@@ -41,12 +41,12 @@ guest:
distro
:
ubuntu
hardware
:
disks
:
disks
:
!mux
ide
:
drive_format
:
ide
scsi
:
drive_format
:
scsi
network
:
network
:
!mux
rtl_8139
:
nic_model
:
rtl8139
e1000
:
...
...
@@ -55,15 +55,15 @@ hardware:
nic_model
:
virtio
enable_msix_vectors
:
yes
tests
:
sync_test
:
tests
:
!mux
sync_test
:
!mux
standard
:
sync_timeout
:
30
sync_tries
:
10
aggressive
:
sync_timeout
:
10
sync_tries
:
20
ping_test
:
ping_test
:
!mux
standard
:
ping_tries
:
10
ping_timeout
:
20
...
...
examples/tests/raise.py
浏览文件 @
a5ba88f0
...
...
@@ -19,7 +19,8 @@ class Raise(test.Test):
"""
Build 'raise'.
"""
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
'raise.c'
))
c_file
=
self
.
get_data_path
(
self
.
params
.
get
(
'source'
,
default
=
'raise.c'
))
c_file_name
=
os
.
path
.
basename
(
c_file
)
dest_c_file
=
os
.
path
.
join
(
self
.
srcdir
,
c_file_name
)
shutil
.
copy
(
c_file
,
dest_c_file
)
...
...
@@ -31,7 +32,7 @@ class Raise(test.Test):
"""
Execute 'raise'.
"""
signum
=
self
.
params
.
get
(
'signal_number'
,
15
)
signum
=
self
.
params
.
get
(
'signal_number'
,
default
=
15
)
cmd
=
os
.
path
.
join
(
self
.
srcdir
,
'raise %d'
%
signum
)
cmd_result
=
process
.
run
(
cmd
,
ignore_status
=
True
)
self
.
log
.
info
(
cmd_result
)
...
...
examples/tests/raise.py.data/raise.yaml
浏览文件 @
a5ba88f0
!mux
sigint
:
signal_number
:
2
siguser1
:
...
...
examples/tests/sleeptenmin.py
浏览文件 @
a5ba88f0
...
...
@@ -17,9 +17,9 @@ class SleepTenMin(test.Test):
"""
Sleep for length seconds.
"""
cycles
=
int
(
self
.
params
.
get
(
'sleep_cycles'
,
1
))
length
=
int
(
self
.
params
.
get
(
'sleep_length'
,
600
))
method
=
self
.
params
.
get
(
'sleep_method'
,
'builtin'
)
cycles
=
int
(
self
.
params
.
get
(
'sleep_cycles'
,
default
=
1
))
length
=
int
(
self
.
params
.
get
(
'sleep_length'
,
default
=
600
))
method
=
self
.
params
.
get
(
'sleep_method'
,
default
=
'builtin'
)
for
cycle
in
xrange
(
0
,
cycles
):
self
.
log
.
debug
(
"Sleeping for %.2f seconds"
,
length
)
...
...
examples/tests/sleeptenmin.py.data/sleeptenmin.mplx
已删除
100644 → 0
浏览文件 @
2bfbfdc6
variants:
- sleeptenmin:
variants:
- builtin:
sleep_method = builtin
- shell:
sleep_method = shell
variants:
- one_cycle:
sleep_cycles = 1
sleep_length = 600
- six_cycles:
sleep_cycles = 6
sleep_length = 100
- one_hundred_cycles:
sleep_cycles = 100
sleep_length = 6
- six_hundred_cycles:
sleep_cycles = 600
sleep_length = 1
examples/tests/sleeptenmin.py.data/sleeptenmin.yaml
0 → 100644
浏览文件 @
a5ba88f0
sleeptenmin
:
!mux
builtin
:
sleep_method
:
builtin
shell
:
sleep_method
:
shell
variants
:
!mux
one_cycle
:
sleep_cycles
:
1
sleep_length
:
600
six_cycles
:
sleep_cycles
:
6
sleep_length
:
100
one_hundred_cycles
:
sleep_cycles
:
100
sleep_length
:
6
six_hundred_cycles
:
sleep_cycles
:
600
sleep_length
:
1
examples/tests/sleeptest.py.data/sleeptest.yaml
浏览文件 @
a5ba88f0
!
using
:
test
!
mux
short
:
sleep_length
:
0.5
medium
:
...
...
examples/tests/synctest.py
浏览文件 @
a5ba88f0
...
...
@@ -20,11 +20,11 @@ class SyncTest(test.Test):
Build the synctest suite.
"""
self
.
cwd
=
os
.
getcwd
()
tarball_path
=
self
.
get_data_path
(
self
.
params
.
get
(
'sync_tarball'
,
tarball_path
=
self
.
get_data_path
(
self
.
params
.
get
(
'sync_tarball'
,
'*'
,
'synctest.tar.bz2'
))
archive
.
extract
(
tarball_path
,
self
.
srcdir
)
self
.
srcdir
=
os
.
path
.
join
(
self
.
srcdir
,
'synctest'
)
if
self
.
params
.
get
(
'debug_symbols'
,
True
):
if
self
.
params
.
get
(
'debug_symbols'
,
default
=
True
):
build
.
make
(
self
.
srcdir
,
env
=
{
'CFLAGS'
:
'-g -O0'
},
extra_args
=
'synctest'
)
...
...
@@ -38,8 +38,8 @@ class SyncTest(test.Test):
os
.
chdir
(
self
.
srcdir
)
path
=
os
.
path
.
join
(
os
.
getcwd
(),
'synctest'
)
cmd
=
(
'%s %s %s'
%
(
path
,
self
.
params
.
get
(
'sync_length'
,
100
),
self
.
params
.
get
(
'sync_loop'
,
10
)))
(
path
,
self
.
params
.
get
(
'sync_length'
,
default
=
100
),
self
.
params
.
get
(
'sync_loop'
,
default
=
10
)))
process
.
system
(
cmd
)
os
.
chdir
(
self
.
cwd
)
...
...
examples/tests/synctest.py.data/synctest.yaml
浏览文件 @
a5ba88f0
sync_tarball
:
synctest.tar.bz2
loop
:
loop
:
!mux
short
:
sync_loop
:
10
medium
:
sync_loop
:
50
long
:
sync_loop
:
100
length
:
length
:
!mux
short
:
sync_length
:
100
medium
:
...
...
examples/tests/timeouttest.py
浏览文件 @
a5ba88f0
...
...
@@ -18,7 +18,7 @@ class TimeoutTest(test.Test):
"""
This should throw a TestTimeoutError.
"""
sleep_time
=
self
.
params
.
get
(
'sleep_time'
,
5
)
sleep_time
=
self
.
params
.
get
(
'sleep_time'
,
default
=
5
)
self
.
log
.
info
(
'Sleeping for %.2f seconds (2 more than the timeout)'
,
sleep_time
)
time
.
sleep
(
sleep_time
)
...
...
examples/tests/whiteboard.py
浏览文件 @
a5ba88f0
...
...
@@ -13,8 +13,8 @@ class WhiteBoard(test.Test):
"""
def
runTest
(
self
):
data_file
=
self
.
params
.
get
(
'whiteboard_data_file'
,
''
)
data_size
=
self
.
params
.
get
(
'whiteboard_data_size'
,
'10'
)
data_file
=
self
.
params
.
get
(
'whiteboard_data_file'
,
default
=
''
)
data_size
=
self
.
params
.
get
(
'whiteboard_data_size'
,
default
=
'10'
)
if
data_file
:
self
.
log
.
info
(
'Writing data to whiteboard from file: %s'
,
data_file
)
...
...
@@ -24,9 +24,9 @@ class WhiteBoard(test.Test):
else
:
offset
=
int
(
data_size
)
-
1
data
=
self
.
params
.
get
(
'whiteboard_data_text'
,
'default whiteboard text'
)[
0
:
offset
]
default
=
'default whiteboard text'
)[
0
:
offset
]
iterations
=
int
(
self
.
params
.
get
(
'whiteboard_writes'
,
1
))
iterations
=
int
(
self
.
params
.
get
(
'whiteboard_writes'
,
default
=
1
))
result
=
''
for
_
in
xrange
(
0
,
iterations
):
...
...
examples/tests/whiteboard.py.data/whiteboard.yaml
浏览文件 @
a5ba88f0
source
:
source
:
!mux
string
:
whiteboard_data_text
:
'
foo
bar
foo
baz'
urandom
:
whiteboard_data_file
:
'
/dev/urandom'
iterations
:
iterations
:
!mux
single
:
whiteboard_writes
:
1
dozen
:
whiteboard_writes
:
12
size
:
size
:
!mux
onekilo
:
whiteboard_data_size
:
1024
onemega
:
...
...
selftests/all/unit/avocado/multiplexer_unittest.py
浏览文件 @
a5ba88f0
...
...
@@ -9,9 +9,12 @@ if sys.version_info[:2] == (2, 6):
import
unittest2
as
unittest
else
:
import
unittest
if
__name__
==
"__main__"
:
PATH_PREFIX
=
"../../../../"
else
:
PATH_PREFIX
=
""
TREE
=
tree
.
create_from_yaml
([
'examples/mux-selftest.yaml'
])
TREE
=
tree
.
create_from_yaml
([
PATH_PREFIX
+
'examples/mux-selftest.yaml'
])
def
combine
(
leaves_pools
):
...
...
@@ -23,36 +26,36 @@ def combine(leaves_pools):
class
TestMultiplex
(
unittest
.
TestCase
):
tree
=
TREE
mux_full
=
tuple
(
combine
(
multiplexer
.
tree2pools
(
tree
)
))
mux_full
=
tuple
(
multiplexer
.
MuxTree
(
tree
))
def
test_empty
(
self
):
act
=
tuple
(
combine
(
multiplexer
.
tree2pools
(
tree
.
TreeNode
()
)))
self
.
assertEqual
(
act
,
(
()
,))
act
=
tuple
(
multiplexer
.
MuxTree
(
tree
.
TreeNode
(
)))
self
.
assertEqual
(
act
,
(
[
''
,
]
,))
def
test_partial
(
self
):
exp
=
(
(
'intel'
,
'scsi'
),
(
'intel'
,
'virtio'
),
(
'amd'
,
'scsi'
)
,
(
'amd'
,
'virtio'
),
(
'arm'
,
'scsi'
),
(
'arm'
,
'virtio'
)
)
act
=
tuple
(
combine
(
multiplexer
.
tree2pools
(
self
.
tree
.
children
[
0
])
))
exp
=
(
[
'intel'
,
'scsi'
],
[
'intel'
,
'virtio'
],
[
'amd'
,
'scsi'
]
,
[
'amd'
,
'virtio'
],
[
'arm'
,
'scsi'
],
[
'arm'
,
'virtio'
]
)
act
=
tuple
(
multiplexer
.
MuxTree
(
self
.
tree
.
children
[
0
]
))
self
.
assertEqual
(
act
,
exp
)
def
test_full
(
self
):
self
.
assertEqual
(
len
(
self
.
mux_full
),
12
)
def
test_create_variants
(
self
):
from_file
=
multiplexer
.
multiplex_yamls
([
'examples/mux-selftest.yaml'
])
from_file
=
multiplexer
.
multiplex_yamls
([
PATH_PREFIX
+
'examples/mux-selftest.yaml'
])
self
.
assertEqual
(
self
.
mux_full
,
tuple
(
from_file
))
# Filters are tested in tree_unittests, only verify `multiplex_yamls` calls
def
test_filter_only
(
self
):
exp
=
(
(
'intel'
,
'scsi'
),
(
'intel'
,
'virtio'
)
)
act
=
tuple
(
multiplexer
.
multiplex_yamls
([
'examples/mux-selftest.yaml'
],
exp
=
(
[
'intel'
,
'scsi'
],
[
'intel'
,
'virtio'
]
)
act
=
tuple
(
multiplexer
.
multiplex_yamls
([
PATH_PREFIX
+
'examples/mux-selftest.yaml'
],
(
'/hw/cpu/intel'
,
'/distro/fedora'
,
'/hw'
)))
self
.
assertEqual
(
act
,
exp
)
def
test_filter_out
(
self
):
act
=
tuple
(
multiplexer
.
multiplex_yamls
([
'examples/mux-selftest.yaml'
],
act
=
tuple
(
multiplexer
.
multiplex_yamls
([
PATH_PREFIX
+
'examples/mux-selftest.yaml'
],
None
,
(
'/hw/cpu/intel'
,
'/distro/fedora'
,
...
...
@@ -67,8 +70,8 @@ class TestMultiplex(unittest.TestCase):
class
TestAvocadoParams
(
unittest
.
TestCase
):
yamls
=
multiplexer
.
multiplex_yamls
([
'examples/mux-selftest-params.'
'yaml'
]
)
yamls
=
iter
(
multiplexer
.
multiplex_yamls
([
PATH_PREFIX
+
'examples/mux-selftest-params.'
'yaml'
])
)
params1
=
multiplexer
.
AvocadoParams
(
yamls
.
next
(),
'Unittest1'
,
1
,
[
'/ch0/*'
,
'/ch1/*'
],
{})
yamls
.
next
()
# Skip 2nd
...
...
@@ -89,12 +92,6 @@ class TestAvocadoParams(unittest.TestCase):
str
(
multiplexer
.
AvocadoParams
([],
'Unittest'
,
None
,
[],
{}))
self
.
assertEqual
(
26
,
sum
([
1
for
_
in
self
.
params1
.
iteritems
()]))
def
test_get_old_api
(
self
):
self
.
assertEqual
(
self
.
params1
.
get
(
'unique1'
),
'unique1'
)
self
.
assertEqual
(
self
.
params1
.
get
(
'missing'
),
None
)
self
.
assertEqual
(
self
.
params1
.
get
(
'missing'
,
'aaa'
),
'aaa'
)
self
.
assertEqual
(
self
.
params1
.
root
,
'root'
)
def
test_get_abs_path
(
self
):
# /ch0/ is not leaf thus it's not queryable
self
.
assertEqual
(
self
.
params1
.
get
(
'root'
,
'/ch0/'
,
'bbb'
),
'bbb'
)
...
...
@@ -171,7 +168,7 @@ class TestAvocadoParams(unittest.TestCase):
self
.
assertEqual
(
self
.
params1
.
get
(
'clash2'
,
path
=
'/ch11/*'
),
'equal'
)
# simple clash in params1
self
.
assertRaisesRegexp
(
ValueError
,
r
"'clash3'.* \['/ch0=>also equal',"
r
" '/ch0/ch0.1/ch0.1.2=>also equal'\]"
,
r
" '/ch0/ch0.1
b
/ch0.1.2=>also equal'\]"
,
self
.
params1
.
get
,
'clash3'
,
default
=
'nnn'
)
# params2 is sliced the other way around so it returns before the clash
...
...
selftests/all/unit/avocado/tree_unittest.py
浏览文件 @
a5ba88f0
...
...
@@ -170,20 +170,20 @@ class TestTree(unittest.TestCase):
self
.
assertEqual
({
'new_value'
:
'something'
},
oldroot
.
children
[
3
].
children
[
0
].
children
[
0
].
value
)
# multiplex root (always True)
self
.
assertEqual
(
tree2
.
multiplex
,
Tru
e
)
self
.
assertEqual
(
tree2
.
multiplex
,
Fals
e
)
# multiplex /virt/
self
.
assertEqual
(
tree2
.
children
[
0
].
multiplex
,
Tru
e
)
self
.
assertEqual
(
tree2
.
children
[
0
].
multiplex
,
Fals
e
)
# multiplex /virt/hw
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
0
].
multiplex
,
Tru
e
)
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
0
].
multiplex
,
Fals
e
)
# multiplex /virt/distro
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
1
].
multiplex
,
Fals
e
)
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
1
].
multiplex
,
Tru
e
)
# multiplex /virt/env
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
2
].
multiplex
,
Fals
e
)
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
2
].
multiplex
,
Tru
e
)
# multiplex /virt/absolutly
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
3
].
multiplex
,
Tru
e
)
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
3
].
multiplex
,
Fals
e
)
# multiplex /virt/distro/fedora
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
1
].
children
[
0
].
multiplex
,
Tru
e
)
Fals
e
)
class
TestPathParent
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录