[PATCH] osmo-bsc[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 Nov 24 11:05:01 UTC 2017


Review at  https://gerrit.osmocom.org/5022

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.

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.

Change-Id: Id22e157d1bee453babdfa7ed04c506390b0f17bb
---
M configure.ac
M tests/Makefile.am
M tests/ctrl_test_runner.py
M tests/vty_test_runner.py
4 files changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/22/5022/1

diff --git a/configure.ac b/configure.ac
index a66ed26..b7dd016 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,7 +124,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/tests/Makefile.am b/tests/Makefile.am
index 474f821..7b4656b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,8 +47,8 @@
 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
 	rm -f $(top_builddir)/sms.db $(top_builddir)/gsn_restart $(top_builddir)/gtphub_restart_count
 else
 python-tests: $(BUILT_SOURCES)
diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index 2e59e13..ccc6758 100644
--- a/tests/ctrl_test_runner.py
+++ b/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
diff --git a/tests/vty_test_runner.py b/tests/vty_test_runner.py
old mode 100644
new mode 100755
index 3ecfd39..8aa3dda
--- a/tests/vty_test_runner.py
+++ b/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/5022
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id22e157d1bee453babdfa7ed04c506390b0f17bb
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list