summaryrefslogtreecommitdiffstats
path: root/tests/features
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2015-03-19 12:05:16 +0100
committerVijay Bellur <vbellur@redhat.com>2015-03-30 23:45:10 -0700
commitffb2e85ff574891639d899cc59fcd9f75d4ce51e (patch)
treef261ca1e87f9f96671a91c5eb3781cccb929e333 /tests/features
parentd3eacb0d83834db485061d875d95b4f6af41f30a (diff)
Tests: portability fixes for ipc.t
This fixes portability problems in ipc.t so that it can run on NetBSD: 1) EOPNOTSUPP value is OS-dependent. Learn it from system headers instead of hard-coding it in the script 2) liglusterfs embbeds its own UUID implementation. The function name may be the same as in built(in implementation from libc, but with different prototype. In that case, we must make sure python will use libglusterfs's version, otherwise we will crash in libc's UUID code. Since dlopen() does not make any guarantee on what symbol will be used, me need to preload libglusterfs when loading python. This is done using LD_PRELOAD. 3) In python code we need to load with RTLD_GLOBAL global in order to have dependencies loaded 4) Python's ctypes.util.find_library does not lookup LD_LIBRARy_PATH and may therefore miss the library. On failure, retry with less portable but more reliable explicit name BUG: 1129939 Change-Id: I024cdfd03a5a42a8ec23de38a99e7349aba92ea8 Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Reviewed-on: http://review.gluster.org/9944 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests/features')
-rwxr-xr-xtests/features/ipc.t18
-rwxr-xr-xtests/features/ipctest.py8
2 files changed, 23 insertions, 3 deletions
diff --git a/tests/features/ipc.t b/tests/features/ipc.t
index 2aaca6620bf..55ce8c871c1 100755
--- a/tests/features/ipc.t
+++ b/tests/features/ipc.t
@@ -13,9 +13,23 @@ TEST $CLI volume info;
TEST $CLI volume create $V0 $H0:$B0/1
TEST $CLI volume start $V0
+# Find OS-dependent EOPNOTSUPP value from system headers
+EOPNOTSUPP=$( echo '#include <errno.h>\\EOPNOTSUPP\\' | tr '\\' '\n' | \
+ cc -E -c - | tail -1 )
+
+# liglusterfs embbeds its own UUID implementation. The function name
+# may be the same as in built(in implementation from libc, but with
+# different prototype. In that case, we must make sure python will
+# use libglusterfs's version, and dlopen() does not make any guarantee
+# on this. By preloading libglusterfs.so before launching python, we
+# ensure libglusterfs's UUID functions will be used.
+LD_PRELOAD=${prefix}/lib/libglusterfs.so
+export LD_PRELOAD
+
# This is a pretty lame test. Basically we just want to make sure that we
# get all the way through the translator stacks on client and server to get a
-# simple error (95 = EOPNOTUPP) instead of a crash, RPC error, etc.
-EXPECT 95 $PYTHON $(dirname $0)/ipctest.py $H0 $V0
+# simple error (EOPNOTSUPP) instead of a crash, RPC error, etc.
+EXPECT ${EOPNOTSUPP} $PYTHON $(dirname $0)/ipctest.py $H0 $V0
+unset LD_PRELOAD
cleanup;
diff --git a/tests/features/ipctest.py b/tests/features/ipctest.py
index 0592bae3bbc..857225fe0a5 100755
--- a/tests/features/ipctest.py
+++ b/tests/features/ipctest.py
@@ -3,7 +3,13 @@
import ctypes
import ctypes.util
-api = ctypes.CDLL(ctypes.util.find_library("gfapi"))
+# find_library does not lookup LD_LIBRARY_PATH and may miss the
+# function. In that case, retry with less portable but explicit name.
+libgfapi = ctypes.util.find_library("gfapi")
+if libgfapi == None:
+ libgfapi = "libgfapi.so"
+api = ctypes.CDLL(libgfapi,mode=ctypes.RTLD_GLOBAL)
+
api.glfs_ipc.argtypes = [ ctypes.c_void_p, ctypes.c_int ]
api.glfs_ipc.restype = ctypes.c_int