diff --git a/src/test/README b/src/test/README index 3e07aa5c0443899f1c6963c6e75c2370dc5fec01..abd6a22d6ba8e1509bd631480d16ff1b90b683dc 100644 --- a/src/test/README +++ b/src/test/README @@ -124,12 +124,6 @@ unit test framework also looks for several other variables: TRACE is not supported for tests which are executed on remote nodes. - Override the LD_LIBRARY_PATH provided by the unit test framework. This - is useful for running a test against another source tree or against the - libraries installed on the system: - - $ TEST_LD_LIBRARY_PATH=/usr/lib ./TEST0 - Run test under Valgrind/memcheck: $ MEMCHECK=force-enable ./TEST0 diff --git a/src/test/RUNTESTS b/src/test/RUNTESTS index fbfc2df4ee88f8739484e5e5b5e30d14cb032449..e4704fd092721cde1089b25fb3a849658df4ee28 100755 --- a/src/test/RUNTESTS +++ b/src/test/RUNTESTS @@ -469,11 +469,13 @@ verbose_tests= [ -n "$KEEP_GOING" ] && keep_going=$KEEP_GOING [ -n "$VERBOSE_TESTS" ] && verbose_tests="$VERBOSE_TESTS" - PMEMDETECT="tools/pmemdetect/pmemdetect.static-nondebug" +pmemdetect() { + LD_LIBRARY_PATH=$LIBNDCTL_LD_LIBRARY_PATHS:$LD_LIBRARY_PATH $PMEMDETECT "$@" +} if [ "$PMEM_FS_DIR_FORCE_PMEM" = "1" ]; then - if $PMEMDETECT -s $PMEM_FS_DIR; then + if pmemdetect -s $PMEM_FS_DIR; then echo "error: PMEM_FS_DIR_FORCE_PMEM variable is set but PMEM_FS_DIR [" $PMEM_FS_DIR "] supports MAP_SYNC" echo "Setting this flag prevents from testing an integration between pmem_map_file and pmem_is_pmem." echo "If you want to ignore this error, please set PMEM_FS_DIR_FORCE_PMEM=2." @@ -495,7 +497,7 @@ if [ -d "$PMEM_FS_DIR" ]; then if [ "$PMEM_FS_DIR_FORCE_PMEM" = "1" ] || [ "$PMEM_FS_DIR_FORCE_PMEM" = "2" ]; then PMEM_IS_PMEM=0 else - $PMEMDETECT "$PMEM_FS_DIR" + pmemdetect "$PMEM_FS_DIR" PMEM_IS_PMEM=$? fi @@ -506,7 +508,7 @@ if [ -d "$PMEM_FS_DIR" ]; then fi if [ -d "$NON_PMEM_FS_DIR" ]; then - $PMEMDETECT "$NON_PMEM_FS_DIR" + pmemdetect "$NON_PMEM_FS_DIR" NON_PMEM_IS_PMEM=$? if [ $NON_PMEM_IS_PMEM -eq 0 ]; then echo "error: NON_PMEM_FS_DIR=$NON_PMEM_FS_DIR does not point to a non-PMEM device" diff --git a/src/test/obj_memcheck/TEST0 b/src/test/obj_memcheck/TEST0 index ee23f97abf7c2dd41fb32ba782b8b320def809e8..ab7df3d4c8fe93d3f7c012114e20aa98bd50f6d3 100755 --- a/src/test/obj_memcheck/TEST0 +++ b/src/test/obj_memcheck/TEST0 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2015-2018, Intel Corporation +# Copyright 2015-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -57,7 +57,7 @@ export PMEMOBJ_VG_CHECK_UNDEF=1 export VALIDATE_VALGRIND_LOG=0 export VALGRIND_OPTS="$VALGRIND_OPTS --show-reachable=yes" -if ! eval LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH LD_PRELOAD=$TEST_LD_PRELOAD $TRACE valgrind ./obj_memcheck$EXESUFFIX m 2>/dev/null; then +if ! eval LD_PRELOAD=$TEST_LD_PRELOAD $TRACE valgrind ./obj_memcheck$EXESUFFIX m 2>/dev/null; then echo "$UNITTEST_NAME: SKIP valgrind with bug" exit 0 fi diff --git a/src/test/unittest/unittest.sh b/src/test/unittest/unittest.sh index 6775be185b8d46205038d2c1784bfad75988732b..65e9723dee7d4a3be218f203a47f495f10fc87cb 100644 --- a/src/test/unittest/unittest.sh +++ b/src/test/unittest/unittest.sh @@ -156,41 +156,30 @@ fi # array of lists of PID files to be cleaned in case of an error NODE_PID_FILES[0]="" -# -# The variable TEST_LD_LIBRARY_PATH is constructed so the test pulls in -# the appropriate library from this source tree. To override this behavior -# (i.e. to force the test to use the libraries installed elsewhere on -# the system), set TEST_LD_LIBRARY_PATH and this script will not override it. -# -# For example, in a test directory, run: -# TEST_LD_LIBRARY_PATH=/usr/lib ./TEST0 -# -[ "$TEST_LD_LIBRARY_PATH" ] || { - case "$BUILD" - in - debug|static-debug) - if [ -z "$PMDK_LIB_PATH_DEBUG" ]; then - PMDK_LIB_PATH=../../debug - REMOTE_PMDK_LIB_PATH=../debug - else - PMDK_LIB_PATH=$PMDK_LIB_PATH_DEBUG - REMOTE_PMDK_LIB_PATH=$PMDK_LIB_PATH_DEBUG - fi - ;; - nondebug|static-nondebug) - if [ -z "$PMDK_LIB_PATH_NONDEBUG" ]; then - PMDK_LIB_PATH=../../nondebug - REMOTE_PMDK_LIB_PATH=../nondebug - else - PMDK_LIB_PATH=$PMDK_LIB_PATH_NONDEBUG - REMOTE_PMDK_LIB_PATH=$PMDK_LIB_PATH_NONDEBUG - fi - ;; - esac +case "$BUILD" +in +debug|static-debug) + if [ -z "$PMDK_LIB_PATH_DEBUG" ]; then + PMDK_LIB_PATH=../../debug + REMOTE_PMDK_LIB_PATH=../debug + else + PMDK_LIB_PATH=$PMDK_LIB_PATH_DEBUG + REMOTE_PMDK_LIB_PATH=$PMDK_LIB_PATH_DEBUG + fi + ;; +nondebug|static-nondebug) + if [ -z "$PMDK_LIB_PATH_NONDEBUG" ]; then + PMDK_LIB_PATH=../../nondebug + REMOTE_PMDK_LIB_PATH=../nondebug + else + PMDK_LIB_PATH=$PMDK_LIB_PATH_NONDEBUG + REMOTE_PMDK_LIB_PATH=$PMDK_LIB_PATH_NONDEBUG + fi + ;; +esac - TEST_LD_LIBRARY_PATH=$PMDK_LIB_PATH:$LD_LIBRARY_PATH - REMOTE_LD_LIBRARY_PATH=$REMOTE_PMDK_LIB_PATH:\$LD_LIBRARY_PATH -} +export LD_LIBRARY_PATH=$PMDK_LIB_PATH:$LIBNDCTL_LD_LIBRARY_PATHS:$LD_LIBRARY_PATH +export REMOTE_LD_LIBRARY_PATH=$REMOTE_PMDK_LIB_PATH:$LIBNDCTL_LD_LIBRARY_PATHS:\$LD_LIBRARY_PATH # # When running static binary tests, append the build type to the binary @@ -832,8 +821,7 @@ function expect_normal_exit() { disable_exit_on_error - eval $ECHO LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH LD_PRELOAD=$TEST_LD_PRELOAD \ - $trace "$*" + eval $ECHO LD_PRELOAD=$TEST_LD_PRELOAD $trace "$*" ret=$? if [ $REMOTE_VALGRIND_LOG -eq 1 ]; then @@ -926,7 +914,7 @@ function expect_abnormal_exit() { disable_exit_on_error eval $ECHO ASAN_OPTIONS="detect_leaks=0 ${ASAN_OPTIONS}" \ - LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH LD_PRELOAD=$TEST_LD_PRELOAD $TRACE "$*" + LD_PRELOAD=$TEST_LD_PRELOAD $TRACE "$*" ret=$? restore_exit_on_error @@ -990,7 +978,7 @@ function require_unlimited_vm() { function require_linked_with_ndctl() { [ "$1" == "" -o ! -x "$1" ] && \ fatal "$UNITTEST_NAME: ERROR: require_linked_with_ndctl() requires one argument - an executable file" - local lddndctl=$(LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH ldd $1 | $GREP -ce "libndctl") + local lddndctl=$(ldd $1 | $GREP -ce "libndctl") [ "$lddndctl" == "1" ] && return msg "$UNITTEST_NAME: SKIP required: executable $1 linked with libndctl" exit 0 @@ -1934,7 +1922,7 @@ function require_preload() { shift trap SIGABRT disable_exit_on_error - ret=$(LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH LD_PRELOAD=$TEST_LD_PRELOAD $* 2>&1 /dev/null) + ret=$(LD_PRELOAD=$TEST_LD_PRELOAD $* 2>&1 /dev/null) ret=$? restore_exit_on_error if [ $ret == 134 ]; then @@ -3431,7 +3419,7 @@ function pmreorder_run_tool() { rm -f pmreorder$UNITTEST_NUM.log disable_exit_on_error - LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH $PYTHON_EXE $PMREORDER \ + $PYTHON_EXE $PMREORDER \ -l store_log$UNITTEST_NUM.log \ -o pmreorder$UNITTEST_NUM.log \ -r $1 \ @@ -3496,7 +3484,7 @@ function pmreorder_create_store_log() cp $1 "$1.pmr" rm -f store_log$UNITTEST_NUM.log - LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH $VALGRINDEXE \ + $VALGRINDEXE \ --tool=pmemcheck -q \ --log-stores=yes \ --print-summary=no \ diff --git a/src/test/util_badblock/TEST10 b/src/test/util_badblock/TEST10 index b3b736a89be9712d03af78778dadf62ef09cd02b..fe7505ddf6e1cff79d59839a1822969508184251 100755 --- a/src/test/util_badblock/TEST10 +++ b/src/test/util_badblock/TEST10 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2018, Intel Corporation +# Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -57,7 +57,7 @@ setup $FALLOCATE 100M $DIR/testfile1 ENV="\ -LD_LIBRARY_PATH=${TEST_LD_LIBRARY_PATH} \ +LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \ UNITTEST_NUM=${UNITTEST_NUM} \ UNITTEST_NAME=${UNITTEST_NAME} \ UNITTEST_LOG_LEVEL=${UNITTEST_LOG_LEVEL}"