[MERGED] openbsc[master]: python tests: allow running from separate build dir

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Mar 20 13:33:15 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: python tests: allow running from separate build dir
......................................................................


python tests: allow running from separate build dir

The VTY tests assume that $top_builddir == $top_srcdir. Use the script's
location from sys.path[0] to find the correct locations of example configs even
when building in another directory.

Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2
---
M openbsc/tests/ctrl_test_runner.py
M openbsc/tests/smpp_test_runner.py
M openbsc/tests/vty_test_runner.py
3 files changed, 9 insertions(+), 4 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index 5030e8b..02bc28a 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -30,7 +30,8 @@
 import osmopy.obscvty as obscvty
 import osmopy.osmoutil as osmoutil
 
-confpath = '.'
+# to be able to find $top_srcdir/doc/...
+confpath = os.path.join(sys.path[0], '..')
 verbose = False
 
 class TestCtrlBase(unittest.TestCase):
diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py
index 06fb766..2fd144b 100644
--- a/openbsc/tests/smpp_test_runner.py
+++ b/openbsc/tests/smpp_test_runner.py
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
+import sys
 import time
 import unittest
 import socket
@@ -25,7 +26,7 @@
 import osmopy.obscvty as obscvty
 import osmopy.osmoutil as osmoutil
 
-confpath = '.'
+confpath = os.path.join(sys.path[0], '..')
 
 class TestVTYBase(unittest.TestCase):
 
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 87b9eba..305c956 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -24,10 +24,13 @@
 import osmopy.obscvty as obscvty
 import osmopy.osmoutil as osmoutil
 
-sys.path.append("../contrib")
+# add $top_srcdir/contrib to find ipa.py
+sys.path.append(os.path.join(sys.path[0], '..', 'contrib'))
+
 from ipa import IPA
 
-confpath = '.'
+# to be able to find $top_srcdir/doc/...
+confpath = os.path.join(sys.path[0], '..')
 
 class TestVTYBase(unittest.TestCase):
 

-- 
To view, visit https://gerrit.osmocom.org/1906
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2
Gerrit-PatchSet: 8
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list