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