trigger-synthetic-event-syntax.tc 2.0 KB
Newer Older
1 2 3
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: event trigger - test synthetic_events syntax parser
4
# requires: set_event synthetic_events
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

do_reset() {
    reset_trigger
    echo > set_event
    clear_trace
}

fail() { #msg
    do_reset
    echo $1
    exit_fail
}

reset_tracer
do_reset

echo "Test synthetic_events syntax parser"

echo > synthetic_events

# synthetic event must have a field
! echo "myevent" >> synthetic_events
echo "myevent u64 var1" >> synthetic_events

# synthetic event must be found in synthetic_events
grep "myevent[[:space:]]u64 var1" synthetic_events

# it is not possible to add same name event
! echo "myevent u64 var2" >> synthetic_events

# Non-append open will cleanup all events and add new one
echo "myevent u64 var2" > synthetic_events

# multiple fields with different spaces
echo "myevent u64 var1; u64 var2;" > synthetic_events
grep "myevent[[:space:]]u64 var1; u64 var2" synthetic_events
echo "myevent u64 var1 ; u64 var2 ;" > synthetic_events
grep "myevent[[:space:]]u64 var1; u64 var2" synthetic_events
echo "myevent u64 var1 ;u64 var2" > synthetic_events
grep "myevent[[:space:]]u64 var1; u64 var2" synthetic_events

# test field types
echo "myevent u32 var" > synthetic_events
echo "myevent u16 var" > synthetic_events
echo "myevent u8 var" > synthetic_events
echo "myevent s64 var" > synthetic_events
echo "myevent s32 var" > synthetic_events
echo "myevent s16 var" > synthetic_events
echo "myevent s8 var" > synthetic_events

echo "myevent char var" > synthetic_events
echo "myevent int var" > synthetic_events
echo "myevent long var" > synthetic_events
echo "myevent pid_t var" > synthetic_events

echo "myevent unsigned char var" > synthetic_events
echo "myevent unsigned int var" > synthetic_events
echo "myevent unsigned long var" > synthetic_events
grep "myevent[[:space:]]unsigned long var" synthetic_events

# test string type
echo "myevent char var[10]" > synthetic_events
grep "myevent[[:space:]]char\[10\] var" synthetic_events

do_reset

exit 0