Skip to content

Commit 9aa7b9f

Browse files
test(profiling): improve native tests (#16377)
## Description As title says, this is just a quality of life improvement PR: - Runs native tests in parallel - Fixes warnings reported by CMake when building.
1 parent fc64774 commit 9aa7b9f

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

ddtrace/internal/datadog/profiling/build_standalone.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ run_cmake() {
192192
fi
193193
if [[ " ${cmake_args[*]} " =~ " -DBUILD_TESTING=ON " ]]; then
194194
echo "--------------------------------------------------------------------- Running Tests"
195-
ctest ${ctest_args[*]} --output-on-failure || { echo "tests failed!"; exit 1; }
195+
if command -v nproc &> /dev/null; then
196+
NPROC=$(nproc)
197+
else
198+
NPROC=$(getconf _NPROCESSORS_ONLN)
199+
fi
200+
ctest -j${NPROC} ${ctest_args[*]} --output-on-failure || { echo "tests failed!"; exit 1; }
196201
fi
197202

198203
# OK, the build or whatever went fine I guess.

ddtrace/internal/datadog/profiling/dd_wrapper/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
3333

3434
# Since this file is currently only loaded as a subdirectory, we need to propagate certain libdatadog variables up to
3535
# the parent scope.
36-
set(Datadog_INCLUDE_DIRS
37-
${Datadog_INCLUDE_DIRS}
38-
PARENT_SCOPE)
39-
set(Datadog_LIBRARIES
40-
${Datadog_LIBRARIES}
41-
PARENT_SCOPE)
36+
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
37+
set(Datadog_INCLUDE_DIRS
38+
${Datadog_INCLUDE_DIRS}
39+
PARENT_SCOPE)
40+
set(Datadog_LIBRARIES
41+
${Datadog_LIBRARIES}
42+
PARENT_SCOPE)
43+
endif()
4244

4345
set(THREADS_PREFER_PTHREAD_FLAG ON)
4446
find_package(Threads REQUIRED)

ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ function(dd_wrapper_add_test name)
6060
ENVIRONMENT "TSAN_OPTIONS=die_after_fork=0:suppressions=${CMAKE_CURRENT_SOURCE_DIR}/TSan.supp")
6161

6262
if(LIB_INSTALL_DIR)
63-
install(TARGETS ${name} RUNTIME DESTINATION ${LIB_INSTALL_DIR}/../test)
63+
get_filename_component(_test_install_dir "${LIB_INSTALL_DIR}" DIRECTORY)
64+
set(_test_install_dir "${_test_install_dir}/test")
65+
install(TARGETS ${name} RUNTIME DESTINATION ${_test_install_dir})
6466
endif()
6567
endfunction()
6668

0 commit comments

Comments
 (0)