msgpack-c
msgpack-c copied to clipboard
C tests fail for shared library build (missing LD_LIBRARY_PATH definition?)
Hi there,
When building msgpack-c in shared library mode, the C library's test fail:
$ LC_ALL=C make test
Running tests...
/usr/bin/ctest --force-new-ctest-process
Test project /home/akien/Mageia/Checkout/msgpack/BUILD/msgpack-2.1.1/build
Start 1: array_ref
1/30 Test #1: array_ref ........................ Passed 0.00 sec
Start 2: buffer
2/30 Test #2: buffer ........................... Passed 0.00 sec
Start 3: carray
3/30 Test #3: carray ........................... Passed 0.00 sec
Start 4: cases
4/30 Test #4: cases ............................ Passed 0.00 sec
Start 5: convert
5/30 Test #5: convert .......................... Passed 0.00 sec
Start 6: fixint
6/30 Test #6: fixint ........................... Passed 0.00 sec
Start 7: fixint_c
7/30 Test #7: fixint_c ......................... Passed 0.00 sec
Start 8: inc_adaptor_define
8/30 Test #8: inc_adaptor_define ............... Passed 0.00 sec
Start 9: json
9/30 Test #9: json ............................. Passed 0.00 sec
Start 10: limit
10/30 Test #10: limit ............................ Passed 0.00 sec
Start 11: msgpack_basic
11/30 Test #11: msgpack_basic .................... Passed 0.22 sec
Start 12: msgpack_c
12/30 Test #12: msgpack_c ........................***Failed 0.00 sec
Start 13: msgpack_container
13/30 Test #13: msgpack_container ................ Passed 0.44 sec
Start 14: msgpack_stream
14/30 Test #14: msgpack_stream ................... Passed 0.23 sec
Start 15: msgpack_tuple
15/30 Test #15: msgpack_tuple .................... Passed 0.00 sec
Start 16: msgpack_vref
16/30 Test #16: msgpack_vref ..................... Passed 0.00 sec
Start 17: object
17/30 Test #17: object ........................... Passed 0.00 sec
Start 18: object_with_zone
18/30 Test #18: object_with_zone ................. Passed 0.30 sec
Start 19: pack_unpack
19/30 Test #19: pack_unpack ...................... Passed 0.00 sec
Start 20: pack_unpack_c
20/30 Test #20: pack_unpack_c ....................***Failed 0.00 sec
Start 21: raw
21/30 Test #21: raw .............................. Passed 0.00 sec
Start 22: reference
22/30 Test #22: reference ........................ Passed 0.00 sec
Start 23: size_equal_only
23/30 Test #23: size_equal_only .................. Passed 0.00 sec
Start 24: streaming
24/30 Test #24: streaming ........................ Passed 0.00 sec
Start 25: streaming_c
25/30 Test #25: streaming_c ......................***Failed 0.00 sec
Start 26: user_class
26/30 Test #26: user_class ....................... Passed 0.01 sec
Start 27: version
27/30 Test #27: version .......................... Passed 0.00 sec
Start 28: visitor
28/30 Test #28: visitor .......................... Passed 0.00 sec
Start 29: zone
29/30 Test #29: zone ............................. Passed 0.00 sec
Start 30: multi_file
30/30 Test #30: multi_file ....................... Passed 0.00 sec
90% tests passed, 3 tests failed out of 30
Total Test time (real) = 1.25 sec
The following tests FAILED:
12 - msgpack_c (Failed)
20 - pack_unpack_c (Failed)
25 - streaming_c (Failed)
Errors while running CTest
Makefile:130: recipe for target 'test' failed
make: *** [test] Error 8
It seems that those tests don't find the libmsgpackc.so.2.0.0
, which is in ${CMAKE_BINARY_DIR}
(here ./build
).
Running the test binaries manually with LD_LIBRARY_PATH
works fine:
cd build
$ ./test/msgpack_c
./test/msgpack_c: error while loading shared libraries: libmsgpackc.so.2: cannot open shared object file: No such file or directory
$ LD_LIBRARY_PATH=. ./test/msgpack_c
Running main() from gtest_main.cc
[==========] Running 57 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 57 tests from MSGPACKC
[ RUN ] MSGPACKC.simple_buffer_char
[ OK ] MSGPACKC.simple_buffer_char (21 ms)
[...]
[==========] 57 tests from 1 test case ran. (84 ms total)
[ PASSED ] 57 tests.
I've tried to tweak the test/CMakeLists.txt
to get it defined in a way that ctest
would take into account, but no luck so far. (I've tried what is documented here and here to set LD_LIBRARY_PATH
to ${CMAKE_BINARY_DIR}
).
A workaround could be to get those binaries linked against the static library, so that there is no library path issue when running tests.
@akien-mga , thank you for reporting the issue. Unfortunately, the problem isn't reproduced on my environment.
Could you tell me your cmake options?
Sure, here are the options from Mageia's %cmake
macro for packaging:
$ rpm --eval %cmake
CFLAGS="${CFLAGS:--O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4}" ; export CFLAGS ;
CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4}" ; export CXXFLAGS ;
FFLAGS="${FFLAGS:--O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4}" ; export FFLAGS ;
LDFLAGS="${LDFLAGS:- -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags}" ; export LDFLAGS
mkdir -p build
cd build
/usr/bin/cmake .. \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DCMAKE_INSTALL_LIBDIR:PATH=/usr/lib64 \
-DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/libexec \
-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc \
-DINCLUDE_INSTALL_DIR:PATH=/usr/include \
-DLIB_INSTALL_DIR:PATH=/usr/lib64 \
-DSYSCONF_INSTALL_DIR:PATH=/etc \
-DSHARE_INSTALL_PREFIX:PATH=/usr/share \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-DNDEBUG" \
-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="-DNDEBUG" \
%if "lib64" == "lib64"
-DLIB_SUFFIX=64 \
%endif
-DCMAKE_SKIP_RPATH:BOOL=ON \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed -Wl,-z,relro -Wl,-O1 -Wl,--build-id -Wl,--enable-new-dtags" \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DBUILD_STATIC_LIBS:BOOL=OFF
I'm not sure but #710 and #717 might solve the issue.