3 # Copyright (C) 2017 Erica Bugden <erica.bugden@efficios.com>
4 # Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
6 # SPDX-License-Identifier: LGPL-2.1-only
9 TEST_DESC
="Userspace probe - Testing userspace probe on ELF symbol"
11 CURDIR
=$
(dirname "$0")/
13 TESTAPP_DIR
="$TESTDIR/utils/testapp/"
14 ELF_TEST_BIN_DIR
="$TESTAPP_DIR/userspace-probe-elf-binary/.libs/"
15 ELF_TEST_BIN_NAME
="userspace-probe-elf-binary"
16 ELF_TEST_BIN
="$ELF_TEST_BIN_DIR/$ELF_TEST_BIN_NAME"
17 ELF_CXX_TEST_BIN_DIR
="$TESTAPP_DIR/userspace-probe-elf-cxx-binary/"
18 ELF_CXX_TEST_BIN_NAME
="userspace-probe-elf-cxx-binary"
19 ELF_CXX_TEST_BIN
="$ELF_CXX_TEST_BIN_DIR/$ELF_CXX_TEST_BIN_NAME"
20 SDT_TEST_BIN_DIR
="$TESTAPP_DIR/userspace-probe-sdt-binary/.libs/"
21 SDT_TEST_BIN_NAME
="userspace-probe-sdt-binary"
22 SDT_TEST_BIN
="$SDT_TEST_BIN_DIR/$SDT_TEST_BIN_NAME"
23 ELF_SYMBOL
="test_function"
24 PROBE_EVENT_NAME
=userspace_probe_test_event
27 ERROR_OUTPUT_DEST
=/dev
/null
29 source "$TESTDIR/utils/utils.sh"
31 function validate_list
()
36 out
=$
("$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list
"$session_name" |
grep "$event_name")
37 if [ -z "$out" ]; then
38 fail
"Validate userspace probe listing"
39 diag
"$event_name not found when listing $session_name"
41 pass
"Validate userspace probe listing. Found $event_name."
45 function test_userspace_probe_enable_file_noexist
()
47 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
48 SESSION_NAME
="test_userspace_probe_enable_file_noexist"
49 ENABLE_EXPR
="elf:/etc/file-not-exist:$ELF_SYMBOL"
51 diag
"Userspace probe enable on non-existant file"
53 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
55 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME $ENABLE_EXPR $PROBE_EVENT_NAME
57 destroy_lttng_session_ok
$SESSION_NAME
62 function test_userspace_probe_enable_file_not_elf
()
64 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
65 SESSION_NAME
="test_userspace_probe_enable_file_not_elf"
66 ENABLE_EXPR
="elf:/etc/passwd:$ELF_SYMBOL"
68 diag
"Userspace probe enable on a non ELF file"
70 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
72 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME $ENABLE_EXPR $PROBE_EVENT_NAME
74 destroy_lttng_session_ok
$SESSION_NAME
79 function test_userspace_probe_enable_elf_missing_symbol_name
()
81 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
82 SESSION_NAME
="test_userspace_probe_enable_elf_missing_symbol"
83 ENABLE_EXPR
="elf:$ELF_TEST_BIN:"
85 diag
"Userspace probe enable with unspecified ELF symbol"
87 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
89 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
91 destroy_lttng_session_ok
$SESSION_NAME
96 function test_userspace_probe_enable_elf_nonexistant_symbol
()
98 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
99 SESSION_NAME
="test_userspace_probe_enable_elf_nonexistant_symbol"
100 ELF_SYMBOL_NO_EXIST
="function_doesnt_exist"
101 ENABLE_EXPR
="elf:$ELF_TEST_BIN:$ELF_SYMBOL_NO_EXIST"
103 diag
"Userspace probe enable with nonexistant ELF symbol"
105 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
107 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
109 destroy_lttng_session_ok
$SESSION_NAME
114 function test_userspace_probe_enable_elf_symbol_not_function
()
116 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
117 SESSION_NAME
="test_userspace_probe_enable_elf_symbol_not_function"
118 ELF_SYMBOL_NO_FUNC
="not_a_function"
119 ENABLE_EXPR
="elf:$ELF_TEST_BIN:$ELF_SYMBOL_NO_FUNC"
121 diag
"Userspace probe enable with non-function ELF symbol"
123 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
125 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
127 destroy_lttng_session_ok
$SESSION_NAME
132 function test_userspace_probe_unsupported_types
()
134 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
135 SESSION_NAME
="test_userspace_probe_unsupported_types"
136 # Userspace probe at an address or at an offset to a function
137 # instrumentation description types are not supported at the moment.
138 ENABLE_EXPR_1
="elf:$ELF_TEST_BIN:0x400030"
139 ENABLE_EXPR_2
="elf:$ELF_TEST_BIN:4194364"
140 ENABLE_EXPR_3
="elf:$ELF_TEST_BIN:$ELF_SYMBOL+0x21"
141 ENABLE_EXPR_4
="elf:$ELF_TEST_BIN:$ELF_SYMBOL+2"
143 diag
"Userspace probe enable with unsupported instrumentation description type"
145 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
147 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR_1" $PROBE_EVENT_NAME
148 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR_2" $PROBE_EVENT_NAME
149 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR_3" $PROBE_EVENT_NAME
150 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR_4" $PROBE_EVENT_NAME
152 destroy_lttng_session_ok
$SESSION_NAME
157 function test_userspace_probe_enable_implicit_probe_type
()
159 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
160 SESSION_NAME
="test_userspace_probe_enable_implicit_probe_type"
161 ENABLE_EXPR
="$ELF_TEST_BIN:$ELF_SYMBOL"
163 diag
"Userspace probe enabled successfully with implicit probe type"
165 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
167 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
169 validate_list
$SESSION_NAME $ELF_SYMBOL
170 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
171 validate_list
$SESSION_NAME "ELF"
172 validate_list
$SESSION_NAME "Function"
174 destroy_lttng_session_ok
$SESSION_NAME
179 function test_userspace_probe_enable_elf_symbol_exists
()
181 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
182 SESSION_NAME
="test_userspace_probe_enable_elf_symbol_exists"
183 ENABLE_EXPR
="elf:$ELF_TEST_BIN:$ELF_SYMBOL"
185 diag
"Userspace probe enabled successfully"
187 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
189 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
191 validate_list
$SESSION_NAME $ELF_SYMBOL
192 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
193 validate_list
$SESSION_NAME "ELF"
194 validate_list
$SESSION_NAME "Function"
196 destroy_lttng_session_ok
$SESSION_NAME
201 function test_userspace_probe_enable_in_path
()
203 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
204 SESSION_NAME
="test_userspace_probe_enable_in_path"
205 ENABLE_EXPR
="elf:$ELF_TEST_BIN_NAME:$ELF_SYMBOL"
207 diag
"Userspace probe on binary in PATH enabled successfully"
209 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
211 # Save old PATH and add the test directory to the PATH.
213 export PATH
="$PATH:$(realpath $ELF_TEST_BIN_DIR)"
215 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
217 validate_list
$SESSION_NAME $ELF_SYMBOL
218 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
219 validate_list
$SESSION_NAME "ELF"
220 validate_list
$SESSION_NAME "Function"
222 # Reset the previously saved PATH.
223 export PATH
="$OLDPATH"
225 destroy_lttng_session_ok
$SESSION_NAME
230 function test_userspace_probe_enable_full_path
()
232 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
233 SESSION_NAME
="test_userspace_probe_enable_full_path"
234 ENABLE_EXPR
="elf:$(realpath $ELF_TEST_BIN):$ELF_SYMBOL"
235 diag
"Userspace probe with full path enabled successfully"
237 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
239 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
241 validate_list
$SESSION_NAME $ELF_SYMBOL
242 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
243 validate_list
$SESSION_NAME "ELF"
244 validate_list
$SESSION_NAME "Function"
246 destroy_lttng_session_ok
$SESSION_NAME
251 function test_userspace_probe_enable_colon_in_path
()
253 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
254 SESSION_NAME
="test_userspace_probe_enable_colon_in_path"
255 COLON_FILE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
256 ELF_BIN_SYMLINK
="$COLON_FILE_PATH/colon_:_in_name"
257 ELF_BIN_WITH_COLON_IN_NAME_ESCAPED
="$COLON_FILE_PATH/colon_\:_in_name"
258 ENABLE_EXPR
="elf:"$ELF_BIN_WITH_COLON_IN_NAME_ESCAPED":$ELF_SYMBOL"
260 ln -s $
(realpath
$ELF_TEST_BIN) $ELF_BIN_SYMLINK
262 diag
"Userspace probe with binary with colon in name enabled successfully"
264 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
266 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
268 validate_list
$SESSION_NAME $ELF_SYMBOL
269 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
270 validate_list
$SESSION_NAME "ELF"
271 validate_list
$SESSION_NAME "Function"
273 destroy_lttng_session_ok
$SESSION_NAME
276 rm -rf "$COLON_FILE_PATH"
279 function test_userspace_probe_elf
()
281 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
282 SESSION_NAME
="test_userprobe_elf"
283 ENABLE_EXPR
="elf:$ELF_TEST_BIN:$ELF_SYMBOL"
285 diag
"Userspace probe on Elf symbol enabled and traced"
287 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
289 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
291 start_lttng_tracing_ok
$SESSION_NAME
292 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-elf-binary/.libs" "$ELF_TEST_BIN" > /dev
/null
293 stop_lttng_tracing_ok
$SESSION_NAME
295 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
297 destroy_lttng_session_ok
$SESSION_NAME
302 function test_userspace_probe_elf_dynamic_symbol
()
304 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
305 SESSION_NAME
="test_userprobe_elf"
306 LIBFOO_PATH
="$ELF_TEST_BIN_DIR/libfoo.so"
307 ENABLE_EXPR
="elf:$LIBFOO_PATH:dynamic_symbol"
309 diag
"Userspace probe on Elf dynamic symbol enabled and traced"
311 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
313 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
315 start_lttng_tracing_ok
$SESSION_NAME
316 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-elf-binary/.libs" "$ELF_TEST_BIN" > /dev
/null
317 stop_lttng_tracing_ok
$SESSION_NAME
319 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
321 destroy_lttng_session_ok
$SESSION_NAME
326 function test_userspace_probe_elf_cxx_function
()
328 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
329 SESSION_NAME
="test_userprobe_elf_cxx_function"
330 # Probing C++ mangled symbols should work the same way as regular Elf
332 ELF_SYMBOL_CXX
="_Z17test_cxx_functionv"
333 ENABLE_EXPR
="elf:$ELF_CXX_TEST_BIN:$ELF_SYMBOL_CXX"
335 diag
"Userspace probe on C++ mangled function enabled and traced"
337 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
339 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
341 start_lttng_tracing_ok
$SESSION_NAME
342 eval "$ELF_CXX_TEST_BIN" > /dev
/null
343 stop_lttng_tracing_ok
$SESSION_NAME
345 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
347 destroy_lttng_session_ok
$SESSION_NAME
352 function test_userspace_probe_elf_cxx_method
()
354 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
355 SESSION_NAME
="test_userprobe_elf_cxx_method"
356 # Probing C++ mangled symbols should work the same way as regular Elf
358 ELF_SYMBOL_CXX
="_ZN10test_class11test_methodEv"
359 ENABLE_EXPR
="elf:$ELF_CXX_TEST_BIN:$ELF_SYMBOL_CXX"
361 diag
"Userspace probe on C++ mangled method enabled and traced"
363 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
365 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
367 start_lttng_tracing_ok
$SESSION_NAME
368 eval "$ELF_CXX_TEST_BIN" > /dev
/null
369 stop_lttng_tracing_ok
$SESSION_NAME
371 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
373 destroy_lttng_session_ok
$SESSION_NAME
378 function test_userspace_probe_elf_disable
()
380 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
381 SESSION_NAME
="test_userprobe_elf_disable"
382 ENABLE_EXPR
="elf:$ELF_TEST_BIN:$ELF_SYMBOL"
384 diag
"Userspace probe on Elf symbol disabled and traced"
386 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
388 # Activate and disable event
389 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
390 disable_kernel_lttng_userspace_probe_event_ok
$SESSION_NAME $PROBE_EVENT_NAME
392 start_lttng_tracing_ok
$SESSION_NAME
393 eval "$ELF_TEST_BIN" > /dev
/null
394 stop_lttng_tracing_ok
$SESSION_NAME
396 # Verify that the trace contains zero event.
397 validate_trace_empty
"$TRACE_PATH"
399 destroy_lttng_session_ok
$SESSION_NAME
404 function test_userspace_probe_elf_list
()
406 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
407 SESSION_NAME
="test_userprobe_elf_list"
408 ENABLE_EXPR
="elf:$ELF_TEST_BIN:$ELF_SYMBOL"
410 diag
"Userspace probe ELF enabled and listed"
412 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
414 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
416 validate_list
$SESSION_NAME $PROBE_EVENT_NAME
417 validate_list
$SESSION_NAME $ELF_SYMBOL
418 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
419 validate_list
$SESSION_NAME "ELF"
420 validate_list
$SESSION_NAME "Function"
422 destroy_lttng_session_ok
$SESSION_NAME
427 function test_userspace_probe_save_load_elf
()
429 # Test that the load and save works for userspace probes AND that when
430 # a userspace probe is placed on a symlink by the user the save command
431 # saves the path to the link and not to the actual file. This is to
432 # support instrumentation of shared objects that are often accessed
433 # through symlinks and updated.
434 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
435 TMP_LINK_DIR
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
436 TMP_SAVE_DIR
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
438 SESSION_NAME
="test_userprobe_save_load_elf"
440 ELF_BIN_SYMLINK
="$TMP_LINK_DIR"/bin_elf_symlink
442 ENABLE_EXPR_ELF
="elf:$ELF_BIN_SYMLINK:$ELF_SYMBOL"
443 PROBE_EVENT_NAME_ELF
="$PROBE_EVENT_NAME"_elf
445 # Create symlinks to the target binaries.
446 ln -s $
(realpath
$ELF_TEST_BIN) $ELF_BIN_SYMLINK
448 diag
"Userspace probes Elf are saved and loaded"
450 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
452 # Enable userspace prove events.
453 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR_ELF" "$PROBE_EVENT_NAME_ELF"
455 # Confirm that the events were enabled.
456 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
458 # Save the session to a file.
459 lttng_save
$SESSION_NAME "--output-path=$TMP_SAVE_DIR"
461 destroy_lttng_session_ok
$SESSION_NAME
463 # Confirm that the userspace probe are save to the xml file.
464 local count
=$
(cat $TMP_SAVE_DIR/* |
grep --count -E "$ELF_BIN_SYMLINK")
465 if [[ $count -eq "1" ]]; then
466 pass
"Symlink found in saved session"
468 fail
"Symlink to binary not found in saved session"
471 # Load the saved session.
472 lttng_load_ok
"--input-path=$TMP_SAVE_DIR"
474 # Confirm that the userspace probes event are enabled in the newly
476 validate_list
$SESSION_NAME $ELF_TEST_BIN_NAME
478 # Cleanup temp files and folders.
480 rm -rf "$TMP_LINK_DIR"
481 rm -rf "$TMP_SAVE_DIR"
483 function test_userspace_probe_save_load_sdt
()
485 # Test that the load and save works for userspace probes AND that when
486 # a userspace probe is placed on a symlink by the user the save command
487 # saves the path to the link and not to the actual file. This is to
488 # support instrumentation of shared objects that are often accessed
489 # through symlinks and updated.
490 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
491 TMP_LINK_DIR
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
492 TMP_SAVE_DIR
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
494 SESSION_NAME
="test_userprobe_save_load_sdt"
498 SDT_BIN_SYMLINK
="$TMP_LINK_DIR"/bin_sdt_symlink
500 ENABLE_EXPR_SDT
="sdt:$SDT_BIN_SYMLINK:$PROVIDER:$PROBE"
501 PROBE_EVENT_NAME_SDT
="$PROBE_EVENT_NAME"_sdt
503 # Create symlinks to the target binaries.
504 ln -s $
(realpath
$SDT_TEST_BIN) $SDT_BIN_SYMLINK
506 diag
"Userspace probes SDT are saved and loaded"
508 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
510 # Enable userspace prove events.
511 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR_SDT" "$PROBE_EVENT_NAME_SDT"
513 # Confirm that the events were enabled.
514 validate_list
$SESSION_NAME $SDT_TEST_BIN_NAME
516 # Save the session to a file.
517 lttng_save
$SESSION_NAME "--output-path=$TMP_SAVE_DIR"
519 destroy_lttng_session_ok
$SESSION_NAME
521 # Confirm that the userspace probe are save to the xml file.
522 local count
=$
(cat $TMP_SAVE_DIR/* |
grep --count -E "$SDT_BIN_SYMLINK")
523 if [[ $count -eq "1" ]]; then
524 pass
"Symlink found in saved session"
526 fail
"Symlink to binary not found in saved session"
529 # Load the saved session.
530 lttng_load_ok
"--input-path=$TMP_SAVE_DIR"
532 # Confirm that the userspace probes event are enabled in the newly
534 validate_list
$SESSION_NAME $SDT_TEST_BIN_NAME
536 # Cleanup temp files and folders.
538 rm -rf "$TMP_LINK_DIR"
539 rm -rf "$TMP_SAVE_DIR"
542 function test_userspace_probe_sdt
()
544 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
547 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
548 SESSION_NAME
="${FUNCNAME[0]}"
550 diag
"Userspace probe on SDT tracepoint enabled and traced"
552 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
554 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
556 start_lttng_tracing_ok
$SESSION_NAME
557 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-sdt-binary/.libs" "$SDT_TEST_BIN" > /dev
/null
558 stop_lttng_tracing_ok
$SESSION_NAME
560 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
562 destroy_lttng_session_ok
$SESSION_NAME
567 function test_userspace_probe_sdt_list
()
569 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
570 SESSION_NAME
="test_userprobe_sdt_list"
573 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
575 diag
"Userspace probe SDT enabled and listed"
577 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
579 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
581 validate_list
$SESSION_NAME $PROBE_EVENT_NAME
582 validate_list
$SESSION_NAME $PROVIDER
583 validate_list
$SESSION_NAME $PROBE
584 validate_list
$SESSION_NAME $SDT_TEST_BIN_NAME
585 validate_list
$SESSION_NAME "SDT"
586 validate_list
$SESSION_NAME "Tracepoint"
588 destroy_lttng_session_ok
$SESSION_NAME
593 function test_userspace_probe_enable_sdt_nonexistant_provider
()
595 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
596 SESSION_NAME
="test_userprobe_sdt_nonexistand_provider"
597 PROVIDER
="not_provider"
599 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
601 diag
"Userspace probe SDT on tracepoint non existant provider"
603 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
605 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
607 destroy_lttng_session_ok
$SESSION_NAME
612 function test_userspace_probe_enable_sdt_nonexistant_probe
()
614 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
615 SESSION_NAME
="test_userprobe_sdt_nonexistant_probe"
617 PROBE
="not_a_tracepoint"
618 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
620 diag
"Userspace probe SDT on non existant probe"
622 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
624 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
626 destroy_lttng_session_ok
$SESSION_NAME
631 function test_userspace_probe_enable_sdt_with_sema
()
633 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
634 SESSION_NAME
="test_userprobe_sdt_with_sema"
636 PROBE
="tp_with_semaphore"
637 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
639 diag
"Userspace probe SDT on non existant probe"
641 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
643 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
645 destroy_lttng_session_ok
$SESSION_NAME
650 function test_userspace_probe_sdt_one_probe
()
652 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
653 SESSION_NAME
="test_userprobe_sdt_one_probe"
656 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
658 diag
"Userspace probe SDT on tracepoint with one callsite"
660 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
662 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
664 start_lttng_tracing_ok
$SESSION_NAME
665 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-sdt-binary/.libs" "$SDT_TEST_BIN" > /dev
/null
666 stop_lttng_tracing_ok
$SESSION_NAME
668 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
670 destroy_lttng_session_ok
$SESSION_NAME
675 function test_userspace_probe_sdt_two_probes
()
677 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
678 SESSION_NAME
="test_userprobe_sdt_two_probes"
681 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
683 diag
"Userspace probe SDT on tracepoint with two callsites"
685 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
687 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
689 start_lttng_tracing_ok
$SESSION_NAME
690 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-sdt-binary/.libs" "$SDT_TEST_BIN" > /dev
/null
691 stop_lttng_tracing_ok
$SESSION_NAME
693 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
695 destroy_lttng_session_ok
$SESSION_NAME
700 function test_userspace_probe_sdt_in_shared_object
()
702 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
703 SESSION_NAME
="test_userprobe_sdt_shared_object"
705 PROBE
="tp_in_shared_object"
706 ENABLE_EXPR
="sdt:$SDT_TEST_BIN_DIR/libfoo.so:$PROVIDER:$PROBE"
708 diag
"Userspace probe SDT on tracepoint in shared object"
710 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
712 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
714 start_lttng_tracing_ok
$SESSION_NAME
715 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-sdt-binary/.libs" "$SDT_TEST_BIN" > /dev
/null
716 stop_lttng_tracing_ok
$SESSION_NAME
718 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
720 destroy_lttng_session_ok
$SESSION_NAME
725 function test_userspace_probe_sdt_in_shared_object_dlopen
()
727 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
728 SESSION_NAME
="test_userprobe_sdt_shared_object_dlopen"
731 ENABLE_EXPR
="sdt:$SDT_TEST_BIN_DIR/libbar.so:$PROVIDER:$PROBE"
733 diag
"Userspace probe SDT on tracepoint in dlopen()ed shared object"
735 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
737 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
739 start_lttng_tracing_ok
$SESSION_NAME
740 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-sdt-binary/.libs" "$SDT_TEST_BIN" > /dev
/null
741 stop_lttng_tracing_ok
$SESSION_NAME
743 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
745 destroy_lttng_session_ok
$SESSION_NAME
750 function test_userspace_probe_sdt_in_shared_object_ldpreload
()
752 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
753 SESSION_NAME
="test_userprobe_sdt_shared_object_ldpreload"
755 PROBE
="tp_in_ldpreload"
756 ENABLE_EXPR
="sdt:$SDT_TEST_BIN_DIR/libzzz.so:$PROVIDER:$PROBE"
758 diag
"Userspace probe SDT on tracepoint in an LD_PRELOADed shared object"
760 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
762 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
764 start_lttng_tracing_ok
$SESSION_NAME
765 LD_PRELOAD
="$SDT_TEST_BIN_DIR/libzzz.so" LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-sdt-binary/.libs" "$SDT_TEST_BIN" > /dev
/null
766 stop_lttng_tracing_ok
$SESSION_NAME
768 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
770 destroy_lttng_session_ok
$SESSION_NAME
775 function test_userspace_probe_sdt_with_arg
()
777 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
778 SESSION_NAME
="test_userprobe_sdt_arg"
781 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
783 diag
"Userspace probe SDT on tracepoint with argument"
785 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
787 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
789 start_lttng_tracing_ok
$SESSION_NAME
790 LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$TESTDIR/utils/testapp/userspace-probe-sdt-binary/.libs" "$SDT_TEST_BIN" > /dev
/null
791 stop_lttng_tracing_ok
$SESSION_NAME
793 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
795 destroy_lttng_session_ok
$SESSION_NAME
800 ls "$SDT_TEST_BIN" >/dev
/null
2>&1
801 if test $?
== 0; then
802 NUM_TESTS
=$
((NUM_TESTS
+68))
808 ls "$ELF_CXX_TEST_BIN" >/dev
/null
2>&1
809 if test $?
== 0; then
810 NUM_TESTS
=$
((NUM_TESTS
+12))
815 plan_tests
$NUM_TESTS
816 print_test_banner
"$TEST_DESC"
818 check_skip_kernel_test
"$NUM_TESTS" "Skipping all tests." ||
820 validate_lttng_modules_present
823 # Unsuccessful event enabling
824 test_userspace_probe_enable_file_noexist
825 test_userspace_probe_enable_file_not_elf
827 test_userspace_probe_enable_elf_missing_symbol_name
828 test_userspace_probe_enable_elf_nonexistant_symbol
829 test_userspace_probe_enable_elf_symbol_not_function
830 test_userspace_probe_unsupported_types
832 # Successful userspace probe elf enabling
833 test_userspace_probe_enable_implicit_probe_type
834 test_userspace_probe_enable_in_path
835 test_userspace_probe_enable_full_path
836 test_userspace_probe_enable_elf_symbol_exists
837 test_userspace_probe_enable_colon_in_path
839 # Successful tracing userspace probe elf
840 test_userspace_probe_elf
841 test_userspace_probe_elf_dynamic_symbol
843 # Disable userspace-probe elf
844 test_userspace_probe_elf_disable
846 # Successful listing of userspace probe elf
847 test_userspace_probe_elf_list
849 # Successful save and load of userspace probe elf
850 test_userspace_probe_save_load_elf
852 if test $RUN_ELF_CXX_TESTS == 1; then
853 # Successful tracing of userspace probe elf on C++ symbol
854 test_userspace_probe_elf_cxx_function
855 test_userspace_probe_elf_cxx_method
858 if test $RUN_SDT_TESTS == 1; then
859 # Unsuccessful event enabling
860 test_userspace_probe_enable_sdt_nonexistant_provider
861 test_userspace_probe_enable_sdt_nonexistant_probe
862 test_userspace_probe_enable_sdt_with_sema
864 # Successful userspace probe sdt enabling
865 test_userspace_probe_sdt_one_probe
866 test_userspace_probe_sdt_two_probes
867 test_userspace_probe_sdt_with_arg
868 test_userspace_probe_sdt_in_shared_object
869 test_userspace_probe_sdt_in_shared_object_dlopen
870 test_userspace_probe_sdt_in_shared_object_ldpreload
872 # Successful tracing of userspace probe sdt
873 test_userspace_probe_sdt
875 # Successful listing of userspace probe sdt
876 test_userspace_probe_sdt_list
878 # Successful save and load of userspace probe sdt
879 test_userspace_probe_save_load_sdt