jjb: Lava: Add kretprobe fuzzing
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 14 Jul 2017 20:02:56 +0000 (16:02 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 21 Jul 2017 15:42:11 +0000 (11:42 -0400)
This test randomly picks a large set of symbols reported by
/proc/kallsyms and activate --function (kretprobe) on them. This also
has the side-effect of testing kprobe since they are used to implement
kretprobes.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
lava/baremetal-tests/kprobe-fuzzing-tests.yml [new file with mode: 0644]
scripts/lttng-baremetal-tests/kprobe-fuzzing.sh [new file with mode: 0755]
scripts/lttng-baremetal-tests/lava-submit.py

diff --git a/lava/baremetal-tests/kprobe-fuzzing-tests.yml b/lava/baremetal-tests/kprobe-fuzzing-tests.yml
new file mode 100644 (file)
index 0000000..8867683
--- /dev/null
@@ -0,0 +1,22 @@
+metadata:
+        format: Lava-Test Test Definition 1.0
+        name: lttng-fuzzing-kprobe-test
+        description: "Run kprobe fuzzing test suite"
+install:
+        git-repos:
+                - url: https://github.com/lttng/lttng-ci
+                  destination: ci
+                  branch: master
+        steps:
+                - export TMPDIR="/tmp"
+                - cd
+                - ulimit -c unlimited
+                - mkdir -p coredump
+                - echo "$(pwd)/coredump/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern
+run:
+        steps:
+                - source /root/lttngvenv/activate
+                - cd ci/
+                - lava-test-case run-tests --shell "./scripts/lttng-baremetal-tests/kprobe-fuzzing.sh"
+                - tar czf coredump.tar.gz coredump
+                - lava-test-case-attach run-benchmarks coredump.tar.gz
diff --git a/scripts/lttng-baremetal-tests/kprobe-fuzzing.sh b/scripts/lttng-baremetal-tests/kprobe-fuzzing.sh
new file mode 100755 (executable)
index 0000000..254123c
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/bash -xeu
+# 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 as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
+NB_KPROBE_PER_ITER=500
+SESSION_NAME="my_kprobe_session"
+
+# Silence the script to avoid redirection of kallsyms to fill the screen
+set +x
+syms=$(awk '{print $3;}' /proc/kallsyms | sort -R)
+nb_syms=$(echo "$syms" | wc -l)
+set -x
+
+# Loop over the list of symbols and enable the symbols in groups of
+# $NB_KPROBE_PER_ITER
+for i in $(seq 0 "$NB_KPROBE_PER_ITER" "$nb_syms"); do
+       # Pick $NB_KPROBE_PER_ITER symbols to instrument, craft enable-event
+       # command and save them to a file. We craft the commands and executed
+       # them in two steps so that the pipeline can be done without the bash
+       # '-x' option that would fill the serial buffer because of the multiple
+       # pipe redirections.
+       set +x
+       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
+       set -x
+
+       # Print what iteration we are at
+       echo "$i" $((i+NB_KPROBE_PER_ITER))
+
+       # Destroy previous session and create a new one
+       lttng create "$SESSION_NAME"
+
+       # Expect commands to fail, turn off early exit of shell script on
+       # non-zero return value
+       set +e
+       source  ./lttng-enable-event.sh
+       set -e
+
+       # Run stress util to generate some kernel activity
+       stress --cpu 2 --io 4 --vm 2 --vm-bytes 128M --hdd 3 --timeout 5s
+
+       lttng list "$SESSION_NAME"
+       lttng destroy "$SESSION_NAME"
+done
index d2bf1ff9346b60212c15952e3bb3fe289972049c..fc8cd3f267d9b5ce4f36a57e33f2229224ed8cbe 100644 (file)
@@ -157,7 +157,7 @@ def get_config_cmd(build_device):
     packages=['bsdtar', 'psmisc', 'wget', 'python3', 'python3-pip', \
             'libglib2.0-dev', 'libffi-dev', 'elfutils', 'libdw-dev', \
             'libelf-dev', 'libmount-dev', 'libxml2', 'libpfm4-dev', \
-            'libnuma-dev', 'python3-dev', 'swig']
+            'libnuma-dev', 'python3-dev', 'swig', 'stress']
     command = OrderedDict({
         'command': 'lava_command_run',
         'parameters': {
@@ -259,6 +259,11 @@ def get_kvm_tests_cmd():
                     'git-repo': 'https://github.com/lttng/lttng-ci.git',
                     'revision': 'master',
                     'testdef': 'lava/baremetal-tests/destructive-tests.yml'
+                },
+                {
+                    'git-repo': 'https://github.com/lttng/lttng-ci.git',
+                    'revision': 'master',
+                    'testdef': 'lava/baremetal-tests/kprobe-fuzzing-tests.yml'
                 }
                 ],
             'timeout': 18000
This page took 0.025528 seconds and 4 git commands to generate.