summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2015-02-10 17:22:03 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-02-25 08:38:40 +0100
commit4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f (patch)
tree3a9381a56ce6a7e2635b354208d202a1dcca9975 /src/tests
parent4706958e7505ce279f06cb2bf413eb38ee8f114c (diff)
downloadsssd-4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f.tar.gz
sssd-4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f.tar.xz
sssd-4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f.zip
BUILD: Add possibility to build python{2,3} bindings
Resolves: https://fedorahosted.org/sssd/ticket/2574 Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
Diffstat (limited to 'src/tests')
-rwxr-xr-xsrc/tests/pyhbac-test.py22
-rwxr-xr-xsrc/tests/pysss_murmur-test.py22
2 files changed, 38 insertions, 6 deletions
diff --git a/src/tests/pyhbac-test.py b/src/tests/pyhbac-test.py
index 0abc5703d..83958d7bf 100755
--- a/src/tests/pyhbac-test.py
+++ b/src/tests/pyhbac-test.py
@@ -6,10 +6,9 @@ import sys
import os
import copy
import sys
+import errno
-srcdir = os.getenv('builddir')
-if not srcdir:
- srcdir = "."
+srcdir = os.getenv('builddir') or "."
MODPATH = srcdir + "/.libs" #FIXME - is there a way to get this from libtool?
if sys.version_info[0] > 2:
@@ -41,6 +40,23 @@ class PyHbacImport(unittest.TestCase):
def testImport(self):
" Import the module and assert it comes from tree "
try:
+ cwd_backup = os.getcwd()
+
+ try:
+ os.unlink(MODPATH + "/pyhbac.so")
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise e
+
+ os.chdir(MODPATH)
+ if sys.version_info[0] > 2:
+ os.symlink("_py3hbac.so", "pyhbac.so")
+ else:
+ os.symlink("_py2hbac.so", "pyhbac.so")
+ os.chdir(cwd_backup)
+
import pyhbac
except ImportError as e:
print("Could not load the pyhbac module. Please check if it is compiled", file=sys.stderr)
diff --git a/src/tests/pysss_murmur-test.py b/src/tests/pysss_murmur-test.py
index 0b28f45e6..faa8bb2d3 100755
--- a/src/tests/pysss_murmur-test.py
+++ b/src/tests/pysss_murmur-test.py
@@ -23,10 +23,9 @@ import unittest
import sys
import os
import copy
+import errno
-srcdir = os.getenv('builddir')
-if not srcdir:
- srcdir = "."
+srcdir = os.getenv('builddir') or "."
MODPATH = srcdir + "/.libs" #FIXME - is there a way to get this from libtool?
def compat_assertItemsEqual(this, expected_seq, actual_seq, msg=None):
@@ -57,6 +56,23 @@ class PySssMurmurImport(unittest.TestCase):
def testImport(self):
" Import the module and assert it comes from tree "
try:
+ cwd_backup = os.getcwd()
+
+ try:
+ os.unlink(MODPATH + "/pysss_murmur.so")
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise e
+
+ os.chdir(MODPATH)
+ if sys.version_info[0] > 2:
+ os.symlink("_py3sss_murmur.so", "pysss_murmur.so")
+ else:
+ os.symlink("_py2sss_murmur.so", "pysss_murmur.so")
+ os.chdir(cwd_backup)
+
import pysss_murmur
except ImportError as e:
print("Could not load the pysss_murmur module. Please check if it is compiled", file=sys.stderr)