Skip to content

Commit

Permalink
Move unit test to dedicated tests folder
Browse files Browse the repository at this point in the history
  • Loading branch information
guberti committed Jul 27, 2021
1 parent 5453d02 commit 6c434b9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions apps/microtvm/arduino/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _create_graph_json(self, model_dir, obj):
def _disassemble_mlf(self, mlf_tar_path, source_dir):
with tempfile.TemporaryDirectory() as mlf_unpacking_dir:
with tarfile.open(mlf_tar_path, "r:") as tar:
tar.extractall(mlf_unpacking_dir.name)
tar.extractall(mlf_unpacking_dir)

# Copy C files
# TODO are the defaultlib0.c the same?
Expand All @@ -140,11 +140,11 @@ def _disassemble_mlf(self, mlf_tar_path, source_dir):
("codegen/host/src/default_lib0.c", "default_lib0.c"),
("codegen/host/src/default_lib1.c", "default_lib1.c"),
]:
shutil.copy(os.path.join(mlf_unpacking_dir.name, source), model_dir / dest)
shutil.copy(os.path.join(mlf_unpacking_dir, source), model_dir / dest)

# Load graph.json, serialize to c format, and extact parameters
with open(
os.path.join(mlf_unpacking_dir.name, "executor-config/graph/graph.json")
os.path.join(mlf_unpacking_dir, "executor-config/graph/graph.json")
) as f:
graph_data = json.load(f)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from unittest import mock
from pathlib import Path
import sys

import pytest

sys.path.append("../")
import microtvm_api_server


Expand Down
6 changes: 3 additions & 3 deletions tests/micro/arduino/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def pytest_addoption(parser):
help="Target platform for microTVM tests.",
)
parser.addoption(
"--arduino-cmd",
"--arduino-cli-cmd",
default="arduino-cli",
help="Path to `arduino-cli` command for flashing device.",
)
Expand All @@ -36,8 +36,8 @@ def platform(request):


@pytest.fixture(scope="session")
def arduino_cmd(request):
return request.config.getoption("--arduino-cmd")
def arduino_cli_cmd(request):
return request.config.getoption("--arduino-cli-cmd")


@pytest.fixture(scope="session")
Expand Down
8 changes: 4 additions & 4 deletions tests/micro/arduino/test_arduino_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PLATFORMS = conftest.PLATFORMS


def _generate_project(model, target, arduino_board, arduino_cmd, mod, build_config):
def _generate_project(model, target, arduino_board, arduino_cli_cmd, mod, build_config):
parent_dir = os.path.dirname(__file__)
filename = os.path.splitext(os.path.basename(__file__))[0]
prev_build = (
Expand Down Expand Up @@ -55,7 +55,7 @@ def _generate_project(model, target, arduino_board, arduino_cmd, mod, build_conf
str(template_project_dir),
mod,
workspace.relpath("project"),
{"arduino_board": arduino_board, "arduino_cmd": arduino_cmd, "verbose": 0},
{"arduino_board": arduino_board, "arduino_cli_cmd": arduino_cli_cmd, "verbose": 0},
)
return (workspace, project)

Expand All @@ -65,7 +65,7 @@ def _generate_project(model, target, arduino_board, arduino_cmd, mod, build_conf


@pytest.fixture(scope="module")
def yes_no_project(platform, arduino_cmd):
def yes_no_project(platform, arduino_cli_cmd):
current_dir = os.path.dirname(__file__)
model, arduino_board = PLATFORMS[platform]
# target = tvm.target.target.micro(model, options=["-link-params=1"])
Expand All @@ -78,7 +78,7 @@ def yes_no_project(platform, arduino_cmd):
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
mod = relay.build(mod, TARGET, params=params)

return _generate_project(model, TARGET, arduino_board, arduino_cmd, mod, build_config)
return _generate_project(model, TARGET, arduino_board, arduino_cli_cmd, mod, build_config)
# return tvm.micro.Session(project.transport())


Expand Down

0 comments on commit 6c434b9

Please sign in to comment.