aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc
blob: 71fa3f49e35e20b7bf36baf74b06813e2d1336f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function trace with cpumask

if ! which nproc ; then
  nproc() {
    ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l
  }
fi

NP=`nproc`

if [ $NP -eq 1 ] ;then
  echo "We can not test cpumask on UP environment"
  exit_unresolved
fi

if ! grep -q "function" available_tracers ; then
  echo "Function trace is not enabled"
  exit_unsupported
fi

ORIG_CPUMASK=`cat tracing_cpumask`

do_reset() {
  echo $ORIG_CPUMASK > tracing_cpumask
}

echo 0 > tracing_on
echo > trace
: "Bitmask only record on CPU1"
echo 2 > tracing_cpumask
MASK=0x`cat tracing_cpumask`
test `printf "%d" $MASK` -eq 2 || do_reset

echo function > current_tracer
echo 1 > tracing_on
(echo "forked")
echo 0 > tracing_on

: "Check CPU1 events are recorded"
grep -q -e "\[001\]" trace || do_reset

: "There should be No other cpu events"
! grep -qv -e "\[001\]" -e "^#" trace || do_reset

do_reset