#!/bin/bash
#
-# Copyright (C) - 2017 Erica Bugden <erica.bugden@efficios.com>
-# Copyright (C) - 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
+# Copyright (C) 2017 Erica Bugden <erica.bugden@efficios.com>
+# Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
+# SPDX-License-Identifier: LGPL-2.1-only
#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
TEST_DESC="Userspace probe - Testing userspace probe on ELF symbol"
CURDIR=$(dirname "$0")/
TESTDIR=$CURDIR/../..
TESTAPP_DIR="$TESTDIR/utils/testapp/"
-ELF_TEST_BIN_DIR="$TESTAPP_DIR/userspace-probe-elf-binary/"
+ELF_TEST_BIN_DIR="$TESTAPP_DIR/userspace-probe-elf-binary/.libs/"
ELF_TEST_BIN_NAME="userspace-probe-elf-binary"
ELF_TEST_BIN="$ELF_TEST_BIN_DIR/$ELF_TEST_BIN_NAME"
ELF_CXX_TEST_BIN_DIR="$TESTAPP_DIR/userspace-probe-elf-cxx-binary/"
SDT_TEST_BIN="$SDT_TEST_BIN_DIR/$SDT_TEST_BIN_NAME"
ELF_SYMBOL="test_function"
PROBE_EVENT_NAME=userspace_probe_test_event
-NUM_TESTS=81
+NUM_TESTS=93
OUTPUT_DEST=/dev/null
ERROR_OUTPUT_DEST=/dev/null
rm -rf "$TRACE_PATH"
}
+function test_userspace_probe_unsupported_types ()
+{
+ TRACE_PATH=$(mktemp -d)
+ SESSION_NAME="test_userspace_probe_unsupported_types"
+ # Userspace probe at an address or at an offset to a function
+ # instrumentation description types are not supported at the moment.
+ ENABLE_EXPR_1="elf:$ELF_TEST_BIN:0x400030"
+ ENABLE_EXPR_2="elf:$ELF_TEST_BIN:4194364"
+ ENABLE_EXPR_3="elf:$ELF_TEST_BIN:$ELF_SYMBOL+0x21"
+ ENABLE_EXPR_4="elf:$ELF_TEST_BIN:$ELF_SYMBOL+2"
+
+ diag "Userspace probe enable with unsupported instrumentation description type"
+
+ create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
+
+ lttng_enable_kernel_userspace_probe_event_fail $SESSION_NAME "$ENABLE_EXPR_1" $PROBE_EVENT_NAME
+ lttng_enable_kernel_userspace_probe_event_fail $SESSION_NAME "$ENABLE_EXPR_2" $PROBE_EVENT_NAME
+ lttng_enable_kernel_userspace_probe_event_fail $SESSION_NAME "$ENABLE_EXPR_3" $PROBE_EVENT_NAME
+ lttng_enable_kernel_userspace_probe_event_fail $SESSION_NAME "$ENABLE_EXPR_4" $PROBE_EVENT_NAME
+
+ destroy_lttng_session_ok $SESSION_NAME
+
+ rm -rf "$TRACE_PATH"
+}
+
function test_userspace_probe_enable_implicit_probe_type ()
{
TRACE_PATH=$(mktemp -d)
rm -rf "$TRACE_PATH"
}
+function test_userspace_probe_elf_dynamic_symbol ()
+{
+ TRACE_PATH=$(mktemp -d)
+ SESSION_NAME="test_userprobe_elf"
+ LIBFOO_PATH="$ELF_TEST_BIN_DIR/libfoo.so"
+ ENABLE_EXPR="elf:$LIBFOO_PATH:dynamic_symbol"
+
+ diag "Userspace probe on Elf dynamic symbol enabled and traced"
+
+ create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
+
+ lttng_enable_kernel_userspace_probe_event_ok $SESSION_NAME "$ENABLE_EXPR" $PROBE_EVENT_NAME
+
+ start_lttng_tracing_ok $SESSION_NAME
+ eval "$ELF_TEST_BIN" > /dev/null
+ stop_lttng_tracing_ok $SESSION_NAME
+
+ validate_trace $PROBE_EVENT_NAME "$TRACE_PATH"
+
+ destroy_lttng_session_ok $SESSION_NAME
+
+ rm -rf "$TRACE_PATH"
+}
+
function test_userspace_probe_elf_cxx_function ()
{
TRACE_PATH=$(mktemp -d)
test_userspace_probe_enable_elf_missing_symbol_name
test_userspace_probe_enable_elf_nonexistant_symbol
test_userspace_probe_enable_elf_symbol_not_function
+ test_userspace_probe_unsupported_types
# Successful userspace probe elf enabling
test_userspace_probe_enable_implicit_probe_type
# Successful tracing userspace probe elf
test_userspace_probe_elf
+ test_userspace_probe_elf_dynamic_symbol
# Disable userspace-probe elf
test_userspace_probe_elf_disable