commit 813acf3f52af00fa0ccf73bd49ac9e019612db8d
Author: François Trahay <francois.trahay@telecom-sudparis.eu>
Date:   Wed Aug 24 14:36:07 2022 +0200

    fix eztrace paths in test mode

commit 4ffaf3c51abf72a3d7bb959ac72de3bfd4ddd9f1
Author: François Trahay <francois.trahay@telecom-sudparis.eu>
Date:   Wed Aug 24 14:23:25 2022 +0200

    when running tests with make test, we need to pass -p to eztrace so that it uses the libraries located in the build directory instead of the one in the install directory

---
 src/eztrace.c.in                  |   17 ++++++++++++-----
 test/memory/test_memory.sh        |    2 +-
 test/mpi/test_mpi_ping.sh         |    2 +-
 test/ompt/test_lock.sh            |    2 +-
 test/ompt/test_parallel_for.sh    |    2 +-
 test/ompt/test_task.sh            |    2 +-
 test/openmp/test_lock.sh          |    2 +-
 test/openmp/test_nest_lock.sh     |    2 +-
 test/openmp/test_openmp_simple.sh |    2 +-
 test/openmp/test_task.sh          |    2 +-
 test/posixio/test_my_cat.sh       |    2 +-
 test/posixio/test_posixio.sh      |    2 +-
 test/pthread/test_dummy.sh        |    2 +-
 test/unit_tests/CMakeLists.txt    |    1 +
 14 files changed, 25 insertions(+), 17 deletions(-)

--- a/src/eztrace.c.in
+++ b/src/eztrace.c.in
@@ -210,17 +210,24 @@ int main(int argc, char **argv) {
     }
   }
 
