Skip to content

Commit 4a26042

Browse files
authored
test(profiling): fix linking by removing recently added test (#3570)
This reverts commit fa1f099.
1 parent 60cd2c7 commit 4a26042

File tree

2 files changed

+5
-90
lines changed

2 files changed

+5
-90
lines changed

profiling/src/php_ffi.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ uintptr_t *ddog_test_php_prof_function_run_time_cache(zend_function const *func)
390390
}
391391
#endif
392392

393-
#if CFG_STACK_WALKING_TESTS || defined(CFG_TEST)
393+
#if CFG_STACK_WALKING_TESTS
394394
static int (*og_snprintf)(char *, size_t, const char *, ...);
395395

396396
// "weak" let's us polyfill, needed by zend_string_init(..., persistent: 1).
@@ -463,33 +463,7 @@ void ddog_php_test_free_fake_zend_execute_data(zend_execute_data *execute_data)
463463

464464
free(execute_data);
465465
}
466-
467-
zend_function *ddog_php_test_create_fake_zend_function_with_name_len(size_t len) {
468-
zend_op_array *op_array = calloc(1, sizeof(zend_function));
469-
if (!op_array) return NULL;
470-
471-
op_array->type = ZEND_USER_FUNCTION;
472-
473-
if (len > 0) {
474-
op_array->function_name = zend_string_alloc(len, true);
475-
if (!op_array->function_name) {
476-
free(op_array);
477-
return NULL;
478-
}
479-
memset(ZSTR_VAL(op_array->function_name), 'x', len);
480-
ZSTR_VAL(op_array->function_name)[len] = '\0';
481-
}
482-
483-
return (zend_function *)op_array;
484-
}
485-
486-
void ddog_php_test_free_fake_zend_function(zend_function *func) {
487-
if (!func) return;
488-
489-
free(func->common.function_name);
490-
free(func);
491-
}
492-
#endif // CFG_STACK_WALKING_TESTS || CFG_TEST
466+
#endif
493467

494468
void *opcache_handle = NULL;
495469

profiling/src/profiling/stack_walking.rs

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -528,20 +528,14 @@ mod detail {
528528

529529
pub use detail::*;
530530

531-
#[cfg(test)]
531+
// todo: this should be feature = "stack_walking_tests" but it seemed to
532+
// cause a failure in CI to migrate it.
533+
#[cfg(all(test, stack_walking_tests))]
532534
mod tests {
533535
use super::*;
534536
use crate::bindings as zend;
535537

536-
extern "C" {
537-
fn ddog_php_test_create_fake_zend_function_with_name_len(
538-
len: libc::size_t,
539-
) -> *mut zend::zend_function;
540-
fn ddog_php_test_free_fake_zend_function(func: *mut zend::zend_function);
541-
}
542-
543538
#[test]
544-
#[cfg(stack_walking_tests)]
545539
fn test_collect_stack_sample() {
546540
unsafe {
547541
let fake_execute_data = zend::ddog_php_test_create_fake_zend_execute_data(3);
@@ -566,57 +560,4 @@ mod tests {
566560
zend::ddog_php_test_free_fake_zend_execute_data(fake_execute_data);
567561
}
568562
}
569-
570-
#[test]
571-
fn test_extract_function_name_short_string() {
572-
unsafe {
573-
let func = ddog_php_test_create_fake_zend_function_with_name_len(10);
574-
assert!(!func.is_null());
575-
576-
let name = extract_function_name(&*func).expect("should extract name");
577-
assert_eq!(name, "xxxxxxxxxx");
578-
579-
ddog_php_test_free_fake_zend_function(func);
580-
}
581-
}
582-
583-
#[test]
584-
fn test_extract_function_name_at_limit_minus_one() {
585-
unsafe {
586-
let func = ddog_php_test_create_fake_zend_function_with_name_len(STR_LEN_LIMIT - 1);
587-
assert!(!func.is_null());
588-
589-
let name = extract_function_name(&*func).expect("should extract name");
590-
assert_eq!(name.len(), STR_LEN_LIMIT - 1);
591-
assert_ne!(name, COW_LARGE_STRING);
592-
593-
ddog_php_test_free_fake_zend_function(func);
594-
}
595-
}
596-
597-
#[test]
598-
fn test_extract_function_name_at_limit() {
599-
unsafe {
600-
let func = ddog_php_test_create_fake_zend_function_with_name_len(STR_LEN_LIMIT);
601-
assert!(!func.is_null());
602-
603-
let name = extract_function_name(&*func).expect("should return large string marker");
604-
assert_eq!(name, COW_LARGE_STRING);
605-
606-
ddog_php_test_free_fake_zend_function(func);
607-
}
608-
}
609-
610-
#[test]
611-
fn test_extract_function_name_over_limit() {
612-
unsafe {
613-
let func = ddog_php_test_create_fake_zend_function_with_name_len(STR_LEN_LIMIT + 1000);
614-
assert!(!func.is_null());
615-
616-
let name = extract_function_name(&*func).expect("should return large string marker");
617-
assert_eq!(name, COW_LARGE_STRING);
618-
619-
ddog_php_test_free_fake_zend_function(func);
620-
}
621-
}
622563
}

0 commit comments

Comments
 (0)