Skip to content

Commit

Permalink
Avoid undefined symbol errors in test run
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi committed Jan 6, 2025
1 parent 2175f56 commit dd16141
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions components-rs/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ typedef enum ddog_RemoteConfigProduct {
DDOG_REMOTE_CONFIG_PRODUCT_ASM,
DDOG_REMOTE_CONFIG_PRODUCT_ASM_DD,
DDOG_REMOTE_CONFIG_PRODUCT_ASM_FEATURES,
DDOG_REMOTE_CONFIG_PRODUCT_ASM_RASP_LFI,
DDOG_REMOTE_CONFIG_PRODUCT_ASM_RASP_SSRF,
DDOG_REMOTE_CONFIG_PRODUCT_LIVE_DEBUGGER,
} ddog_RemoteConfigProduct;

Expand Down
2 changes: 2 additions & 0 deletions profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ uuid = { version = "1.0", features = ["v4"] }

[dev-dependencies]
criterion = { version = "0.5.1" }
datadog-php-profiling = { path = ".", features = ["test"] }

[target.'cfg(target_arch = "x86_64")'.dev-dependencies]
criterion-perf-events = "0.4.0"
Expand All @@ -52,6 +53,7 @@ allocation_profiling = []
timeline = []
exception_profiling = []
stack_walking_tests = []
test = []

# only for testing:
trigger_time_sample = []
Expand Down
9 changes: 6 additions & 3 deletions profiling/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ fn build_zend_php_ffis(
#[cfg(not(feature = "stack_walking_tests"))]
let stack_walking_tests = "0";

cc::Build::new()
let mut build = cc::Build::new();
build
.files(files.into_iter().chain(zai_c_files))
.define("CFG_POST_STARTUP_CB", post_startup_cb)
.define("CFG_PRELOAD", preload)
Expand All @@ -165,8 +166,10 @@ fn build_zend_php_ffis(
)
.flag_if_supported("-fuse-ld=lld")
.flag_if_supported("-std=c11")
.flag_if_supported("-std=c17")
.compile("php_ffi");
.flag_if_supported("-std=c17");
#[cfg(feature = "test")]
build.define("CFG_TEST", "1");
build.compile("php_ffi");
}

#[derive(Debug)]
Expand Down
6 changes: 6 additions & 0 deletions profiling/src/php_ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ void datadog_php_profiling_copy_string_view_into_zval(zval *dest, zai_str view,
bool persistent) {
ZEND_ASSERT(dest);

#ifdef CFG_TEST
(void)dest;
(void)view;
ZEND_UNREACHABLE();
#else
if (view.len == 0) {
if (persistent) {
ZVAL_EMPTY_PSTRING(dest);
Expand All @@ -272,6 +277,7 @@ void datadog_php_profiling_copy_string_view_into_zval(zval *dest, zai_str view,
ZEND_ASSERT(view.ptr);
ZVAL_STR(dest, zend_string_init(view.ptr, view.len, persistent));
}
#endif
}

void ddog_php_prof_copy_long_into_zval(zval *dest, long num) {
Expand Down

0 comments on commit dd16141

Please sign in to comment.