Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
981b3ba4
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,发现更多精彩内容 >>
提交
981b3ba4
编写于
2月 12, 2016
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'ldoktor/qemu-bin2'
上级
4f528ae1
e34a1de4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
0 deletion
+62
-0
.travis.yml
.travis.yml
+17
-0
Makefile
Makefile
+3
-0
avocado/utils/process.py
avocado/utils/process.py
+26
-0
selftests/unit/test_utils_process.py
selftests/unit/test_utils_process.py
+16
-0
未找到文件。
.travis.yml
浏览文件 @
981b3ba4
...
...
@@ -27,3 +27,20 @@ script:
-
python setup.py develop
-
./selftests/run
-
./selftests/check_tmp_dirs
-
|
ERR=""
MASTER=$(git rev-parse origin/master)
echo Master is $MASTER
for COMMIT in $(git rev-list origin..HEAD); do
echo
echo "--------------------< $(git log -1 --oneline $COMMIT) >--------------------"
echo
echo
git checkout $COMMIT || ERR=$(echo -e "$ERR\nUnable to checkout $(git log -1 --oneline $COMMIT)")
python setup.py develop && make smokecheck || ERR=$(echo -e "$ERR\n$(git log -1 --oneline)")
done
if [ "$ERR" ]; then
echo
echo "Incremental smokecheck failed: $ERR"
exit -1
fi
Makefile
浏览文件 @
981b3ba4
...
...
@@ -123,6 +123,9 @@ requirements:
requirements-selftests
:
requirements
-
grep
-v
'^#'
requirements-selftests.txt | xargs
-n
1 pip
install
--upgrade
smokecheck
:
./scripts/avocado run passtest
check
:
clean check_cyclical modules_boundaries
selftests/checkall
selftests/check_tmp_dirs
...
...
avocado/utils/process.py
浏览文件 @
981b3ba4
...
...
@@ -18,6 +18,7 @@ Functions dedicated to find and run external commands.
import
logging
import
os
import
re
import
StringIO
import
signal
import
time
...
...
@@ -63,6 +64,10 @@ WRAP_PROCESS_NAMES_EXPR = []
UNDEFINED_BEHAVIOR_EXCEPTION
=
None
# variable=value bash assignment
_RE_BASH_SET_VARIABLE
=
re
.
compile
(
r
"[a-zA-Z]\w*=.*"
)
class
CmdError
(
Exception
):
def
__init__
(
self
,
command
=
None
,
result
=
None
,
additional_text
=
None
):
...
...
@@ -178,6 +183,27 @@ def get_children_pids(ppid):
return
system_output
(
"ps -L --ppid=%d -o lwp"
%
ppid
,
verbose
=
False
).
split
(
'
\n
'
)[
1
:]
def
binary_from_shell_cmd
(
cmd
):
"""
Tries to find the first binary path from a simple shell-like command.
:note: It's a naive implementation, but for commands like:
`VAR=VAL binary -args || true` gives the right resutl (binary)
:param cmd: simple shell-like binary
:return: first found binary from the cmd
"""
try
:
cmds
=
shlex
.
split
(
cmd
)
except
ValueError
:
log
.
warning
(
"binary_from_shell_cmd: Shlex split of %s failed, using "
"using simple split."
,
cmd
)
cmds
=
cmd
.
split
(
" "
)
for
item
in
cmds
:
if
not
_RE_BASH_SET_VARIABLE
.
match
(
item
):
return
item
raise
ValueError
(
"Unable to parse first binary from '%s'"
%
cmd
)
class
CmdResult
(
object
):
"""
...
...
selftests/unit/test_utils_process.py
浏览文件 @
981b3ba4
...
...
@@ -202,5 +202,21 @@ class TestProcessRun(unittest.TestCase):
p
=
process
.
run
(
cmd
=
'ls -l'
,
sudo
=
True
,
shell
=
True
,
ignore_status
=
True
)
self
.
assertEqual
(
p
.
command
,
expected_command
)
class
MiscProcessTests
(
unittest
.
TestCase
):
def
test_binary_from_shell
(
self
):
self
.
assertEqual
(
"binary"
,
process
.
binary_from_shell_cmd
(
"binary"
))
res
=
process
.
binary_from_shell_cmd
(
"MY_VAR=foo myV4r=123 "
"quote='a b c' QUOTE=
\"
1 2 && b
\"
"
"QuOtE=
\"
1 2
\"
foo' 3 4' first_bin "
"second_bin VAR=xyz"
)
self
.
assertEqual
(
"first_bin"
,
res
)
res
=
process
.
binary_from_shell_cmd
(
"VAR=VALUE 1st_binary var=value "
"second_binary"
)
self
.
assertEqual
(
"1st_binary"
,
res
)
res
=
process
.
binary_from_shell_cmd
(
"FOO=bar ./bin var=value"
)
self
.
assertEqual
(
"./bin"
,
res
)
if
__name__
==
"__main__"
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录