Skip to content

Commit

Permalink
[microTVM][Zephyr] Fix: Test fails on hardware because of short timeo…
Browse files Browse the repository at this point in the history
…ut (apache#8677)

* add timeout

* rename timeout and change timeout to a reasonable value

* fix tests after project api merge

* retrigger because of flaktest
  • Loading branch information
mehrdadh authored and ylc committed Sep 29, 2021
1 parent d0b9c50 commit 1e5982b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/microtvm/zephyr/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def server_info_query(self, tvm_version):
"qemu_cortex_r5",
"qemu_riscv64",
),
"CONFIG_ENTROPY_GENERATOR_BOARDS=y": (
"CONFIG_ENTROPY_GENERATOR=y": (
"mps2_an521",
"nrf5340dk_nrf5340_cpuapp",
"nucleo_f746zg",
Expand Down Expand Up @@ -313,7 +313,7 @@ def _create_prj_conf(self, project_dir, options):

f.write("# For random number generation.\n" "CONFIG_TEST_RANDOM_GENERATOR=y\n")

f.write("\n# Extra prj.conf directives")
f.write("\n# Extra prj.conf directives\n")
for line, board_list in self.EXTRA_PRJ_CONF_DIRECTIVES.items():
if options["zephyr_board"] in board_list:
f.write(f"{line}\n")
Expand Down
16 changes: 7 additions & 9 deletions tests/micro/zephyr/test_zephyr_aot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# specific language governing permissions and limitations
# under the License.

import datetime
from hashlib import new
import io
import logging
import os
Expand Down Expand Up @@ -113,13 +111,13 @@ def _create_header_file(tensor_name, npy_data, output_path, tar_file):
tar_file.addfile(ti, io.BytesIO(header_file_bytes))


def _read_line(fd):
def _read_line(fd, timeout_sec: int):
data = ""
new_line = False
while True:
if new_line:
break
new_data = fd.read(1, timeout_sec=10)
new_data = fd.read(1, timeout_sec=timeout_sec)
logging.debug(f"read data: {new_data}")
for item in new_data:
new_c = chr(item)
Expand All @@ -130,9 +128,9 @@ def _read_line(fd):
return data


def _get_message(fd, expr: str):
def _get_message(fd, expr: str, timeout_sec: int):
while True:
data = _read_line(fd)
data = _read_line(fd, timeout_sec)
logging.debug(f"new line: {data}")
if expr in data:
return data
Expand Down Expand Up @@ -213,10 +211,10 @@ def test_tflite(temp_dir, platform, west_cmd, skip_build, tvm_debug):

project.flash()
with project.transport() as transport:
_get_message(transport, "#wakeup")
timeout_read = 60
_get_message(transport, "#wakeup", timeout_sec=timeout_read)
transport.write(b"start\n", timeout_sec=5)

result_line = _get_message(transport, "#result")
result_line = _get_message(transport, "#result", timeout_sec=timeout_read)

result_line = result_line.strip("\n")
result_line = result_line.split(":")
Expand Down

0 comments on commit 1e5982b

Please sign in to comment.