Merge pull request #42 from frdeso/lava_fuzzing_multi_iter
authorJonathan Rajotte Julien <jonathan.rajotte-julien@efficios.com>
Thu, 15 Mar 2018 18:59:28 +0000 (14:59 -0400)
committerGitHub <noreply@github.com>
Thu, 15 Mar 2018 18:59:28 +0000 (14:59 -0400)
jjb: lava: kprobe-fuzzing: Split testcase into multiple independent ones

lava/system-tests/kprobe-fuzzing-generate-data.yml
lava/system-tests/kprobe-fuzzing-tests.yml
scripts/system-tests/lava-submit.py
scripts/system-tests/run-kprobe-fuzzing.py

index d9d5e4964570df79b23f1b253d23669c963e8aea..cc4b3e3241b03a191f5ef19207e07b5e8bef1d7f 100644 (file)
@@ -7,8 +7,10 @@ install:
                 - url: https://github.com/lttng/lttng-ci
                   destination: ci
                   branch: master
+params:
+  RANDOM_SEED=12345
 run:
         steps:
                 - cd ci/
-                - lava-test-case generate-fuzzing-data --shell "python3 ./scripts/system-tests/run-kprobe-generate-instr-points.py $((1 + RANDOM))"
+                - lava-test-case generate-fuzzing-data --shell "python3 ./scripts/system-tests/run-kprobe-generate-instr-points.py $RANDOM_SEED"
                 - sync
index 56812bac329b6896227e3905875f07bf3d420c10..a0bce4a41094cc77618922ff0cb7e0acf72b3b29 100644 (file)
@@ -12,10 +12,12 @@ install:
                 - ulimit -c unlimited
                 - mkdir -p coredump
                 - echo "$(pwd)/coredump/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern
+params:
+  ROUND_NB: 0
 run:
         steps:
                 - cd ci/
-                - lava-test-case run-fuzzing --shell "python3 ./scripts/system-tests/run-kprobe-fuzzing.py /root/instr_points.txt.gz"
+                - lava-test-case run-fuzzing --shell "python3 ./scripts/system-tests/run-kprobe-fuzzing.py /root/instr_points.txt.gz $ROUND_NB"
                 - cd ..
                 - tar czf coredump.tar.gz coredump
                 - lava-test-case-attach run-fuzzing coredump.tar.gz
index 62df12b171bbd39d9b0fd89d3327a9e7573f4ffc..7de270335a1e47a03eaaaa2efbded257b023e872 100644 (file)
@@ -18,6 +18,7 @@ import argparse
 import base64
 import json
 import os
+import random
 import sys
 import time
 import xmlrpc.client
@@ -269,6 +270,7 @@ def get_kvm_tests_cmd():
     return command
 
 def get_kprobes_generate_data_cmd():
+    random_seed = random.randint(0, 1000000)
     command = OrderedDict({
         'command': 'lava_test_shell',
         'parameters': {
@@ -276,7 +278,8 @@ def get_kprobes_generate_data_cmd():
                 {
                     'git-repo': 'https://github.com/lttng/lttng-ci.git',
                     'revision': 'master',
-                    'testdef': 'lava/system-tests/kprobe-fuzzing-generate-data.yml'
+                    'testdef': 'lava/system-tests/kprobe-fuzzing-generate-data.yml',
+                    'parameters': { 'RANDOM_SEED': str(random_seed) }
                 }
                 ],
             'timeout': 60
@@ -284,7 +287,7 @@ def get_kprobes_generate_data_cmd():
         })
     return command
 
-def get_kprobes_test_cmd():
+def get_kprobes_test_cmd(round_nb):
     command = OrderedDict({
         'command': 'lava_test_shell',
         'parameters': {
@@ -292,10 +295,11 @@ def get_kprobes_test_cmd():
                 {
                     'git-repo': 'https://github.com/lttng/lttng-ci.git',
                     'revision': 'master',
-                    'testdef': 'lava/system-tests/kprobe-fuzzing-tests.yml'
+                    'testdef': 'lava/system-tests/kprobe-fuzzing-tests.yml',
+                    'parameters': { 'ROUND_NB': str(round_nb) }
                 }
-                ],
-            'timeout': 7200
+            ],
+            'timeout': 1000
             }
         })
     return command
@@ -464,7 +468,8 @@ def main():
             return -1
         j['actions'].append(get_config_cmd('kvm'))
         j['actions'].append(get_kprobes_generate_data_cmd())
-        j['actions'].append(get_kprobes_test_cmd())
+        for i in range(10):
+            j['actions'].append(get_kprobes_test_cmd(round_nb=i))
         j['actions'].append(get_results_cmd(stream_name='tests-kernel'))
     else:
         assert False, 'Unknown test type'
index 9e4a2a017e0e880758cef4f082a4e3f08e7c8ec3..3c7c7668741efb73dfe96f433202debc75b37957 100644 (file)
@@ -21,6 +21,7 @@ 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='')
@@ -54,16 +55,18 @@ def set_kprobe_tracing_state(state):
     if state not in (0 ,1):
         raise ValueError
 
-    if state == 0:
-        # Clear the content of the trace.
-        open('/sys/kernel/debug/tracing/trace', 'w').close()
-
     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()
@@ -87,23 +90,31 @@ def print_dashed_line():
     print('-'*100)
 
 def main():
-    assert(len(sys.argv) == 2)
+    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(len(instrumentation_points)/NB_KPROBES_PER_ITER)):
+    for i in range(int(NB_KPROBES_PER_ROUND/NB_KPROBES_PER_ITER)):
         print_dashed_line()
-        print('Time now: {}, {} to {}'.format(datetime.datetime.now(), i*NB_KPROBES_PER_ITER, (i+1)*NB_KPROBES_PER_ITER))
-        set_kprobe_tracing_state(0)
-        enable_kprobe_events(instrumentation_points[i*NB_KPROBES_PER_ITER:(i+1)*NB_KPROBES_PER_ITER])
+        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()
This page took 0.026868 seconds and 4 git commands to generate.