From 141035f276675d5afec530ef7dd7168ced1c2be9 Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <yamanu@xilinx.com>
Date: Thu, 27 Feb 2020 15:06:38 +0000
Subject: [PATCH] [Test] check if PYNQ_IP is empty string as alternative

---
 tests/end2end/test_end2end_tfc.py                 | 7 +++++--
 tests/fpgadataflow/test_fpgadataflow_ip_stitch.py | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/end2end/test_end2end_tfc.py b/tests/end2end/test_end2end_tfc.py
index 002d82e32..63e4f13c9 100644
--- a/tests/end2end/test_end2end_tfc.py
+++ b/tests/end2end/test_end2end_tfc.py
@@ -4,6 +4,7 @@ from pkgutil import get_data
 import pytest
 
 import numpy as np
+
 # as of Feb'20 there is a bug that segfaults ONNX shape inference if we
 # import pytorch before onnx, so we make sure to import onnx first
 import onnx  # NOQA
@@ -171,7 +172,6 @@ def test_end2end_tfc_verify_all():
     golden = ModelWrapper(build_dir + "/end2end_tfc_w1_a1_streamlined.onnx")
     iname = golden.graph.input[0].name
     oname = golden.graph.output[0].name
-    ishape = golden.get_tensor_shape(iname)
     raw_i = get_data("finn", "data/onnx/mnist-conv/test_data_set_0/input_0.pb")
     input_tensor = onnx.load_tensor_from_string(raw_i)
     x = nph.to_array(input_tensor)
@@ -229,6 +229,8 @@ def test_end2end_tfc_deploy_on_pynq():
     model = ModelWrapper(build_dir + "/end2end_tfc_w1_a1_pynq_driver.onnx")
     try:
         ip = os.environ["PYNQ_IP"]  # no fault for this one; skip if not defined
+        if ip == "":
+            pytest.skip("PYNQ board IP address not specified")
         username = os.getenv("PYNQ_USERNAME", "xilinx")
         password = os.getenv("PYNQ_PASSWORD", "xilinx")
         target_dir = os.getenv("PYNQ_TARGET_DIR", "/home/xilinx/finn")
@@ -244,7 +246,6 @@ def test_end2end_tfc_run_on_pynq():
     golden = ModelWrapper(build_dir + "/end2end_tfc_w1_a1_streamlined.onnx")
     iname = golden.graph.input[0].name
     oname = golden.graph.output[0].name
-    ishape = golden.get_tensor_shape(iname)
     raw_i = get_data("finn", "data/onnx/mnist-conv/test_data_set_0/input_0.pb")
     input_tensor = onnx.load_tensor_from_string(raw_i)
     x = nph.to_array(input_tensor)
@@ -259,6 +260,8 @@ def test_end2end_tfc_run_on_pynq():
     oname = parent_model.graph.output[0].name
     try:
         ip = os.environ["PYNQ_IP"]  # NOQA
+        if ip == "":
+            pytest.skip("PYNQ board IP address not specified")
         # produce results with npysim
         sdp_node = getCustomOp(parent_model.graph.node[2])
         sdp_node.set_nodeattr(
diff --git a/tests/fpgadataflow/test_fpgadataflow_ip_stitch.py b/tests/fpgadataflow/test_fpgadataflow_ip_stitch.py
index 56664eb1d..d5ad340a0 100644
--- a/tests/fpgadataflow/test_fpgadataflow_ip_stitch.py
+++ b/tests/fpgadataflow/test_fpgadataflow_ip_stitch.py
@@ -274,6 +274,8 @@ def test_fpgadataflow_ipstitch_pynq_deployment_folder():
     )
     try:
         ip = os.environ["PYNQ_IP"]  # no default for this one; skip if not defined
+        if ip == "":
+            pytest.skip("PYNQ board IP address not specified")
         username = os.getenv("PYNQ_USERNAME", "xilinx")
         password = os.getenv("PYNQ_PASSWORD", "xilinx")
         target_dir = os.getenv("PYNQ_TARGET_DIR", "/home/xilinx/finn")
@@ -305,6 +307,8 @@ def test_fpgadataflow_ipstitch_remote_execution():
     )
     try:
         ip = os.environ["PYNQ_IP"]  # NOQA
+        if ip == "":
+            pytest.skip("PYNQ board IP address not specified")
         idt = DataType.INT2
         x = gen_finn_dt_tensor(idt, (1, 4))
         input_dict = {"inp": x}
-- 
GitLab