From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org
Cc: kwolf@redhat.com, den@openvz.org, jsnow@redhat.com,
qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [PATCH v7 09/11] iotests: add testrunner.py
Date: Thu, 21 Jan 2021 11:02:56 -0600 [thread overview]
Message-ID: <ee9c73e1-2c33-2df0-0af7-ad19a29c8139@redhat.com> (raw)
In-Reply-To: <20210116134424.82867-10-vsementsov@virtuozzo.com>
On 1/16/21 7:44 AM, Vladimir Sementsov-Ogievskiy wrote:
> Add TestRunner class, which will run tests in a new python iotests
> running framework.
>
> There are some differences with current ./check behavior, most
> significant are:
> - Consider all tests self-executable, just run them, don't run python
> by hand.
> - Elapsed time is cached in json file
> - Elapsed time precision increased a bit
> - use python difflib instead of "diff -w", to ignore spaces at line
> ends strip lines by hand. Do not ignore other spaces.
Awkward wording. Maybe:
Instead of using "diff -w" which ignores all whitespace differences,
manually strip whitespace at line end then use python difflib, which no
longer ignores spacing mid-line
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> tests/qemu-iotests/testrunner.py | 344 +++++++++++++++++++++++++++++++
> 1 file changed, 344 insertions(+)
> create mode 100644 tests/qemu-iotests/testrunner.py
>
> diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
> new file mode 100644
> index 0000000000..92722cc68b
> --- /dev/null
> +++ b/tests/qemu-iotests/testrunner.py
> @@ -0,0 +1,344 @@
> +# Class for actual tests running.
for actually running tests
again, should this file be 755 with #! python?
> +
> +def file_diff(file1: str, file2: str) -> List[str]:
> + with open(file1) as f1, open(file2) as f2:
> + # We want to ignore spaces at line ends. There are a lot of mess about
> + # it in iotests.
> + # TODO: fix all tests to not produce extra spaces, fix all .out files
> + # and use strict diff here!
> + seq1 = [line.rstrip() for line in f1]
> + seq2 = [line.rstrip() for line in f2]
> + return list(difflib.unified_diff(seq1, seq2, file1, file2))
Offhand, do you have the list of tests where (actual/expected) output
has trailing whitespace and would fail without the .rstrip()?
> +
> +
> +# We want to save current tty settings during test run,
> +# since an aborting qemu call may leave things screwed up.
> +@contextmanager
> +def savetty() -> Iterator[None]:
> + isterm = sys.stdin.isatty()
> + if isterm:
> + fd = sys.stdin.fileno()
> + attr = termios.tcgetattr(0)
Isn't fd always going to be 0? It looks odd to hard-code zero in the
very next line; either we should s/0/fd/ here, or...
> +
> + try:
> + yield
> + finally:
> + if isterm:
> + termios.tcsetattr(fd, termios.TCSADRAIN, attr)
... s/fd/0/ here and drop fd altogether.
> +
> +
> +class LastElapsedTime(AbstractContextManager['LastElapsedTime']):
> + """ Cache for elapsed time for tests, to show it during new test run
> +
> + Use get() in any time. But, if use update you should then call save(),
> + or use update() inside with-block.
Grammar is hard, maybe:
It is safe to use get() at any time. To use update(), you must either
use a with-block or first use save().
> + def test_print_one_line(self, test: str, starttime: str,
> +
> + if status == 'pass':
> + col = '\033[32m'
> + elif status == 'fail':
> + col = '\033[1m\033[31m'
> + elif status == 'not run':
> + col = '\033[33m'
This hard-codes the use of ANSI escape sequences without first checking
that we are writing to a terminal. Is that wise? Should we have this
be tunable by a tri-state command-line option, similar to ls --color?
(--color=auto is default, and bases decision on istty(), --color=off
turns color off even for a terminal, --color=on uses color even when
outputting to a pipe, which can be useful depending on the other end of
the pipeline...)
> + with f_test.open() as f:
> + try:
> + if f.readline() == '#!/usr/bin/env python3':
> + args.insert(0, self.env.python)
> + except UnicodeDecodeError: # binary test? for future.
> + pass
Is pass the right action here? Or will it silently skip a test file
with encoding errors?
Again, I'm not comfortable enough to give a full review of the python,
but it looks fairly similar to the existing shell code, and with the
series applied, things still work. So I can offer
Tested-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2021-01-21 17:09 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-16 13:44 [PATCH v7 00/11] Rework iotests/check Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 01/11] iotests/277: use dot slash for nbd-fault-injector.py running Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 02/11] iotests/303: use dot slash for qcow2.py running Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 03/11] iotests: fix some whitespaces in test output files Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 04/11] iotests: make tests executable Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 05/11] iotests/294: add shebang line Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 06/11] iotests: define group in each iotest Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 07/11] iotests: add findtests.py Vladimir Sementsov-Ogievskiy
2021-01-21 16:18 ` Eric Blake
2021-01-21 16:21 ` Eric Blake
2021-01-21 16:57 ` Vladimir Sementsov-Ogievskiy
2021-01-22 11:48 ` Kevin Wolf
2021-01-22 11:57 ` Vladimir Sementsov-Ogievskiy
2021-01-22 12:45 ` Kevin Wolf
2021-01-22 13:16 ` Vladimir Sementsov-Ogievskiy
2021-01-22 13:34 ` Kevin Wolf
2021-01-22 13:52 ` Vladimir Sementsov-Ogievskiy
2021-01-22 11:49 ` Kevin Wolf
2021-01-22 11:59 ` Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 08/11] iotests: add testenv.py Vladimir Sementsov-Ogievskiy
2021-01-21 16:48 ` Eric Blake
2021-01-21 17:03 ` Vladimir Sementsov-Ogievskiy
2021-01-22 14:34 ` Kevin Wolf
2021-01-16 13:44 ` [PATCH v7 09/11] iotests: add testrunner.py Vladimir Sementsov-Ogievskiy
2021-01-21 17:02 ` Eric Blake [this message]
2021-01-21 17:17 ` Vladimir Sementsov-Ogievskiy
2021-01-22 14:11 ` Kevin Wolf
2021-01-22 14:22 ` Vladimir Sementsov-Ogievskiy
2021-01-22 14:51 ` Kevin Wolf
2021-01-22 15:01 ` Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 10/11] iotests: rewrite check into python Vladimir Sementsov-Ogievskiy
2021-01-21 17:22 ` Eric Blake
2021-01-22 13:53 ` Vladimir Sementsov-Ogievskiy
2021-01-22 16:08 ` Kevin Wolf
2021-01-23 15:08 ` Vladimir Sementsov-Ogievskiy
2021-01-25 12:02 ` Kevin Wolf
2021-01-25 12:31 ` Vladimir Sementsov-Ogievskiy
2021-01-16 13:44 ` [PATCH v7 11/11] iotests: rename and move 169 and 199 tests Vladimir Sementsov-Ogievskiy
2021-01-20 20:52 ` [PATCH v7 00/11] Rework iotests/check Eric Blake
2021-01-22 11:27 ` Kevin Wolf
2021-01-22 11:32 ` Vladimir Sementsov-Ogievskiy
2021-01-22 16:08 ` Eric Blake
2021-01-22 16:18 ` Kevin Wolf
2021-01-21 15:08 ` Paolo Bonzini
2021-01-22 16:16 ` Kevin Wolf
2021-01-23 15:14 ` Vladimir Sementsov-Ogievskiy
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=ee9c73e1-2c33-2df0-0af7-ad19a29c8139@redhat.com \
--to=eblake@redhat.com \
--cc=den@openvz.org \
--cc=jsnow@redhat.com \
--cc=kwolf@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).