• Steven Rostedt's avatar
    tracing/events: add startup tests for events · e6187007
    Steven Rostedt authored
    As events start to become popular, and the new way to add tracing
    infrastructure into ftrace, it is important to catch any problems
    that might happen with a mistake in the TRACE_EVENT macro.
    
    This patch introduces a startup self test on the registered trace
    events. Note, it can only do a generic test, any type of testing that
    needs more involement is needed to be implemented by the tracepoint
    creators.
    
    The test goes down one by one enabling a trace point and running
    some random tasks (random in the sense that I just made them up).
    Those tasks are creating threads, grabbing mutexes and spinlocks
    and using workqueues.
    
    After testing each event individually, it does the same test after
    enabling each system of trace points. Like sched, irq, lockdep.
    
    Then finally it enables all tracepoints and performs the tasks again.
    The output to the console on bootup will look like this when everything
    works:
    
    Running tests on trace events:
    Testing event kfree_skb: OK
    Testing event kmalloc: OK
    Testing event kmem_cache_alloc: OK
    Testing event kmalloc_node: OK
    Testing event kmem_cache_alloc_node: OK
    Testing event kfree: OK
    Testing event kmem_cache_free: OK
    Testing event irq_handler_exit: OK
    Testing event irq_handler_entry: OK
    Testing event softirq_entry: OK
    Testing event softirq_exit: OK
    Testing event lock_acquire: OK
    Testing event lock_release: OK
    Testing event sched_kthread_stop: OK
    Testing event sched_kthread_stop_ret: OK
    Testing event sched_wait_task: OK
    Testing event sched_wakeup: OK
    Testing event sched_wakeup_new: OK
    Testing event sched_switch: OK
    Testing event sched_migrate_task: OK
    Testing event sched_process_free: OK
    Testing event sched_process_exit: OK
    Testing event sched_process_wait: OK
    Testing event sched_process_fork: OK
    Testing event sched_signal_send: OK
    Running tests on trace event systems:
    Testing event system skb: OK
    Testing event system kmem: OK
    Testing event system irq: OK
    Testing event system lockdep: OK
    Testing event system sched: OK
    Running tests on all trace events:
    Testing all events: OK
    
    [ folded in:
    
      tracing: add #include <linux/delay.h> to fix build failure in test_work()
    
      This build failure occured on a few rare configs:
    
       kernel/trace/trace_events.c: In function ‘test_work’:
       kernel/trace/trace_events.c:975: error: implicit declaration of function ‘udelay’
       kernel/trace/trace_events.c:980: error: implicit declaration of function ‘msleep’
    
      delay.h is included in way too many other headers, hiding cases
      where new usage is added without header inclusion.
    
      [ Impact: build fix ]
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    ]
    
    [ Impact: add event tracer self-tests ]
    Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    e6187007
trace_events.c 21.4 KB