Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / tests / regression / kernel / test_callstack
index 6cb20bcdb56f8e6c95cac881d2c87617a4b5b9dc..960bb8a44e1511f08ae425a675dc296c75dc4410 100755 (executable)
@@ -1,25 +1,15 @@
 #!/bin/bash
 #
-# Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
+# Copyright (C) 2017 Francis Deslauriers <francis.deslauriers@efficios.com>
 #
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
+# SPDX-License-Identifier: GPL-2.0-only
 #
-# This program 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 General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 TEST_DESC="Kernel tracer - Callstack context"
 
 CURDIR=$(dirname "$0")/
 TESTDIR=$CURDIR/../..
-NUM_TESTS=11
+NUM_TESTS=12
 TEST_APP_USERSPACE="$TESTDIR/utils/testapp/gen-syscall-events-callstack/gen-syscall-events-callstack"
 TEST_APP_KERNELSPACE="$TESTDIR/utils/testapp/gen-syscall-events/gen-syscall-events"
 PARSE_CALLSTACK="$TESTDIR/utils/parse-callstack.py"
@@ -43,12 +33,14 @@ function lttng_track_pid()
 function run_workload()
 {
        local TEST_APP=$1
-       local start_file_sync
-       start_file_sync=$(mktemp -u)
+       # shift the first argument, passing along the other args if any to the
+       # test app.
+       shift
+       local start_file_sync=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_first.XXXXXX")
 
        lttng_untrack_all
 
-       ./"$TEST_APP" "$start_file_sync" &
+       ./"$TEST_APP" "$start_file_sync" "$@" &
        PID=$!
        lttng_track_pid $PID
 
@@ -68,7 +60,7 @@ function run_workload()
 
 function test_user_callstack()
 {
-       TRACE_PATH=$(mktemp -d)
+       TRACE_PATH=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
        # This is the expected userspace callstack. (see gen-syscall-events-callstack.c)
        USER_CS_EXPECTED="main fct_a fct_b fct_c my_gettid"
        EVENT_NAME="gettid"
@@ -92,7 +84,7 @@ function test_user_callstack()
 
 function test_kernel_callstack()
 {
-       TRACE_PATH=$(mktemp -d)
+       TRACE_PATH=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
        # Those are symbol expected to be present in the kernel callstack. This
        # is not an exhaustive list since it's kernel dependent.
 
@@ -118,7 +110,7 @@ function test_kernel_callstack()
        lttng_enable_kernel_syscall_ok "$SESSION_NAME" "$EVENT_NAME" "$CHANNEL_NAME"
        add_context_kernel_ok "$SESSION_NAME" "$CHANNEL_NAME" "callstack-kernel"
 
-       run_workload $TEST_APP_KERNELSPACE
+       run_workload "$TEST_APP_KERNELSPACE" "/proc/cpuinfo" "/proc/cmdline"
 
        destroy_lttng_session_ok "$SESSION_NAME"
 
@@ -128,10 +120,10 @@ function test_kernel_callstack()
        rm -rf "$TRACE_PATH"
 }
 
-# Only run userspace callstack test on x86
-uname -m | grep -E "x86" >/dev/null 2>&1
+# Only run userspace callstack test on x86 (32 and 64 variants)
+uname -m | grep "86" >/dev/null 2>&1
 if test $? == 0; then
-       NUM_TESTS=$((NUM_TESTS+11))
+       NUM_TESTS=$((NUM_TESTS+10))
        RUN_USERSPACE_TEST=1
 else
        RUN_USERSPACE_TEST=0
@@ -142,26 +134,18 @@ plan_tests $NUM_TESTS
 
 print_test_banner "$TEST_DESC"
 
-if [ "$(id -u)" == "0" ]; then
-       isroot=1
-else
-       isroot=0
-fi
+bail_out_if_no_babeltrace
 
-skip $isroot "Root access is needed. Skipping all tests." "$NUM_TESTS" ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
 {
-       which "$BABELTRACE_BIN" > /dev/null
-       test $? -ne 0
-       skip $? "Babeltrace binary not found. Skipping callstack tests" "$NUM_TESTS" ||
-       {
-               start_lttng_sessiond
+       validate_lttng_modules_present
+       start_lttng_sessiond
 
-               if test $RUN_USERSPACE_TEST == 1; then
-                       test_user_callstack
-               fi
+       if test $RUN_USERSPACE_TEST == 1; then
+               test_user_callstack
+       fi
 
-               test_kernel_callstack
+       test_kernel_callstack
 
-               stop_lttng_sessiond
-       }
+       stop_lttng_sessiond
 }
This page took 0.026168 seconds and 4 git commands to generate.