From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: qemu-block@nongnu.org, jsnow@redhat.com, qemu-devel@nongnu.org,
mreitz@redhat.com, den@openvz.org
Subject: Re: [PATCH v8 2/5] iotests: add testenv.py
Date: Mon, 25 Jan 2021 23:05:28 +0100 [thread overview]
Message-ID: <20210125220528.GA170615@merkur.fritz.box> (raw)
In-Reply-To: <20210123210428.27220-3-vsementsov@virtuozzo.com>
Am 23.01.2021 um 22:04 hat Vladimir Sementsov-Ogievskiy geschrieben:
> Add TestEnv class, which will handle test environment in a new python
> iotests running framework.
>
> Don't add compat=1.1 for qcow2 IMGOPTS, as v3 is default anyway.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> tests/qemu-iotests/testenv.py | 278 ++++++++++++++++++++++++++++++++++
> 1 file changed, 278 insertions(+)
> create mode 100644 tests/qemu-iotests/testenv.py
>
> diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
> new file mode 100644
> index 0000000000..348af593e9
> --- /dev/null
> +++ b/tests/qemu-iotests/testenv.py
> @@ -0,0 +1,278 @@
> +# TestEnv class to manage test environment variables.
> +#
> +# Copyright (c) 2020-2021 Virtuozzo International GmbH
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +#
> +
> +import os
> +import sys
> +import tempfile
> +from pathlib import Path
> +import shutil
> +import collections
> +import random
> +import subprocess
> +import glob
> +from contextlib import AbstractContextManager
> +from typing import Dict, Any, Optional
> +
> +
> +def get_default_machine(qemu_prog: str) -> str:
> + outp = subprocess.run([qemu_prog, '-machine', 'help'], check=True,
> + universal_newlines=True,
> + stdout=subprocess.PIPE).stdout
> +
> + machines = outp.split('\n')
> + default_machine = next(m for m in machines if m.endswith(' (default)'))
> + default_machine = default_machine.split(' ', 1)[0]
> +
> + alias_suf = ' (alias of {})'.format(default_machine)
> + alias = next((m for m in machines if m.endswith(alias_suf)), None)
> + if alias is not None:
> + default_machine = alias.split(' ', 1)[0]
> +
> + return default_machine
> +
> +
> +class TestEnv(AbstractContextManager['TestEnv']):
I'm getting CI failures here:
Traceback (most recent call last):
File "./check", line 23, in <module>
from testenv import TestEnv
File "/builds/.../qemu/tests/qemu-iotests/testenv.py", line 49, in <module>
class TestEnv(AbstractContextManager['TestEnv']):
TypeError: 'ABCMeta' object is not subscriptable
On the other hand, if I make it just AbstractContextManager without
giving the type parameter, mypy complains:
testenv.py:49: error: Missing type parameters for generic type "ContextManager"
I guess I need to have another look into this tomorrow.
By the way, mypy --strict still finds a few errors. I think we want to
address at least the warnings about missing type annotatings and calling
untyped functions.
Kevin
next prev parent reply other threads:[~2021-01-25 22:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-23 21:04 [PATCH v8 0/5] Rework iotests/check Vladimir Sementsov-Ogievskiy
2021-01-23 21:04 ` [PATCH v8 1/5] iotests: add findtests.py Vladimir Sementsov-Ogievskiy
2021-01-23 21:04 ` [PATCH v8 2/5] iotests: add testenv.py Vladimir Sementsov-Ogievskiy
2021-01-25 12:32 ` Vladimir Sementsov-Ogievskiy
2021-01-25 22:05 ` Kevin Wolf [this message]
2021-01-26 8:28 ` Vladimir Sementsov-Ogievskiy
2021-01-26 9:45 ` Kevin Wolf
2021-01-26 10:08 ` Vladimir Sementsov-Ogievskiy
2021-01-26 10:13 ` Kevin Wolf
2021-01-23 21:04 ` [PATCH v8 3/5] iotests: add testrunner.py Vladimir Sementsov-Ogievskiy
2021-01-23 21:04 ` [PATCH v8 4/5] iotests: rewrite check into python Vladimir Sementsov-Ogievskiy
2021-01-23 21:04 ` [PATCH v8 5/5] iotests: rename and move 169 and 199 tests Vladimir Sementsov-Ogievskiy
2021-01-25 16:08 ` [PATCH v8 0/5] Rework iotests/check Kevin Wolf
2021-01-25 16:23 ` Vladimir Sementsov-Ogievskiy
2021-01-25 16:36 ` Vladimir Sementsov-Ogievskiy
2021-01-25 16:50 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210125220528.GA170615@merkur.fritz.box \
--to=kwolf@redhat.com \
--cc=den@openvz.org \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).