xref: /linux/tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc (revision 71e2f4dd5a65bd8dbca0b77661e75eea471168f8)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: ftrace - Max stack tracer
4# Test the basic function of max-stack usage tracing
5
6if [ ! -f stack_trace ]; then
7  echo "Max stack tracer is not supported - please make CONFIG_STACK_TRACER=y"
8  exit_unsupported
9fi
10
11echo > stack_trace_filter
12echo 0 > stack_max_size
13echo 1 > /proc/sys/kernel/stack_tracer_enabled
14
15: "Fork and wait for the first entry become !lock"
16timeout=10
17while [ $timeout -ne 0 ]; do
18  ( echo "forked" )
19  FL=`grep " 0)" stack_trace`
20  echo $FL | grep -q "lock" || break;
21  timeout=$((timeout - 1))
22done
23echo 0 > /proc/sys/kernel/stack_tracer_enabled
24
25echo '*lock*' > stack_trace_filter
26test `cat stack_trace_filter | wc -l` -eq `grep lock stack_trace_filter | wc -l`
27
28echo 0 > stack_max_size
29echo 1 > /proc/sys/kernel/stack_tracer_enabled
30
31: "Fork and always the first entry including lock"
32timeout=10
33while [ $timeout -ne 0 ]; do
34  ( echo "forked" )
35  FL=`grep " 0)" stack_trace`
36  echo $FL | grep -q "lock"
37  timeout=$((timeout - 1))
38done
39echo 0 > /proc/sys/kernel/stack_tracer_enabled
40