jjb: lava: rename lttng-baremetal-tests to system-tests
[lttng-ci.git] / scripts / system-tests / kprobe-fuzzing.sh
CommitLineData
30b89c1f
FD
1#!/bin/bash -xeu
2# Copyright (C) 2017 - Francis Deslauriers <francis.deslauriers@efficios.com>
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17NB_KPROBE_PER_ITER=500
18SESSION_NAME="my_kprobe_session"
19
20# Silence the script to avoid redirection of kallsyms to fill the screen
21set +x
22syms=$(awk '{print $3;}' /proc/kallsyms | sort -R)
23nb_syms=$(echo "$syms" | wc -l)
24set -x
25
26# Loop over the list of symbols and enable the symbols in groups of
27# $NB_KPROBE_PER_ITER
28for i in $(seq 0 "$NB_KPROBE_PER_ITER" "$nb_syms"); do
99d75d63
FD
29 # Print time in UTC at each iteration to easily see when the script
30 # hangs
31 date --utc
32
30b89c1f
FD
33 # Pick $NB_KPROBE_PER_ITER symbols to instrument, craft enable-event
34 # command and save them to a file. We craft the commands and executed
35 # them in two steps so that the pipeline can be done without the bash
36 # '-x' option that would fill the serial buffer because of the multiple
37 # pipe redirections.
38 set +x
39 echo "$syms" | head -n $((i+NB_KPROBE_PER_ITER)) | tail -n $NB_KPROBE_PER_ITER |awk '{print "lttng enable-event --kernel --function=" $1 " " $1}' > lttng-enable-event.sh
40 set -x
41
42 # Print what iteration we are at
43 echo "$i" $((i+NB_KPROBE_PER_ITER))
44
45 # Destroy previous session and create a new one
46 lttng create "$SESSION_NAME"
47
48 # Expect commands to fail, turn off early exit of shell script on
49 # non-zero return value
50 set +e
51 source ./lttng-enable-event.sh
52 set -e
53
54 # Run stress util to generate some kernel activity
55 stress --cpu 2 --io 4 --vm 2 --vm-bytes 128M --hdd 3 --timeout 5s
56
57 lttng list "$SESSION_NAME"
58 lttng destroy "$SESSION_NAME"
59done
This page took 0.023631 seconds and 4 git commands to generate.