Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
94ce6e64
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,发现更多精彩内容 >>
提交
94ce6e64
编写于
8月 30, 2016
作者:
A
Amador Pahim
提交者:
GitHub
8月 30, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1427 from clebergnu/utils_partition
avocado/utils/partition.py: test related improvements
上级
4ec2576c
9bab6c63
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
8 deletion
+28
-8
avocado/utils/partition.py
avocado/utils/partition.py
+2
-1
selftests/unit/test_utils_partition.py
selftests/unit/test_utils_partition.py
+26
-7
未找到文件。
avocado/utils/partition.py
浏览文件 @
94ce6e64
...
...
@@ -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.
"""
...
...
selftests/unit/test_utils_partition.py
浏览文件 @
94ce6e64
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录