[Replicant] [libsamsung-ipc] [PATCH 4/6] tests: nv_data-imei: fix test with out of tree builds

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Tue Jan 25 16:51:46 UTC 2022


When running the tests in an out of tree build directory (here in
scripts/src/), without that fix, we have the following error in
src/samsung-ipc/tests/test-suite.log when running 'make check':
    FAIL: nv_data-imei
    ==================

    Traceback (most recent call last):
      File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 122, in <module>
        rc = main()
      File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 117, in main
        nv_data_imei = NvDataImei()
      File "[...]/scripts/src/tools/../../../tools/nv_data-imei.py", line 53, in __init__
        self.nv_data_imei = sh.Command(srcdir + os.sep + 'nv_data-imei')
      File "/usr/lib/python3.9/site-packages/sh.py", line 1342, in __init__
        raise CommandNotFound(path)
    sh.CommandNotFound: ../../../tools/nv_data-imei
    FAIL nv_data-imei.py (exit status: 1)

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 tools/nv_data-imei.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/nv_data-imei.py b/tools/nv_data-imei.py
index dbe9cfb..c3e9351 100755
--- a/tools/nv_data-imei.py
+++ b/tools/nv_data-imei.py
@@ -46,11 +46,18 @@ def get_output(data):
 class NvDataImei(object):
     def __init__(self):
         srcdir = os.environ.get('srcdir', None)
-        # Enable also to test without automake
-        if not srcdir:
-            srcdir = os.path.dirname(sys.argv[0])
 
-        self.nv_data_imei = sh.Command(srcdir + os.sep + 'nv_data-imei')
+        command_path = ''
+        if srcdir:
+            command_path = '.' + os.sep + 'nv_data-imei'
+        # Enable to run tests without automake
+        else:
+            command_path = os.path.dirname(sys.argv[0]) \
+                + os.sep \
+                + 'nv_data-imei'
+
+        self.nv_data_imei = sh.Command(command_path)
+
     def test_help(self):
         try:
             self.nv_data_imei('')
-- 
2.34.1



More information about the Replicant mailing list