* [PATCH] decodetree: Add --output-null for meson testing
@ 2023-05-31 23:25 Richard Henderson
2023-06-01 1:51 ` Thomas Huth
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2023-05-31 23:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Thomas Huth
Using "-o /dev/null" fails on Windows. Rather that working
around this in meson, add a separate command-line option so
that we can use python's os.devnull.
Reported-by: Thomas Huth <thuth@redhat.com>
Fixes: 656666dc7d1b ("tests/decode: Convert tests to meson")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
scripts/decodetree.py | 18 ++++++++++--------
tests/decode/meson.build | 4 ++--
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/scripts/decodetree.py b/scripts/decodetree.py
index 13db585d04..a8a6cb69cd 100644
--- a/scripts/decodetree.py
+++ b/scripts/decodetree.py
@@ -42,6 +42,7 @@
input_file = ''
output_file = None
output_fd = None
+output_null = False
insntype = 'uint32_t'
decode_function = 'decode'
@@ -145,12 +146,7 @@ def error_with_file(file, lineno, *args):
if output_file and output_fd:
output_fd.close()
- # Do not try to remove e.g. -o /dev/null
- if not output_file.startswith("/dev"):
- try:
- os.remove(output_file)
- except PermissionError:
- pass
+ os.remove(output_file)
exit(0 if testforerror else 1)
# end error_with_file
@@ -1501,6 +1497,7 @@ def main():
global translate_prefix
global output_fd
global output_file
+ global output_null
global input_file
global insnwidth
global insntype
@@ -1514,7 +1511,8 @@ def main():
decode_scope = 'static '
long_opts = ['decode=', 'translate=', 'output=', 'insnwidth=',
- 'static-decode=', 'varinsnwidth=', 'test-for-error']
+ 'static-decode=', 'varinsnwidth=', 'test-for-error',
+ 'output-null']
try:
(opts, args) = getopt.gnu_getopt(sys.argv[1:], 'o:vw:', long_opts)
except getopt.GetoptError as err:
@@ -1545,6 +1543,8 @@ def main():
error(0, 'cannot handle insns of width', insnwidth)
elif o == '--test-for-error':
testforerror = True
+ elif o == '--output-null':
+ output_null = True
else:
assert False, 'unhandled option'
@@ -1574,7 +1574,9 @@ def main():
stree = build_size_tree(toppat.pats, 8, 0, 0)
prop_size(stree)
- if output_file:
+ if output_null:
+ output_fd = open(os.devnull, 'wt', encoding='utf-8', errors="ignore")
+ elif output_file:
output_fd = open(output_file, 'wt', encoding='utf-8')
else:
output_fd = io.TextIOWrapper(sys.stdout.buffer,
diff --git a/tests/decode/meson.build b/tests/decode/meson.build
index 38a0629d67..b13fada980 100644
--- a/tests/decode/meson.build
+++ b/tests/decode/meson.build
@@ -53,12 +53,12 @@ decodetree = find_program(meson.project_source_root() / 'scripts/decodetree.py')
foreach t: err_tests
test(fs.replace_suffix(t, ''),
- decodetree, args: ['-o', '/dev/null', '--test-for-error', files(t)],
+ decodetree, args: ['--output-null', '--test-for-error', files(t)],
suite: suite)
endforeach
foreach t: succ_tests
test(fs.replace_suffix(t, ''),
- decodetree, args: ['-o', '/dev/null', files(t)],
+ decodetree, args: ['--output-null', files(t)],
suite: suite)
endforeach
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] decodetree: Add --output-null for meson testing
2023-05-31 23:25 [PATCH] decodetree: Add --output-null for meson testing Richard Henderson
@ 2023-06-01 1:51 ` Thomas Huth
2023-06-01 4:10 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huth @ 2023-06-01 1:51 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
On 01/06/2023 01.25, Richard Henderson wrote:
> Using "-o /dev/null" fails on Windows. Rather that working
> around this in meson, add a separate command-line option so
> that we can use python's os.devnull.
>
> Reported-by: Thomas Huth <thuth@redhat.com>
> Fixes: 656666dc7d1b ("tests/decode: Convert tests to meson")
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> scripts/decodetree.py | 18 ++++++++++--------
> tests/decode/meson.build | 4 ++--
> 2 files changed, 12 insertions(+), 10 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] decodetree: Add --output-null for meson testing
2023-06-01 1:51 ` Thomas Huth
@ 2023-06-01 4:10 ` Richard Henderson
0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2023-06-01 4:10 UTC (permalink / raw)
To: Thomas Huth, qemu-devel
On 5/31/23 18:51, Thomas Huth wrote:
> On 01/06/2023 01.25, Richard Henderson wrote:
>> Using "-o /dev/null" fails on Windows. Rather that working
>> around this in meson, add a separate command-line option so
>> that we can use python's os.devnull.
>>
>> Reported-by: Thomas Huth <thuth@redhat.com>
>> Fixes: 656666dc7d1b ("tests/decode: Convert tests to meson")
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> scripts/decodetree.py | 18 ++++++++++--------
>> tests/decode/meson.build | 4 ++--
>> 2 files changed, 12 insertions(+), 10 deletions(-)
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
>
Thanks. Applied, with typo in the first line above fixed, to master in preparation for
tomorrow's refresh of ci minutes.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-01 4:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31 23:25 [PATCH] decodetree: Add --output-null for meson testing Richard Henderson
2023-06-01 1:51 ` Thomas Huth
2023-06-01 4:10 ` Richard Henderson
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).