areusch commented on a change in pull request #8236:
URL: https://github.com/apache/tvm/pull/8236#discussion_r649585624
##########
File path: tests/micro/zephyr/test_zephyr_aot.py
##########
@@ -211,5 +213,50 @@ def test_tflite(platform, west_cmd, skip_build, tvm_debug):
assert result == 8
+def test_qemu_make_fail(platform, west_cmd, skip_build, tvm_debug):
+ """Testing QEMU make fail."""
+ model, zephyr_board = PLATFORMS[platform]
+ build_config = {"skip_build": skip_build, "debug": tvm_debug}
+ shape = (10,)
+ dtype = "float32"
+
+ this_dir = os.path.dirname(__file__)
Review comment:
nit: i've been liking pathlib for doing this stuff, like:
```
import pathlib
this_dir = pathlib.Path(__file__).parent
tvm_source_dir = this_dir / ".." / ".." / ".."
# ...
```
##########
File path: tests/micro/zephyr/test_zephyr_aot.py
##########
@@ -211,5 +213,50 @@ def test_tflite(platform, west_cmd, skip_build, tvm_debug):
assert result == 8
+def test_qemu_make_fail(platform, west_cmd, skip_build, tvm_debug):
+ """Testing QEMU make fail."""
+ model, zephyr_board = PLATFORMS[platform]
+ build_config = {"skip_build": skip_build, "debug": tvm_debug}
+ shape = (10,)
+ dtype = "float32"
+
+ this_dir = os.path.dirname(__file__)
+ tvm_source_dir = os.path.join(this_dir, "..", "..", "..")
+ runtime_path = os.path.join(tvm_source_dir, "apps", "microtvm", "zephyr",
"aot_demo")
+
+ # Construct Relay program.
+ x = relay.var("x", relay.TensorType(shape=shape, dtype=dtype))
+ xx = relay.multiply(x, x)
+ z = relay.add(xx, relay.const(np.ones(shape=shape, dtype=dtype)))
+ func = relay.Function([x], z)
+
+ target = tvm.target.target.micro(model, options=["-link-params=1",
"--executor=aot"])
+ with tvm.transform.PassContext(opt_level=3,
config={"tir.disable_vectorize": True}):
+ lowered = relay.build(func, target)
+
+ # Generate input/output header files
+ model_files_path = os.path.join(runtime_path, "include")
+ _create_header_file((f"input_data"), np.zeros(shape=shape, dtype=dtype),
model_files_path)
+ _create_header_file("output_data", np.zeros(shape=shape, dtype=dtype),
model_files_path)
+
+ session_kw = _build_session_kw(
+ model, target, zephyr_board, west_cmd, lowered.lib, runtime_path,
build_config
+ )
+
+ file_path = os.path.join(session_kw["binary"].base_dir,
"zephyr/CMakeFiles/run.dir/build.make")
+ assert os.path.isfile(file_path), f"[{file_path}] does not exist."
+
+ # Remove a file to create make failure.
+ os.remove(file_path)
+ transport = session_kw["flasher"].flash(session_kw["binary"])
+ try:
Review comment:
try using
[pytest.raises](https://docs.pytest.org/en/6.2.x/reference.html#pytest.raises)
here for a more maintainable assert
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]