This is an automated email from the ASF dual-hosted git repository.
manupa pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 8f6fa8f [cleanup] Log compile errors for AOT tests (#10214)
8f6fa8f is described below
commit 8f6fa8f2c41406cb54d01647ba8731e4ceb8f4ab
Author: David Riazati <[email protected]>
AuthorDate: Tue Mar 1 23:55:21 2022 -0800
[cleanup] Log compile errors for AOT tests (#10214)
* [cleanup] Log compile errors for AOT tests
See #10213
* Update tests/python/relay/aot/aot_test_utils.py
* removed the encode of msg that is already str
Co-authored-by: lhutton1 <[email protected]>
Co-authored-by: driazati <[email protected]>
Co-authored-by: Manupa Karunaratne <[email protected]>
Co-authored-by: lhutton1 <[email protected]>
---
tests/python/integration/test_arm_mprofile_dsp.py | 1 +
tests/python/relay/aot/aot_test_utils.py | 45 ++++++++++++++---------
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/tests/python/integration/test_arm_mprofile_dsp.py
b/tests/python/integration/test_arm_mprofile_dsp.py
index cdafa91..484c19f 100644
--- a/tests/python/integration/test_arm_mprofile_dsp.py
+++ b/tests/python/integration/test_arm_mprofile_dsp.py
@@ -18,6 +18,7 @@ import sys
import numpy as np
import pytest
import tvm
+import tvm.testing
from tvm import relay
from tests.python.relay.aot.aot_test_utils import (
AOTTestModel,
diff --git a/tests/python/relay/aot/aot_test_utils.py
b/tests/python/relay/aot/aot_test_utils.py
index 63817fc..687fbe5 100644
--- a/tests/python/relay/aot/aot_test_utils.py
+++ b/tests/python/relay/aot/aot_test_utils.py
@@ -225,35 +225,46 @@ def parametrize_aot_options(test):
)(test)
-def subprocess_log_output(cmd, cwd, logfile):
+def subprocess_check_log_output(cmd, cwd, logfile):
"""
This method runs a process and logs the output to both a log file and
stdout
"""
_LOG.info("Execute (%s): %s", cwd, cmd)
cmd_base = cmd[0] if isinstance(cmd, (list, tuple)) else cmd.split(" ",
1)[0]
proc = subprocess.Popen(
- cmd, cwd=cwd, shell=True, bufsize=0, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
+ cmd,
+ cwd=cwd,
+ shell=True,
+ bufsize=0,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ encoding="utf-8",
)
- with open(logfile, "ab") as f:
- f.write(
- bytes(
- "\n"
- + "-" * 80
- + f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}:
Execute ({cwd}): {cmd}\n"
- + "-" * 80,
- "utf-8",
- )
+ stdout = ""
+ with open(logfile, "a") as f:
+ msg = (
+ "\n"
+ + "-" * 80
+ + f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}:
Execute ({cwd}): {cmd}\n"
+ + "-" * 80
)
+ f.write(msg)
+ stdout += msg + "\n"
while True:
data = proc.stdout.readline()
- _LOG.debug("%s: %s", cmd_base, str(data, "utf-8",
"replace").rstrip("\n"))
+ stdout += data
+ _LOG.debug("%s: %s", cmd_base, data.rstrip("\n"))
f.write(data)
# process is done if there is no data and the result is valid
if not data: # EOF
break
- return proc.wait()
+ proc.wait()
+ if proc.returncode != 0:
+ raise RuntimeError(
+ f"Subprocess failed: {cmd}\nstdout:\n{stdout}"
+ )
# TODO: Move to linker script with list of symbols rather than coding into
source
@@ -812,16 +823,16 @@ def run_and_check(
compile_command = f"{make_command} aot_test_runner"
if verbose:
print("Compile command:\n", compile_command)
- ret = subprocess_log_output(compile_command, ".", compile_log_path)
- assert ret == 0
+ subprocess_check_log_output(compile_command, ".", compile_log_path)
# Verify that runs fine
run_log_path = os.path.join(build_path, "test_run.log")
run_command = f"{make_command} run"
if verbose:
print("Run command:\n", run_command)
- ret = subprocess_log_output(run_command, build_path, run_log_path)
- assert ret == 0
+
+ subprocess_check_log_output(run_command, build_path, run_log_path)
+
with open(run_log_path) as run_log:
assert AOT_SUCCESS_TOKEN in run_log.read()