publishers:
- workspace-cleanup
-- defaults:
- name: vm_tests_fuzzing
- description: |
- Runs virtual machine fuzzing tests over different combination of kernel and lttng configurations.
- project-type: freestyle
- node: 'amd64'
- <<: *system_tests_parameters_defaults
-
- properties:
- - build-discarder:
- num-to-keep: 10
- - throttle:
- max-total: 4
- option: 'category'
- categories:
- - 'kvm-tests'
-
- wrappers:
- - workspace-cleanup
- - timestamps
- - ansicolor
- - credentials-binding:
- - text:
- credential-id: jenkins_lava_key
- variable: LAVA_JENKINS_TOKEN
- - text:
- credential-id: jenkins_lava2_key
- variable: LAVA2_JENKINS_TOKEN
- - inject:
- properties-content: |
- BUILD_DEVICE=kvm
-
- scm:
- - git:
- url: https://github.com/lttng/lttng-ci
- basedir: src/lttng-ci/
-
- builders:
- - shell: !include-raw-escape: scripts/system-tests/generate-properties-master.sh
- - trigger-builds:
- - project: "build_kernel_PARAM"
- property-file: 'properties.txt'
- block: true
- - inject:
- properties-file: properties.txt
- - shell: !include-raw-escape: scripts/system-tests/run-kvm-fuzzing-tests.sh
-
- publishers:
- - workspace-cleanup
-
- defaults:
name: baremetal_tests
description: |
name: baremetal_tests_k{kversion}_l{lttngversion}
defaults: baremetal_tests
-- job-template:
- name: vm_tests_fuzzing_k{kversion}_l{lttngversion}
- defaults: vm_tests_fuzzing
-
# Canary jobs are made to confirm that the whole Lava pipeline is working.
# They are scheduled once a day always on the same (LTTng, Kernel) code. If any
# of those jobs fails, it means that there is an issue with the configuration
- 'baremetal_tests_canary'
- 'baremetal_benchmarks_canary'
-- project:
- name: system-fuzzing-tests
- kversion: master
- lttngversion: master
- jobs:
- - 'vm_tests_fuzzing_k{kversion}_l{lttngversion}'
- project:
name: system-general
test_type:
+++ /dev/null
-metadata:
- format: Lava-Test Test Definition 1.0
- name: lttng-fuzzing-kprobe-generate-data
- description: "Run kprobe fuzzing data generation"
-params:
- RANDOM_SEED: 12345
-run:
- steps:
- - git clone https://github.com/lttng/lttng-ci ci
- - cd ci/
- - lava-test-case generate-fuzzing-data --shell "python3 ./scripts/system-tests/run-kprobe-generate-instr-points.py $RANDOM_SEED"
- - sync
+++ /dev/null
-metadata:
- format: Lava-Test Test Definition 1.0
- name: lttng-fuzzing-kprobe-test
- description: "Run kprobe fuzzing test suite"
-params:
- ROUND_NB: 0
-run:
- steps:
- - git clone https://github.com/lttng/lttng-ci ci
- - lava-test-case run-fuzzing --shell "python3 ./ci/scripts/system-tests/run-kprobe-fuzzing.py /root/instr_points.txt.gz $ROUND_NB"
baremetal_benchmarks = 1
baremetal_tests = 2
kvm_tests = 3
- kvm_fuzzing_tests = 4
values = {
'baremetal-benchmarks': baremetal_benchmarks,
'baremetal-tests': baremetal_tests,
'kvm-tests': kvm_tests,
- 'kvm-fuzzing-tests': kvm_fuzzing_tests,
}
+++ /dev/null
-# Copyright (C) 2018 - 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/>.
-
-import datetime
-import gzip
-import os
-import pprint
-import subprocess
-import sys
-
-NB_KPROBES_PER_ITER=500
-NB_KPROBES_PER_ROUND=20000
-
-def load_instr_points(instr_points_archive):
- print('Reading instrumentation points from \'{}\'.'.format(instr_points_archive), end='')
- sys.stdout.flush()
-
- with gzip.open(instr_points_archive, 'r') as f:
- data = f.read()
- print(' Done.')
-
- return [x.decode('utf-8') for x in data.split()]
-
-def enable_kprobe_events(instr_points):
- print('Enabling events from {} to {}...'.format(instr_points[0], instr_points[-1]), end='')
- sys.stdout.flush()
-
- # Use os module directly, because this is a sysfs file and seeking inside
- # the file is not supported. The python open() function with the append
- # ('a') flag uses lseek(, SEEK_END) to move the write pointer to the end.
- fd = os.open('/sys/kernel/debug/tracing/kprobe_events', os.O_WRONLY|os.O_CREAT|os.O_APPEND)
- for i, point in enumerate(instr_points):
-
- kprobe_cmd = 'r:event_{} {}\n'.format(i, point).encode('utf-8')
- try:
- os.write(fd, kprobe_cmd)
- except OSError:
- continue
- os.close(fd)
- print(' Done.')
-
-def set_kprobe_tracing_state(state):
- if state not in (0 ,1):
- raise ValueError
-
- try:
- with open('/sys/kernel/debug/tracing/events/kprobes/enable', 'w') as enable_kprobe_file:
- enable_kprobe_file.write('{}\n'.format(state))
- except IOError:
- print('kprobes/enable file does not exist')
-
- if state == 0:
- # Clear the content of the trace.
- open('/sys/kernel/debug/tracing/trace', 'w').close()
- # Clear all the events.
- open('/sys/kernel/debug/tracing/kprobe_events', 'w').close()
-
-def run_workload():
- print('Running workload...', end='')
- sys.stdout.flush()
- workload = ['stress', '--cpu', '2', '--io', '4', '--vm', '2',
- '--vm-bytes', '128M', '--hdd', '3', '--timeout', '3s']
- try:
- with open(os.devnull) as devnull:
- subprocess.call(workload, stdout=devnull, stderr=devnull)
- except OSError as e:
- print("Workload execution failed:", e, file=sys.stderr)
- pprint.pprint(workload)
-
- print(' Done.')
-
-def mount_tracingfs():
- with open(os.devnull) as devnull:
- subprocess.call(['mount', '-t', 'debugfs', 'nodev', '/sys/kernel/debug/'],
- stdout=devnull, stderr=devnull)
-
-def print_dashed_line():
- print('-'*100)
-
-def main():
- assert(len(sys.argv) == 3)
-
- instr_point_archive = sys.argv[1]
- round_nb = int(sys.argv[2])
- # Load instrumentation points to disk and attach it to lava test run.
- instrumentation_points = load_instr_points(instr_point_archive)
-
- # We are past the end of the instrumentation point list.
- if len(instrumentation_points)/NB_KPROBES_PER_ROUND <= round_nb:
- print('No instrumentation point for round {}.'.format(round_nb))
- return
-
- mount_tracingfs()
-
- # Loop over the list by enabling ranges of NB_KPROBES_PER_ITER kprobes.
- for i in range(int(NB_KPROBES_PER_ROUND/NB_KPROBES_PER_ITER)):
- print_dashed_line()
- lower_bound = (round_nb * NB_KPROBES_PER_ROUND) + (i * NB_KPROBES_PER_ITER)
- upper_bound = lower_bound + NB_KPROBES_PER_ITER
- print('Time now: {}, {} to {}'.format(datetime.datetime.now(), lower_bound , upper_bound))
- enable_kprobe_events(instrumentation_points[lower_bound:upper_bound])
- set_kprobe_tracing_state(1)
- run_workload()
- print('\n')
- set_kprobe_tracing_state(0)
-
-if __name__ == "__main__":
- main()
+++ /dev/null
-# Copyright (C) 2018 - 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/>.
-
-import datetime
-import gzip
-import os
-import pprint
-import random
-import subprocess
-import sys
-
-def save_instr_points(instr_points):
-
- # Save in /root to be persistent across lava slave reboots.
- instrumenation_points_arch = '/root/instr_points.txt.gz'
-
- print('Saving instrumentation points to \'{}\' ...'.format(instrumenation_points_arch), end='')
- sys.stdout.flush()
-
- text = "\n".join(instr_points)
-
- with gzip.open(instrumenation_points_arch, 'w') as f:
- f.write(text.encode('utf-8'))
-
- # Attach fuzzing data to test case.
- events = ['lava-test-case-attach', 'generate-fuzzing-data', instrumenation_points_arch]
-
- try:
- subprocess.call(events)
- except OSError as e:
- print("Execution failed:", e, file=sys.stderr)
- print("Probably not running on the lava worker")
- pprint.pprint(events)
- print('Done.')
-
-def main():
- assert(len(sys.argv) == 2)
-
- seed = int(sys.argv[1])
- print('Random seed: {}'.format(seed))
-
- rng = random.Random(seed)
-
- # Get all the symbols from kallsyms.
- with open('/proc/kallsyms') as kallsyms_file:
- raw_symbol_list = kallsyms_file.readlines()
-
- # Keep only the symbol name.
- symbol_list = []
- for symbol in raw_symbol_list:
- symbol = symbol.split()[2].strip()
- if 'ftrace' not in symbol:
- symbol_list.append(symbol)
-
- instrumentation_points = []
-
- # Add all symbols.
- instrumentation_points.extend(symbol_list)
-
- # For each symbol, create 2 new instrumentation points by random offsets.
- for s in symbol_list:
- offsets = rng.sample(range(1, 10), 2)
- for offset in offsets:
- instrumentation_points.append(s + "+" + str(hex(offset)))
-
- lower_bound = 0x0
- upper_bound = 0xffffffffffffffff
- address_list = []
-
- # Add random addresses to the instrumentation points.
- for _ in range(1000):
- instrumentation_points.append(hex(rng.randint(lower_bound, upper_bound)))
-
- # Shuffle the entire list.
- rng.shuffle(instrumentation_points)
-
- # Save instrumentation points to disk and attach it to lava test run.
- save_instr_points(instrumentation_points)
-
-if __name__ == "__main__":
- main()
+++ /dev/null
-#!/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/>.
-
-echo 'At this point, we built the modules and kernel if we needed to.'
-echo 'We can now launch the lava job using those artefacts'
-
-venv=$(mktemp -d)
-virtualenv -p python3 "$venv"
-set +eu
-source "${venv}/bin/activate"
-set -eu
-pip install pyyaml Jinja2
-
-python -u "$LTTNG_CI_PATH"/scripts/system-tests/lava2-submit.py \
- -t kvm-fuzzing-tests \
- -j "$JOB_NAME" \
- -k "$S3_URL_KERNEL_IMAGE" \
- -lm "$S3_URL_LTTNG_MODULES" \
- -tu "$LTTNG_TOOLS_REPO" \
- -uu "$LTTNG_UST_REPO" \
- -tc "$LTTNG_TOOLS_COMMIT_ID" \
- -uc "$LTTNG_UST_COMMIT_ID" \
- -id "$BUILD_TAG"
-
-set +eu
-deactivate
-set -eu
-rm -rf "$venv"
configurationOfInterest.each { lttngBr, linuxBr ->
def jobName = CraftJobName(jobType, linuxBr, lttngBr);
currentJobs[jobName] = CraftConfig(linuxBr, lttngBr);
-
- // Add fuzzing job in vm_tests on master branches of lttng and linux.
- //if (jobType == 'vm_tests' && lttngBr == 'master' && linuxBr == 'master') {
- // def vmFuzzingJobName = CraftJobName(jobType + '_fuzzing', linuxBr, lttngBr);
- // currentJobs[vmFuzzingJobName] = CraftConfig(linuxBr, lttngBr);
- //}
}
//Add canary job
currentJobs.each { jobName, jobInfo ->
// If the job ran in the past, we check if the IDs changed since.
- // Fetch past results only if the job is not of type canary or fuzzing.
- if (!jobName.contains('_canary') && !jobName.contains('_fuzzing') &&
- pastJobs.containsKey(jobName) &&
+ // Fetch past results only if the job is not of type canary.
+ if (!jobName.contains('_canary') && pastJobs.containsKey(jobName) &&
build.getBuildVariables().get('FORCE_JOB_RUN') == 'false') {
pastJob = pastJobs[jobName];
metadata:
jenkins_jobname: {{ job_name }}
-{% if test_type == TestType.kvm_fuzzing_tests %}
- nb_iterations: {{ kprobe_round_nb }}
-{% endif %}
actions:
- apt-get update
- apt-get upgrade
- apt-get install -y systemtap-sdt-dev
- {% if test_type != TestType.kvm_fuzzing_tests %}
- pip3 install --upgrade pip
- hash -r
- pip3 install vlttng
- {{ vlttng_cmd }}
- ln -s {{ vlttng_path }} /root/lttngvenv
- sync
- {% endif %}
from: inline
name: x86-env-setup-inline
path: inline/x86-env-setup.yaml
name: destructive-tests
params:
JENKINS_BUILD_ID: {{ jenkins_build_id }}
- {% elif test_type == TestType.kvm_fuzzing_tests %}
- - repository: https://github.com/lttng/lttng-ci.git
- from: git
- path: lava/system-tests/kprobe-fuzzing-generate-data.yml
- name: kprobe-fuzzing-generate-data
- params:
- RANDOM_SEED: {{ random_seed }}
- {% for i in range(kprobe_round_nb) %}
- - repository: https://github.com/lttng/lttng-ci.git
- from: git
- path: lava/system-tests/kprobe-fuzzing-tests.yml
- name: kprobe-fuzzing-tests{{ i }}
- params:
- ROUND_NB: {{ i }}
- {% endfor %}
{% endif %}