summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Gomez <agomez@igalia.com>2021-05-17 22:50:21 +0300
committerAndres Gomez <agomez@igalia.com>2021-05-18 12:06:44 +0300
commit9d87cc3d79e0c7e572273b94dcb51882f4d83d7f (patch)
tree6c0385fed493ec04ca49be08d39dfa578c05dc7d
parent3b84e8a37ec149160e95aef2e9b0dfa262da7d69 (diff)
framework/replay: send backend's subprocess stderr to sys.stderr
Make it explicit, in case it was redirected for the parent process. See: https://bugs.python.org/issue44158 Signed-off-by: Andres Gomez <agomez@igalia.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Martin Peres <martin.peres@mupuf.org> Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/534>
-rw-r--r--framework/replay/backends/abstract.py8
-rw-r--r--framework/replay/backends/apitrace.py3
-rw-r--r--framework/replay/backends/gfxreconstruct.py5
-rw-r--r--unittests/framework/replay/backends/test_apitrace.py43
-rw-r--r--unittests/framework/replay/backends/test_gfxreconstruct.py43
-rw-r--r--unittests/framework/replay/backends/test_renderdoc.py2
6 files changed, 57 insertions, 47 deletions
diff --git a/framework/replay/backends/abstract.py b/framework/replay/backends/abstract.py
index f84a4e0e3..937d3a8d1 100644
--- a/framework/replay/backends/abstract.py
+++ b/framework/replay/backends/abstract.py
@@ -33,6 +33,7 @@ This module provides a base class for replayer dump backend modules.
import abc
import functools
import subprocess
+import sys
from os import path
@@ -89,7 +90,12 @@ class DumpBackend(metaclass=abc.ABCMeta):
@staticmethod
def _run_logged_command(cmd, env):
- ret = subprocess.run(cmd, stdout=subprocess.PIPE, env=env)
+ # Explicitly send the stderr to the fd at sys.stderr in case it was
+ # redirected for the parent process.
+ # See:
+ # https://bugs.python.org/issue44158
+ ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=sys.stderr,
+ env=env)
logoutput = '[dump_trace_images] Running: {}\n'.format(
' '.join(cmd)).encode() + ret.stdout
print(logoutput.decode(errors='replace'))
diff --git a/framework/replay/backends/apitrace.py b/framework/replay/backends/apitrace.py
index 692badeb8..07d935c52 100644
--- a/framework/replay/backends/apitrace.py
+++ b/framework/replay/backends/apitrace.py
@@ -29,6 +29,7 @@
import os
import subprocess
+import sys
from os import path
@@ -94,7 +95,7 @@ class APITraceBackend(DumpBackend):
default='apitrace')
cmd = cmd_wrapper + [apitrace_bin,
'dump', '--calls=frame', self._trace_path]
- ret = subprocess.run(cmd, stdout=subprocess.PIPE)
+ ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=sys.stderr)
logoutput = '[dump_trace_images] Running: {}\n'.format(
' '.join(cmd)) + ret.stdout.decode(errors='replace')
print(logoutput)
diff --git a/framework/replay/backends/gfxreconstruct.py b/framework/replay/backends/gfxreconstruct.py
index b247a5b67..8186e8130 100644
--- a/framework/replay/backends/gfxreconstruct.py
+++ b/framework/replay/backends/gfxreconstruct.py
@@ -30,6 +30,7 @@
import os
import re
import subprocess
+import sys
from packaging import version
from os import path
@@ -79,7 +80,7 @@ class GFXReconstructBackend(DumpBackend):
('replay', 'gfxrecon-info_bin'),
default='gfxrecon-info')
cmd = [gfxrecon_info_bin, self._trace_path]
- ret = subprocess.run(cmd, stdout=subprocess.PIPE)
+ ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=sys.stderr)
lines = ret.stdout.decode(errors='replace').splitlines()
print(ret.stdout.decode(errors='replace'))
try:
@@ -90,7 +91,7 @@ class GFXReconstructBackend(DumpBackend):
def _check_version(self, gfxrecon_replay_bin):
cmd = [gfxrecon_replay_bin, '--version']
- ret = subprocess.run(cmd, stdout=subprocess.PIPE)
+ ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=sys.stderr)
lines = ret.stdout.decode(errors='replace').splitlines()
print(ret.stdout.decode(errors='replace'))
try:
diff --git a/unittests/framework/replay/backends/test_apitrace.py b/unittests/framework/replay/backends/test_apitrace.py
index aa9ea6ddb..84a936fca 100644
--- a/unittests/framework/replay/backends/test_apitrace.py
+++ b/unittests/framework/replay/backends/test_apitrace.py
@@ -29,6 +29,7 @@ import pytest
import os
import subprocess
+import sys
from os import path
@@ -48,7 +49,7 @@ def config(mocker):
class TestAPITraceBackend(object):
"""Tests for the APITraceBackend class."""
- def mock_apitrace_subprocess_run(self, cmd, stdout, env=None):
+ def mock_apitrace_subprocess_run(self, cmd, stdout, stderr, env=None):
get_last_call_args = ['dump', '--calls=frame']
replay_retrace_args = ['--headless']
if cmd[1:-1] == get_last_call_args:
@@ -212,12 +213,12 @@ class TestAPITraceBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.eglretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -239,12 +240,12 @@ class TestAPITraceBackend(object):
path.basename(trace_path) + '-')
m_calls = [self.mocker.call(
[self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.eglretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -267,7 +268,7 @@ class TestAPITraceBackend(object):
[self.eglretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)
for call in calls.split(','):
assert path.exists(snapshot_prefix + call.zfill(10) + '.png')
@@ -288,7 +289,7 @@ class TestAPITraceBackend(object):
[self.eglretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)
for call in calls.split(','):
assert not path.exists(snapshot_prefix + call.zfill(10) + '.png')
@@ -305,12 +306,12 @@ class TestAPITraceBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.eglretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -329,12 +330,12 @@ class TestAPITraceBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.eglretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -371,12 +372,12 @@ class TestAPITraceBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.wine, self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.wine, self.d3dretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -398,12 +399,12 @@ class TestAPITraceBackend(object):
path.basename(trace_path) + '-')
m_calls = [self.mocker.call(
[self.wine, self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.wine, self.d3dretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -426,7 +427,7 @@ class TestAPITraceBackend(object):
[self.wine, self.d3dretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)
for call in calls.split(','):
assert path.exists(snapshot_prefix + call.zfill(10) + '.png')
@@ -447,7 +448,7 @@ class TestAPITraceBackend(object):
[self.wine, self.d3dretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)
for call in calls.split(','):
assert not path.exists(snapshot_prefix + call.zfill(10) + '.png')
@@ -464,12 +465,12 @@ class TestAPITraceBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.wine, self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.wine, self.d3dretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -488,12 +489,12 @@ class TestAPITraceBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.wine, self.apitrace, 'dump', '--calls=frame', trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.wine, self.d3dretrace, '--headless',
'--snapshot=' + calls,
'--snapshot-prefix=' + snapshot_prefix, trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_apitrace_subprocess_run.call_count == 2
self.m_apitrace_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
diff --git a/unittests/framework/replay/backends/test_gfxreconstruct.py b/unittests/framework/replay/backends/test_gfxreconstruct.py
index 7f56e4191..3704b4c40 100644
--- a/unittests/framework/replay/backends/test_gfxreconstruct.py
+++ b/unittests/framework/replay/backends/test_gfxreconstruct.py
@@ -29,6 +29,7 @@ import pytest
import os
import subprocess
+import sys
import textwrap
from os import path
@@ -49,7 +50,7 @@ def config(mocker):
class TestGFXReconstructBackend(object):
"""Tests for the GFXReconstructBackend class."""
- def mock_gfxreconstruct_subprocess_run(self, cmd, stdout, env=None):
+ def mock_gfxreconstruct_subprocess_run(self, cmd, stdout, stderr, env=None):
if cmd[0].endswith(self.gfxrecon_info):
# VK get_last_call
ret = subprocess.CompletedProcess(cmd, 0)
@@ -211,16 +212,16 @@ class TestGFXReconstructBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_info, trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_replay,
'--screenshots', calls,
'--screenshot-dir', path.dirname(trace_path),
trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_gfxreconstruct_subprocess_run.call_count == 3
self.m_gfxreconstruct_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -253,17 +254,17 @@ class TestGFXReconstructBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_info, trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_replay] +
gfxrecon_replay_extra.split() +
['--screenshots', calls,
'--screenshot-dir', path.dirname(trace_path),
trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_gfxreconstruct_subprocess_run.call_count == 3
self.m_gfxreconstruct_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -285,16 +286,16 @@ class TestGFXReconstructBackend(object):
path.basename(trace_path) + '-')
m_calls = [self.mocker.call(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_info, trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_replay,
'--screenshots', calls,
'--screenshot-dir', self.output_dir,
trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_gfxreconstruct_subprocess_run.call_count == 3
self.m_gfxreconstruct_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -315,13 +316,13 @@ class TestGFXReconstructBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_replay,
'--screenshots', calls,
'--screenshot-dir', path.dirname(trace_path),
trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_gfxreconstruct_subprocess_run.call_count == 2
self.m_gfxreconstruct_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -342,13 +343,13 @@ class TestGFXReconstructBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_replay,
'--screenshots', calls,
'--screenshot-dir', path.dirname(trace_path),
trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_gfxreconstruct_subprocess_run.call_count == 2
self.m_gfxreconstruct_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -367,16 +368,16 @@ class TestGFXReconstructBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_info, trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_replay,
'--screenshots', calls,
'--screenshot-dir', path.dirname(trace_path),
trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_gfxreconstruct_subprocess_run.call_count == 3
self.m_gfxreconstruct_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -395,16 +396,16 @@ class TestGFXReconstructBackend(object):
snapshot_prefix = trace_path + '-'
m_calls = [self.mocker.call(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_info, trace_path],
- stdout=subprocess.PIPE),
+ stdout=subprocess.PIPE, stderr=sys.stderr),
self.mocker.call(
[self.gfxrecon_replay,
'--screenshots', calls,
'--screenshot-dir', path.dirname(trace_path),
trace_path],
- env=None, stdout=subprocess.PIPE)]
+ env=None, stdout=subprocess.PIPE, stderr=sys.stderr)]
assert self.m_gfxreconstruct_subprocess_run.call_count == 3
self.m_gfxreconstruct_subprocess_run.assert_has_calls(m_calls)
for call in calls.split(','):
@@ -432,6 +433,6 @@ class TestGFXReconstructBackend(object):
snapshot_prefix = trace_path + '-'
self.m_gfxreconstruct_subprocess_run.assert_called_once_with(
[self.gfxrecon_replay, '--version'],
- stdout=subprocess.PIPE)
+ stdout=subprocess.PIPE, stderr=sys.stderr)
for call in calls.split(','):
assert not path.exists(snapshot_prefix + call + '.png')
diff --git a/unittests/framework/replay/backends/test_renderdoc.py b/unittests/framework/replay/backends/test_renderdoc.py
index f78bb944a..3c0fbcc27 100644
--- a/unittests/framework/replay/backends/test_renderdoc.py
+++ b/unittests/framework/replay/backends/test_renderdoc.py
@@ -48,7 +48,7 @@ def config(mocker):
class TestRenderDocBackend(object):
"""Tests for the RenderDocBackend class."""
- def mock_renderdoc_subprocess_run(self, cmd, stdout, env=None):
+ def mock_renderdoc_subprocess_run(self, cmd, stdout, stderr, env=None):
ret = subprocess.CompletedProcess(cmd, 0)
if len(cmd) > 3:
calls = cmd[3:]