Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
4b65065c
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,发现更多精彩内容 >>
提交
4b65065c
编写于
11月 03, 2015
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'ldoktor/fix-remote2'
上级
0a9e7b9f
79336999
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
61 addition
and
3 deletion
+61
-3
avocado/core/remote/runner.py
avocado/core/remote/runner.py
+3
-1
avocado/core/test.py
avocado/core/test.py
+2
-2
avocado/utils/astring.py
avocado/utils/astring.py
+10
-0
avocado/utils/process.py
avocado/utils/process.py
+5
-0
selftests/functional/test_basic.py
selftests/functional/test_basic.py
+41
-0
未找到文件。
avocado/core/remote/runner.py
浏览文件 @
4b65065c
...
...
@@ -16,6 +16,7 @@
import
sys
import
json
import
os
import
pipes
import
re
import
logging
...
...
@@ -26,6 +27,7 @@ from .. import output
from
..
import
exceptions
from
..
import
status
from
..runner
import
TestRunner
from
...utils
import
astring
from
...utils
import
archive
from
...utils
import
stacktrace
...
...
@@ -118,7 +120,7 @@ class RemoteTestRunner(TestRunner):
for
t_dict
in
json_result
[
'tests'
]:
logdir
=
os
.
path
.
dirname
(
self
.
result
.
stream
.
debuglog
)
logdir
=
os
.
path
.
join
(
logdir
,
'test-results'
)
relative_path
=
t_dict
[
'test'
].
lstrip
(
'/'
)
relative_path
=
astring
.
string_to_safe_path
(
t_dict
[
'test'
]
)
logdir
=
os
.
path
.
join
(
logdir
,
relative_path
)
t_dict
[
'logdir'
]
=
logdir
t_dict
[
'logfile'
]
=
os
.
path
.
join
(
logdir
,
'debug.log'
)
...
...
avocado/core/test.py
浏览文件 @
4b65065c
...
...
@@ -21,7 +21,6 @@ framework tests.
import
inspect
import
logging
import
os
import
pipes
import
re
import
shutil
import
sys
...
...
@@ -31,6 +30,7 @@ from . import data_dir
from
.
import
exceptions
from
.
import
multiplexer
from
.
import
sysinfo
from
..utils
import
astring
from
..utils
import
data_structures
from
..utils
import
genio
from
..utils
import
path
as
utils_path
...
...
@@ -103,7 +103,7 @@ class Test(unittest.TestCase):
self
.
tagged_name
=
self
.
get_tagged_name
(
base_logdir
)
# Replace '/' with '_' to avoid splitting name into multiple dirs
safe_tagged_name
=
self
.
tagged_name
.
replace
(
os
.
path
.
sep
,
'_'
)
safe_tagged_name
=
astring
.
string_to_safe_path
(
self
.
tagged_name
)
self
.
logdir
=
utils_path
.
init_dir
(
base_logdir
,
safe_tagged_name
)
genio
.
set_log_file_dir
(
self
.
logdir
)
self
.
logfile
=
os
.
path
.
join
(
self
.
logdir
,
'debug.log'
)
...
...
avocado/utils/astring.py
浏览文件 @
4b65065c
...
...
@@ -25,6 +25,7 @@ string. Even with the dot notation, people may try to do things like
And not notice until their code starts failing.
"""
import
os.path
import
re
...
...
@@ -192,3 +193,12 @@ def tabular_output(matrix, header=None):
:rtype: str
"""
return
"
\n
"
.
join
(
iter_tabular_output
(
matrix
,
header
))
def
string_to_safe_path
(
string
):
"""
Convert string to a valid file/dir name.
:param string: String to be converted
:return: String which is safe to pass as a file/dir name (on recent fs)
"""
return
string
.
replace
(
os
.
path
.
sep
,
'_'
)
avocado/utils/process.py
浏览文件 @
4b65065c
...
...
@@ -343,6 +343,11 @@ class SubProcess(object):
while
True
:
tmp
=
os
.
read
(
fileno
,
1024
)
if
tmp
==
''
:
if
self
.
verbose
and
bfr
:
for
line
in
bfr
.
splitlines
():
log
.
debug
(
prefix
,
line
)
if
stream_logger
is
not
None
:
stream_logger
.
debug
(
stream_prefix
,
line
)
break
lock
.
acquire
()
try
:
...
...
selftests/functional/test_basic.py
浏览文件 @
4b65065c
...
...
@@ -5,6 +5,7 @@ import time
import
sys
import
tempfile
import
xml.dom.minidom
import
glob
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
import
unittest2
as
unittest
...
...
@@ -334,6 +335,32 @@ class RunnerHumanOutputTest(unittest.TestCase):
self
.
assertIn
(
'skiponsetup.py:SkipOnSetupTest.test_wont_be_executed:'
' SKIP'
,
result
.
stdout
)
def
test_ugly_echo_cmd
(
self
):
if
not
os
.
path
.
exists
(
"/bin/echo"
):
self
.
skipTest
(
"Program /bin/echo does not exist"
)
os
.
chdir
(
basedir
)
cmd_line
=
(
'./scripts/avocado run "/bin/echo -ne '
'foo
\\\\\\
n
\\\'\\\\\\
"
\\\\\\
nbar/baz" --job-results-dir %s'
' --sysinfo=off --show-job-log'
%
self
.
tmpdir
)
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %s:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertIn
(
'[stdout] foo'
,
result
.
stdout
,
result
)
self
.
assertIn
(
'[stdout]
\'
"'
,
result
.
stdout
,
result
)
self
.
assertIn
(
'[stdout] bar/baz'
,
result
.
stdout
,
result
)
self
.
assertIn
(
'PASS /bin/echo -ne foo
\\\\
n
\\\'\\
"
\\\\
nbar/baz'
,
result
.
stdout
,
result
)
# logdir name should escape special chars (/)
test_dirs
=
glob
.
glob
(
os
.
path
.
join
(
self
.
tmpdir
,
'latest'
,
'test-results'
,
'*'
))
self
.
assertEqual
(
len
(
test_dirs
),
1
,
"There are multiple directories in"
" test-results dir, but only one test was executed: "
"%s"
%
(
test_dirs
))
self
.
assertEqual
(
os
.
path
.
basename
(
test_dirs
[
0
]),
'_bin_echo -ne foo
\\\\
n
\\\'\\
"
\\\\
nbar_baz'
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
...
...
@@ -695,6 +722,7 @@ class PluginsJSONTest(AbsPluginsTest, unittest.TestCase):
n_skip
=
json_data
[
'skip'
]
self
.
assertEqual
(
n_skip
,
e_nskip
,
"Different number of skipped tests"
)
return
json_data
def
test_json_plugin_passtest
(
self
):
self
.
run_and_check
(
'passtest'
,
exit_codes
.
AVOCADO_ALL_OK
,
...
...
@@ -712,6 +740,19 @@ class PluginsJSONTest(AbsPluginsTest, unittest.TestCase):
self
.
run_and_check
(
'errortest'
,
exit_codes
.
AVOCADO_TESTS_FAIL
,
1
,
1
,
0
,
0
)
def
test_ugly_echo_cmd
(
self
):
if
not
os
.
path
.
exists
(
"/bin/echo"
):
self
.
skipTest
(
"Program /bin/echo does not exist"
)
data
=
self
.
run_and_check
(
'"/bin/echo -ne foo
\\\\\\
n
\\\'\\\\\\
"
\\\\\\
'
'nbar/baz"'
,
exit_codes
.
AVOCADO_ALL_OK
,
1
,
0
,
0
,
0
)
# The executed test should be this
self
.
assertEqual
(
data
[
'tests'
][
0
][
'url'
],
'/bin/echo -ne foo
\\\\
n
\\\'\\
"
\\\\
nbar/baz'
)
# logdir name should escape special chars (/)
self
.
assertEqual
(
os
.
path
.
basename
(
data
[
'tests'
][
0
][
'logdir'
]),
'_bin_echo -ne foo
\\\\
n
\\\'\\
"
\\\\
nbar_baz'
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
super
(
PluginsJSONTest
,
self
).
tearDown
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录