Change in openbsc[master]: tests: Fix selection of python version

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Fri May 3 18:25:11 UTC 2019


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/13868 )

Change subject: tests: Fix selection of python version
......................................................................

tests: Fix selection of python version

According to documentation (and personal experience), AM_PATH_PYTHON
selects the highest version of python, no matter if major version is
different, which means if both python2 and 3 are available, 3 will be
chosen an PYTHON will point to "/.../python" which is python3. Apparently,
the macro cannot be easily used to pick highest python2 version.

chosen an PYTHON will point to "/.../python" which is python3. Apparently,
the macro cannot be easily used to pick highest python2 version.

As {vty,ctrl}_test_runner.py require python2 and are incompatible with
python3, let's instead rely on the system having a "python2" binary
available, which is the case in most distros.

cherry-picked from: osmo-bsc.git 7e78681f0f740bd68ed5255b506a1efa08a231b1.

Change-Id: Icc147c8457116ad551d166313f3a79e1c2107a22
---
M openbsc/configure.ac
M openbsc/tests/Makefile.am
M openbsc/tests/ctrl_test_runner.py
M openbsc/tests/smpp_test_runner.py
M openbsc/tests/vty_test_runner.py
5 files changed, 12 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index 704c7d7..5602313 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -198,7 +198,10 @@
 				[Include the VTY/CTRL tests in make check [default=no]]),
 		[enable_ext_tests="$enableval"],[enable_ext_tests="no"])
 if test "x$enable_ext_tests" = "xyes" ; then
-	AM_PATH_PYTHON
+	AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes)
+	if test "x$PYTHON2_AVAIL" != "xyes" ; then
+		AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.])
+	fi
 	AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
 	 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
 		AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am
index 7208a2f..a62451e 100644
--- a/openbsc/tests/Makefile.am
+++ b/openbsc/tests/Makefile.am
@@ -64,10 +64,10 @@
 python-tests: $(BUILT_SOURCES)
 	osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
 	osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
-	$(PYTHON) $(srcdir)/vty_test_runner.py -w $(abs_top_builddir) -v
-	$(PYTHON) $(srcdir)/ctrl_test_runner.py -w $(abs_top_builddir) -v
+	$(srcdir)/vty_test_runner.py -w $(abs_top_builddir) -v
+	$(srcdir)/ctrl_test_runner.py -w $(abs_top_builddir) -v
 if BUILD_SMPP
-	$(PYTHON) $(srcdir)/smpp_test_runner.py -w $(abs_top_builddir) -v
+	$(srcdir)/smpp_test_runner.py -w $(abs_top_builddir) -v
 endif
 	rm -f $(top_builddir)/hlr.sqlite3
 else
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
old mode 100644
new mode 100755
index d76ed65..ad0a16b
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 # (C) 2013 by Jacob Erlbeck <jerlbeck at sysmocom.de>
 # (C) 2014 by Holger Hans Peter Freyther
@@ -262,12 +262,12 @@
         self.assertEquals(r['mtype'], 'SET_REPLY')
         self.assertEquals(r['var'], 'bts.0.trx.0.max-power-reduction')
         self.assertEquals(r['value'], '22')
-        
+
         r = self.do_get('bts.0.trx.0.max-power-reduction')
         self.assertEquals(r['mtype'], 'GET_REPLY')
         self.assertEquals(r['var'], 'bts.0.trx.0.max-power-reduction')
         self.assertEquals(r['value'], '22')
-        
+
         r = self.do_set('bts.0.trx.0.max-power-reduction', '1')
         self.assertEquals(r['mtype'], 'ERROR')
         self.assertEquals(r['error'], 'Value must be even')
diff --git a/openbsc/tests/smpp_test_runner.py b/openbsc/tests/smpp_test_runner.py
old mode 100644
new mode 100755
index 58645aa..eccfa6b
--- a/openbsc/tests/smpp_test_runner.py
+++ b/openbsc/tests/smpp_test_runner.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 # (C) 2014 by Holger Hans Peter Freyther
 # based on vty_test_runner.py:
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
old mode 100644
new mode 100755
index 44ccdd8..67adb71
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 # (C) 2013 by Katerina Barone-Adesi <kat.obsc at gmail.com>
 # (C) 2013 by Holger Hans Peter Freyther

-- 
To view, visit https://gerrit.osmocom.org/13868
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Icc147c8457116ad551d166313f3a79e1c2107a22
Gerrit-Change-Number: 13868
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190503/94ffdddc/attachment.htm>


More information about the gerrit-log mailing list