Skip to content

Commit 1d48125

Browse files
committed
test that wraprec is re-used when adding the same function to wraprec hashmap
1 parent cdbbdee commit 1d48125

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

agent/tests/test_user_instrument_wraprec_hashmap.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ static void test_wraprecs_hashmap() {
5757
found_wraprec = nr_php_user_instrument_wraprec_hashmap_get(func_name, NULL);
5858
tlib_pass_if_ptr_equal("getting valid global function", wraprec, found_wraprec);
5959

60+
wraprec = nr_php_user_instrument_wraprec_hashmap_add(NR_PSTR(FUNCTION_NAME),
61+
&is_new_wraprec);
62+
tlib_pass_if_not_null("adding valid global function one more time", wraprec);
63+
tlib_pass_if_false("adding valid global function one more time", is_new_wraprec,
64+
"expected false for is_new_wraprec");
65+
tlib_pass_if_ptr_equal("getting valid global function one more time", wraprec, found_wraprec);
66+
6067
found_wraprec = nr_php_user_instrument_wraprec_hashmap_get(func_name, scope_name);
6168
tlib_pass_if_null("getting global function with scope", found_wraprec);
6269

@@ -69,6 +76,13 @@ static void test_wraprecs_hashmap() {
6976
found_wraprec = nr_php_user_instrument_wraprec_hashmap_get(method_name, scope_name);
7077
tlib_pass_if_ptr_equal("getting scoped method", wraprec, found_wraprec);
7178

79+
wraprec = nr_php_user_instrument_wraprec_hashmap_add(NR_PSTR(SCOPED_METHOD_NAME),
80+
&is_new_wraprec);
81+
tlib_pass_if_not_null("adding valid scoped method one more time", wraprec);
82+
tlib_pass_if_false("adding valid scoped method one more time", is_new_wraprec,
83+
"expected false for is_new_wraprec");
84+
tlib_pass_if_ptr_equal("getting valid scoped method one more time", wraprec, found_wraprec);
85+
7286
found_wraprec = nr_php_user_instrument_wraprec_hashmap_get(NULL, scope_name);
7387
tlib_pass_if_null("getting scoped method without method name", found_wraprec);
7488

0 commit comments

Comments
 (0)