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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
254 SESSION_NAME
="test_userspace_probe_enable_colon_in_path"
255 COLON_FILE_PATH
=$
(mktemp
-d)
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)
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 eval "$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)
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 eval "$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)
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)
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)
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)
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)
435 TMP_LINK_DIR
=$
(mktemp
-d)
436 TMP_SAVE_DIR
=$
(mktemp
-d)
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)
491 TMP_LINK_DIR
=$
(mktemp
-d)
492 TMP_SAVE_DIR
=$
(mktemp
-d)
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)
547 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
549 diag
"Userspace probe on SDT tracepoint enabled and traced"
551 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
553 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
555 start_lttng_tracing_ok
$SESSION_NAME
556 eval "$SDT_TEST_BIN" > /dev
/null
557 stop_lttng_tracing_ok
$SESSION_NAME
559 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
561 destroy_lttng_session_ok
$SESSION_NAME
566 function test_userspace_probe_sdt_list
()
568 TRACE_PATH
=$
(mktemp
-d)
569 SESSION_NAME
="test_userprobe_sdt_list"
572 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
574 diag
"Userspace probe SDT enabled and listed"
576 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
578 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
580 validate_list
$SESSION_NAME $PROBE_EVENT_NAME
581 validate_list
$SESSION_NAME $PROVIDER
582 validate_list
$SESSION_NAME $PROBE
583 validate_list
$SESSION_NAME $SDT_TEST_BIN_NAME
584 validate_list
$SESSION_NAME "SDT"
585 validate_list
$SESSION_NAME "Tracepoint"
587 destroy_lttng_session_ok
$SESSION_NAME
592 function test_userspace_probe_enable_sdt_nonexistant_provider
()
594 TRACE_PATH
=$
(mktemp
-d)
595 SESSION_NAME
="test_userprobe_sdt_nonexistand_provider"
596 PROVIDER
="not_provider"
598 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
600 diag
"Userspace probe SDT on tracepoint non existant provider"
602 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
604 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
606 destroy_lttng_session_ok
$SESSION_NAME
611 function test_userspace_probe_enable_sdt_nonexistant_probe
()
613 TRACE_PATH
=$
(mktemp
-d)
614 SESSION_NAME
="test_userprobe_sdt_nonexistant_probe"
616 PROBE
="not_a_tracepoint"
617 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
619 diag
"Userspace probe SDT on non existant probe"
621 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
623 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
625 destroy_lttng_session_ok
$SESSION_NAME
630 function test_userspace_probe_enable_sdt_with_sema
()
632 TRACE_PATH
=$
(mktemp
-d)
633 SESSION_NAME
="test_userprobe_sdt_with_sema"
635 PROBE
="tp_with_semaphore"
636 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
638 diag
"Userspace probe SDT on non existant probe"
640 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
642 lttng_enable_kernel_userspace_probe_event_fail
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
644 destroy_lttng_session_ok
$SESSION_NAME
649 function test_userspace_probe_sdt_one_probe
()
651 TRACE_PATH
=$
(mktemp
-d)
652 SESSION_NAME
="test_userprobe_sdt_one_probe"
655 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
657 diag
"Userspace probe SDT on tracepoint with one callsite"
659 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
661 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
663 start_lttng_tracing_ok
$SESSION_NAME
664 eval "$SDT_TEST_BIN" > /dev
/null
665 stop_lttng_tracing_ok
$SESSION_NAME
667 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
669 destroy_lttng_session_ok
$SESSION_NAME
674 function test_userspace_probe_sdt_two_probes
()
676 TRACE_PATH
=$
(mktemp
-d)
677 SESSION_NAME
="test_userprobe_sdt_two_probes"
680 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
682 diag
"Userspace probe SDT on tracepoint with two callsites"
684 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
686 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
688 start_lttng_tracing_ok
$SESSION_NAME
689 eval "$SDT_TEST_BIN" > /dev
/null
690 stop_lttng_tracing_ok
$SESSION_NAME
692 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
694 destroy_lttng_session_ok
$SESSION_NAME
699 function test_userspace_probe_sdt_in_shared_object
()
701 TRACE_PATH
=$
(mktemp
-d)
702 SESSION_NAME
="test_userprobe_sdt_shared_object"
704 PROBE
="tp_in_shared_object"
705 ENABLE_EXPR
="sdt:$SDT_TEST_BIN_DIR/libfoo.so:$PROVIDER:$PROBE"
707 diag
"Userspace probe SDT on tracepoint in shared object"
709 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
711 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
713 start_lttng_tracing_ok
$SESSION_NAME
714 eval "$SDT_TEST_BIN" > /dev
/null
715 stop_lttng_tracing_ok
$SESSION_NAME
717 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
719 destroy_lttng_session_ok
$SESSION_NAME
724 function test_userspace_probe_sdt_in_shared_object_dlopen
()
726 TRACE_PATH
=$
(mktemp
-d)
727 SESSION_NAME
="test_userprobe_sdt_shared_object_dlopen"
730 ENABLE_EXPR
="sdt:$SDT_TEST_BIN_DIR/libbar.so:$PROVIDER:$PROBE"
732 diag
"Userspace probe SDT on tracepoint in dlopen()ed shared object"
734 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
736 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
738 start_lttng_tracing_ok
$SESSION_NAME
739 eval "$SDT_TEST_BIN" > /dev
/null
740 stop_lttng_tracing_ok
$SESSION_NAME
742 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
744 destroy_lttng_session_ok
$SESSION_NAME
749 function test_userspace_probe_sdt_in_shared_object_ldpreload
()
751 TRACE_PATH
=$
(mktemp
-d)
752 SESSION_NAME
="test_userprobe_sdt_shared_object_ldpreload"
754 PROBE
="tp_in_ldpreload"
755 ENABLE_EXPR
="sdt:$SDT_TEST_BIN_DIR/libzzz.so:$PROVIDER:$PROBE"
757 diag
"Userspace probe SDT on tracepoint in an LD_PRELOADed shared object"
759 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
761 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
763 start_lttng_tracing_ok
$SESSION_NAME
764 LD_PRELOAD
="$SDT_TEST_BIN_DIR/libzzz.so" eval "$SDT_TEST_BIN" > /dev
/null
765 stop_lttng_tracing_ok
$SESSION_NAME
767 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
769 destroy_lttng_session_ok
$SESSION_NAME
774 function test_userspace_probe_sdt_with_arg
()
776 TRACE_PATH
=$
(mktemp
-d)
777 SESSION_NAME
="test_userprobe_sdt_arg"
780 ENABLE_EXPR
="sdt:$SDT_TEST_BIN:$PROVIDER:$PROBE"
782 diag
"Userspace probe SDT on tracepoint with argument"
784 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
786 lttng_enable_kernel_userspace_probe_event_ok
$SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
788 start_lttng_tracing_ok
$SESSION_NAME
789 eval "$SDT_TEST_BIN" > /dev
/null
790 stop_lttng_tracing_ok
$SESSION_NAME
792 validate_trace
$PROBE_EVENT_NAME "$TRACE_PATH"
794 destroy_lttng_session_ok
$SESSION_NAME
799 ls "$SDT_TEST_BIN" >/dev
/null
2>&1
800 if test $?
== 0; then
801 NUM_TESTS
=$
((NUM_TESTS
+68))
807 ls "$ELF_CXX_TEST_BIN" >/dev
/null
2>&1
808 if test $?
== 0; then
809 NUM_TESTS
=$
((NUM_TESTS
+12))
814 plan_tests
$NUM_TESTS
815 print_test_banner
"$TEST_DESC"
817 if [ "$(id -u)" == "0" ]; then
823 skip
$isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
827 # Unsuccessful event enabling
828 test_userspace_probe_enable_file_noexist
829 test_userspace_probe_enable_file_not_elf
831 test_userspace_probe_enable_elf_missing_symbol_name
832 test_userspace_probe_enable_elf_nonexistant_symbol
833 test_userspace_probe_enable_elf_symbol_not_function
834 test_userspace_probe_unsupported_types
836 # Successful userspace probe elf enabling
837 test_userspace_probe_enable_implicit_probe_type
838 test_userspace_probe_enable_in_path
839 test_userspace_probe_enable_full_path
840 test_userspace_probe_enable_elf_symbol_exists
841 test_userspace_probe_enable_colon_in_path
843 # Successful tracing userspace probe elf
844 test_userspace_probe_elf
845 test_userspace_probe_elf_dynamic_symbol
847 # Disable userspace-probe elf
848 test_userspace_probe_elf_disable
850 # Successful listing of userspace probe elf
851 test_userspace_probe_elf_list
853 # Successful save and load of userspace probe elf
854 test_userspace_probe_save_load_elf
856 if test $RUN_ELF_CXX_TESTS == 1; then
857 # Successful tracing of userspace probe elf on C++ symbol
858 test_userspace_probe_elf_cxx_function
859 test_userspace_probe_elf_cxx_method
862 if test $RUN_SDT_TESTS == 1; then
863 # Unsuccessful event enabling
864 test_userspace_probe_enable_sdt_nonexistant_provider
865 test_userspace_probe_enable_sdt_nonexistant_probe
866 test_userspace_probe_enable_sdt_with_sema
868 # Successful userspace probe sdt enabling
869 test_userspace_probe_sdt_one_probe
870 test_userspace_probe_sdt_two_probes
871 test_userspace_probe_sdt_with_arg
872 test_userspace_probe_sdt_in_shared_object
873 test_userspace_probe_sdt_in_shared_object_dlopen
874 test_userspace_probe_sdt_in_shared_object_ldpreload
876 # Successful tracing of userspace probe sdt
877 test_userspace_probe_sdt
879 # Successful listing of userspace probe sdt
880 test_userspace_probe_sdt_list
882 # Successful save and load of userspace probe sdt
883 test_userspace_probe_save_load_sdt