iotests.py: filter out successful output of qemu-img create

The only "feature" of this "Formatting ..." line is that we have to
update it every time we add new option. Let's drop it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20211223160144.1097696-10-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2021-12-23 17:01:34 +01:00 committed by Hanna Reitz
parent 12a936171d
commit a70eeb3d47
7 changed files with 11 additions and 67 deletions

View file

@ -150,7 +150,9 @@ def qemu_tool_popen(args: Sequence[str],
def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
connect_stderr: bool = True) -> Tuple[str, int]:
connect_stderr: bool = True,
drop_successful_output: bool = False) \
-> Tuple[str, int]:
"""
Run a tool and return both its output and its exit code
"""
@ -160,6 +162,8 @@ def qemu_tool_pipe_and_status(tool: str, args: Sequence[str],
cmd = ' '.join(args)
sys.stderr.write(f'{tool} received signal \
{-subp.returncode}: {cmd}\n')
if drop_successful_output and subp.returncode == 0:
output = ''
return (output, subp.returncode)
def qemu_img_create_prepare_args(args: List[str]) -> List[str]:
@ -204,8 +208,10 @@ def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]:
"""
Run qemu-img and return both its output and its exit code
"""
is_create = bool(args and args[0] == 'create')
full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
return qemu_tool_pipe_and_status('qemu-img', full_args)
return qemu_tool_pipe_and_status('qemu-img', full_args,
drop_successful_output=is_create)
def qemu_img(*args: str) -> int:
'''Run qemu-img and return the exit code'''