Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
78de5264
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,发现更多精彩内容 >>
提交
78de5264
编写于
2月 13, 2017
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
selftests: Adapt test_basic to be compatible with macOS
Signed-off-by:
N
Lucas Meneghel Rodrigues
<
lookkas@gmail.com
>
上级
0aae0bbc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
10 deletion
+23
-10
selftests/functional/test_basic.py
selftests/functional/test_basic.py
+23
-10
未找到文件。
selftests/functional/test_basic.py
浏览文件 @
78de5264
...
...
@@ -12,6 +12,7 @@ import time
import
xml.dom.minidom
import
zipfile
import
unittest
import
psutil
import
pkg_resources
...
...
@@ -24,7 +25,6 @@ from avocado.utils import path as utils_path
basedir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'..'
,
'..'
)
basedir
=
os
.
path
.
abspath
(
basedir
)
PASS_SCRIPT_CONTENTS
=
"""#!/bin/sh
true
"""
...
...
@@ -105,8 +105,18 @@ def probe_binary(binary):
return
None
TRUE_CMD
=
probe_binary
(
'true'
)
CC_BINARY
=
probe_binary
(
'cc'
)
ECHO_BINARY
=
probe_binary
(
'echo'
)
# On macOS, the default GNU coreutils installation (brew)
# installs the gnu utility versions with a g prefix. It still has the
# BSD versions of the core utilities installed on their expected paths
# but their behavior and flags are in most cases different.
GNU_ECHO_BINARY
=
probe_binary
(
'echo'
)
if
GNU_ECHO_BINARY
is
not
None
:
echo_manpage
=
process
.
run
(
'man %s'
%
os
.
path
.
basename
(
GNU_ECHO_BINARY
)).
stdout
if
'-e'
not
in
echo_manpage
:
GNU_ECHO_BINARY
=
probe_binary
(
'gecho'
)
READ_BINARY
=
probe_binary
(
'read'
)
SLEEP_BINARY
=
probe_binary
(
'sleep'
)
...
...
@@ -470,7 +480,7 @@ class RunnerOperationTest(unittest.TestCase):
log
=
open
(
debuglog
,
'r'
).
read
()
# Remove the result dir
shutil
.
rmtree
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
debuglog
)))
self
.
assertIn
(
'/tmp'
,
debuglog
)
# Use tmp dir, not default location
self
.
assertIn
(
tempfile
.
gettempdir
()
,
debuglog
)
# Use tmp dir, not default location
self
.
assertEqual
(
result
[
'job_id'
],
u
'0'
*
40
)
# Check if all tests were skipped
self
.
assertEqual
(
result
[
'skip'
],
4
)
...
...
@@ -564,13 +574,14 @@ class RunnerHumanOutputTest(unittest.TestCase):
self
.
assertIn
(
'skiponsetup.py:SkipOnSetupTest.test_wont_be_executed:'
' SKIP'
,
result
.
stdout
)
@
unittest
.
skipIf
(
not
ECHO_BINARY
,
'echo binary not available'
)
@
unittest
.
skipIf
(
not
GNU_ECHO_BINARY
,
'GNU style echo binary not available'
)
def
test_ugly_echo_cmd
(
self
):
os
.
chdir
(
basedir
)
cmd_line
=
(
'./scripts/avocado run --external-runner "%s -ne" '
'"foo
\\\\\\
n
\\\'\\\\\\
"
\\\\\\
nbar/baz" --job-results-dir %s'
' --sysinfo=off --show-job-log'
%
(
ECHO_BINARY
,
self
.
tmpdir
))
(
GNU_
ECHO_BINARY
,
self
.
tmpdir
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
...
...
@@ -716,8 +727,10 @@ class RunnerSimpleTest(unittest.TestCase):
%
(
self
.
tmpdir
,
SLEEP_BINARY
))
proc
.
read_until_output_matches
([
"\(1/1\)"
],
timeout
=
3
,
internal_timeout
=
0.01
)
# We need pid of the avocado, not the shell executing it
pid
=
int
(
process
.
get_children_pids
(
proc
.
get_pid
())[
0
])
# We need pid of the avocado process, not the shell executing it
avocado_shell
=
psutil
.
Process
(
proc
.
get_pid
())
avocado_proc
=
avocado_shell
.
children
()[
0
]
pid
=
avocado_proc
.
pid
os
.
kill
(
pid
,
signal
.
SIGTSTP
)
# This freezes the process
deadline
=
time
.
time
()
+
9
while
time
.
time
()
<
deadline
:
...
...
@@ -807,7 +820,7 @@ class ExternalRunnerTest(unittest.TestCase):
def
test_externalrunner_no_url
(
self
):
os
.
chdir
(
basedir
)
cmd_line
=
(
'./scripts/avocado run --job-results-dir %s --sysinfo=off '
'--external-runner=
/bin/true'
%
self
.
tmpdir
)
'--external-runner=
%s'
%
(
self
.
tmpdir
,
TRUE_CMD
)
)
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_output
=
(
'No test references provided nor any other '
'arguments resolved into tests'
)
...
...
@@ -1137,11 +1150,11 @@ class PluginsJSONTest(AbsPluginsTest, unittest.TestCase):
self
.
run_and_check
(
'errortest.py'
,
exit_codes
.
AVOCADO_TESTS_FAIL
,
1
,
1
,
0
,
0
)
@
unittest
.
skipIf
(
not
ECHO_BINARY
,
'echo binary not available'
)
@
unittest
.
skipIf
(
not
GNU_
ECHO_BINARY
,
'echo binary not available'
)
def
test_ugly_echo_cmd
(
self
):
data
=
self
.
run_and_check
(
'"-ne foo
\\\\\\
n
\\\'\\\\\\
"
\\\\\\
'
'nbar/baz"'
,
exit_codes
.
AVOCADO_ALL_OK
,
1
,
0
,
0
,
0
,
ECHO_BINARY
)
0
,
0
,
GNU_
ECHO_BINARY
)
# The executed test should be this
self
.
assertEqual
(
data
[
'tests'
][
0
][
'url'
],
'1--ne foo
\\\\
n
\\\'\\
"
\\\\
nbar/baz'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录