]> granicus.if.org Git - esp-idf/commitdiff
unit_test.py: Allow importing tiny-test-fw from IDF_PATH as well as TEST_FW_PATH
authorAngus Gratton <angus@espressif.com>
Wed, 5 Dec 2018 00:13:46 +0000 (11:13 +1100)
committerAngus Gratton <gus@projectgus.com>
Tue, 18 Dec 2018 03:09:05 +0000 (14:09 +1100)
tools/unit-test-app/unit_test.py

index eb3005641e0899a1acadfe2b80fb0bac7ab4e71f..4650a974211678b5aa28bff587adb86de953b8c6 100755 (executable)
@@ -25,13 +25,22 @@ import time
 import argparse
 import threading
 
-# if we want to run test case outside `tiny-test-fw` folder,
-# we need to insert tiny-test-fw path into sys path
-test_fw_path = os.getenv("TEST_FW_PATH")
-if test_fw_path and test_fw_path not in sys.path:
-    sys.path.insert(0, test_fw_path)
+try:
+        import TinyFW
+except ImportError:
+    # if we want to run test case outside `tiny-test-fw` folder,
+    # we need to insert tiny-test-fw path into sys path
+    test_fw_path = os.getenv("TEST_FW_PATH")
+    if test_fw_path and test_fw_path not in sys.path:
+        sys.path.insert(0, test_fw_path)
+    else:
+        # or try the copy in IDF
+        idf_path = os.getenv("IDF_PATH")
+        tiny_test_path = idf_path + "/tools/tiny-test-fw"
+        if os.path.exists(tiny_test_path):
+            sys.path.insert(0, tiny_test_path)
+    import TinyFW
 
-import TinyFW
 import IDF
 import Utility
 import Env