-  // libeztrace should always be preloaded!
+  // libeztrace-core and libeztrace-lib should always be preloaded!
   char *files = NULL;
   if (test) {
+    /* If test is enable, it means that eztrace is invoked by "make
+     *  test", and we should use the libraries located in the build
+     *  directory instead of the one in the installed directory.
+    */
+
     fprintf(stderr, "Eztrace test Mode\n");
-    files = strdup(EZTRACE_ABS_TOP_BUILDDIR);
-    files = add_to_str(files, "src/core/.libs/libeztrace.@DYNLIB_EXT@");
+    files = strdup("@CMAKE_BINARY_DIR@");
+    files = add_to_str(files, "/src/core/libeztrace-core.@DYNLIB_EXT@");
+    files = strdup("@CMAKE_BINARY_DIR@");
+    files = add_to_str(files, "/src/eztrace-lib/libeztrace-lib.@DYNLIB_EXT@");
   } else {
     files = strdup(EZTRACE_LIB_DIR);
-    files = add_to_str(files, "/libeztrace-core.@DYNLIB_EXT@"); //libeztrace-core
+    files = add_to_str(files, "/libeztrace-core.@DYNLIB_EXT@");
     files = strdup(EZTRACE_LIB_DIR);
-    files = add_to_str(files, "/libeztrace-lib.@DYNLIB_EXT@"); //libeztrace-core
+    files = add_to_str(files, "/libeztrace-lib.@DYNLIB_EXT@");
   }
   if (pptrace_add_preload(bin, files)) {
     fprintf(stderr, "Unable to add %s to @LD_PRELOAD_NAME@\n", files);
--- a/test/memory/test_memory.sh
+++ b/test/memory/test_memory.sh
@@ -3,7 +3,7 @@ CUR_PATH=$(dirname  $(realpath $0))
 source "$CUR_PATH/../test_utils/test_utils.sh"
 
 name="memory"
-run_and_check_command "$EZTRACE_PATH" -t "memory" "$CUR_PATH/$name"
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "memory" "$CUR_PATH/$name"
 
 trace_filename="${name}_trace/eztrace_log.otf2"
 
--- a/test/mpi/test_mpi_ping.sh
+++ b/test/mpi/test_mpi_ping.sh
@@ -6,7 +6,7 @@ name="mpi_ping"
 np="2"
 
 [ -n "$MPI_MODULE_NAME" ] || MPI_MODULE_NAME=mpi
-run_and_check_command "$MPIRUN_PATH" $MPIRUN_CLI_OPTION -np $np "$EZTRACE_PATH" -t "$MPI_MODULE_NAME $CUR_PATH/$name"
+run_and_check_command "$MPIRUN_PATH" $MPIRUN_CLI_OPTION -np $np "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "$MPI_MODULE_NAME $CUR_PATH/$name"
 
 trace_filename="${name}_trace/eztrace_log.otf2"
 if ! "$OTF2_PRINT_PATH" "$trace_filename" 2>&1 > /dev/null ; then
--- a/test/ompt/test_lock.sh
+++ b/test/ompt/test_lock.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="lock"
 
-run_and_check_command "$EZTRACE_PATH" -t "ompt" "$CUR_PATH/test_$name"
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "ompt" "$CUR_PATH/test_$name"
 
 trace_filename="test_${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename"
--- a/test/ompt/test_parallel_for.sh
+++ b/test/ompt/test_parallel_for.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="parallel_for"
 
-run_and_check_command "$EZTRACE_PATH" -t "ompt" "$CUR_PATH/test_$name"
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "ompt" "$CUR_PATH/test_$name"
 
 trace_filename="test_${name}_trace/eztrace_log.otf2"
 
--- a/test/ompt/test_task.sh
+++ b/test/ompt/test_task.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="task"
 
-nb_tasks=$("$EZTRACE_PATH" -t "ompt" "$CUR_PATH/test_$name" 2>&1 | grep "Number of executed tasks" | cut -d' ' -f5)
+nb_tasks=$("$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "ompt" "$CUR_PATH/test_$name" 2>&1 | grep "Number of executed tasks" | cut -d' ' -f5)
 
 trace_filename="test_${name}_trace/eztrace_log.otf2"
 
--- a/test/openmp/test_lock.sh
+++ b/test/openmp/test_lock.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="lock"
 
-run_and_check_command "$EZTRACE_PATH" -t "openmp" "$CUR_PATH/test_$name" || ((nb_fail++))
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "openmp" "$CUR_PATH/test_$name" || ((nb_fail++))
 
 trace_filename="test_${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename" ||  ((nb_fail++))
--- a/test/openmp/test_nest_lock.sh
+++ b/test/openmp/test_nest_lock.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="nest_lock"
 
-run_and_check_command "$EZTRACE_PATH" -t "openmp" "$CUR_PATH/test_$name" || ((nb_fail++))
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "openmp" "$CUR_PATH/test_$name" || ((nb_fail++))
 
 trace_filename="test_${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename" || return 1
--- a/test/openmp/test_openmp_simple.sh
+++ b/test/openmp/test_openmp_simple.sh
@@ -5,7 +5,7 @@ source "$CUR_PATH/../test_utils/test_uti
 name="openmp_simple"
 export OMP_NUM_THREADS=4
 
-run_and_check_command "$EZTRACE_PATH" -t "openmp" "$CUR_PATH/$name" || ((nb_fail++))
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "openmp" "$CUR_PATH/$name" || ((nb_fail++))
 
 trace_filename="${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename" || exit 1
--- a/test/openmp/test_task.sh
+++ b/test/openmp/test_task.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="task"
 
-run_and_check_command "$EZTRACE_PATH" -t "openmp" "$CUR_PATH/test_$name" || ((nb_fail++))
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "openmp" "$CUR_PATH/test_$name" || ((nb_fail++))
 
 trace_filename="test_${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename" || exit 1
--- a/test/posixio/test_my_cat.sh
+++ b/test/posixio/test_my_cat.sh
@@ -8,7 +8,7 @@ output_file="output_file.tmp"
 size=1000
 dd if=/dev/random of="$input_file" count=1000 bs=1
 
-run_and_check_command "$EZTRACE_PATH" -t "posixio" "$CUR_PATH/$name" "${input_file}" "$output_file"
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "posixio" "$CUR_PATH/$name" "${input_file}" "$output_file"
 
 trace_filename="${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename"
--- a/test/posixio/test_posixio.sh
+++ b/test/posixio/test_posixio.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="posixio"
 
-run_and_check_command "$EZTRACE_PATH" -t "posixio" "$CUR_PATH/$name"
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "posixio"  "$CUR_PATH/$name"
 
 trace_filename="${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename"
--- a/test/pthread/test_dummy.sh
+++ b/test/pthread/test_dummy.sh
@@ -4,7 +4,7 @@ source "$CUR_PATH/../test_utils/test_uti
 
 name="dummy_thread"
 [ -n "$EZTRACE_PATH" ] || EZTRACE_PATH=eztrace
-run_and_check_command "$EZTRACE_PATH" -t "pthread" "$CUR_PATH/dummy_thread"
+run_and_check_command "$EZTRACE_PATH" $EZTRACE_TEST_OPTION -t "pthread" "$CUR_PATH/dummy_thread"
 
 trace_filename="${name}_trace/eztrace_log.otf2"
 trace_check_integrity "$trace_filename"
--- a/test/unit_tests/CMakeLists.txt
+++ b/test/unit_tests/CMakeLists.txt
@@ -49,4 +49,5 @@ set_property(TEST ${test_list}
   "EZTRACE_CC_PATH=${CMAKE_BINARY_DIR}/modules/omp/bin/eztrace_cc"
   "EZTRACE_PATH=${CMAKE_BINARY_DIR}/src/eztrace"
   "OTF2_PRINT_PATH=${OTF2_PRINT}"
+  "EZTRACE_TEST_OPTION=-p"
 )
