1#!/bin/sh 2# description: Test creation and deletion of trace instances while setting an event 3 4if [ ! -d instances ] ; then 5 echo "no instance directory with this kernel" 6 exit_unsupported; 7fi 8 9fail() { # mesg 10 rmdir foo 2>/dev/null 11 echo $1 12 set -e 13 exit $FAIL 14} 15 16cd instances 17 18# we don't want to fail on error 19set +e 20 21mkdir x 22rmdir x 23result=$? 24 25if [ $result -ne 0 ]; then 26 echo "instance rmdir not supported" 27 exit_unsupported 28fi 29 30instance_slam() { 31 while :; do 32 mkdir foo 2> /dev/null 33 rmdir foo 2> /dev/null 34 done 35} 36 37instance_read() { 38 while :; do 39 cat foo/trace 1> /dev/null 2>&1 40 done 41} 42 43instance_set() { 44 while :; do 45 echo 1 > foo/events/sched/sched_switch 46 done 2> /dev/null 47} 48 49instance_slam & 50p1=$! 51echo $p1 52 53instance_set & 54p2=$! 55echo $p2 56 57instance_read & 58p3=$! 59echo $p3 60 61sleep 1 62 63kill -1 $p3 64kill -1 $p2 65kill -1 $p1 66 67echo "Wait for processes to finish" 68wait $p1 $p2 $p3 69echo "all processes finished, wait for cleanup" 70sleep 1 71 72mkdir foo 73ls foo > /dev/null 74rmdir foo 75if [ -d foo ]; then 76 fail "foo still exists" 77fi 78 79mkdir foo 80echo "schedule:enable_event:sched:sched_switch" > foo/set_ftrace_filter 81rmdir foo 82if [ -d foo ]; then 83 fail "foo still exists" 84fi 85if grep -q "schedule:enable_event:sched:sched_switch" ../set_ftrace_filter; then 86 echo "Older kernel detected. Cleanup filter" 87 echo '!schedule:enable_event:sched:sched_switch' > ../set_ftrace_filter 88fi 89 90instance_slam() { 91 while :; do 92 mkdir x 93 mkdir y 94 mkdir z 95 rmdir x 96 rmdir y 97 rmdir z 98 done 2>/dev/null 99} 100 101instance_slam & 102p1=$! 103echo $p1 104 105instance_slam & 106p2=$! 107echo $p2 108 109instance_slam & 110p3=$! 111echo $p3 112 113instance_slam & 114p4=$! 115echo $p4 116 117instance_slam & 118p5=$! 119echo $p5 120 121ls -lR >/dev/null 122sleep 1 123 124kill -1 $p1 125kill -1 $p2 126kill -1 $p3 127kill -1 $p4 128kill -1 $p5 129 130echo "Wait for processes to finish" 131wait $p1 $p2 $p3 $p4 $p5 132echo "all processes finished, wait for cleanup" 133 134mkdir x y z 135ls x y z 136rmdir x y z 137for d in x y z; do 138 if [ -d $d ]; then 139 fail "instance $d still exists" 140 fi 141done 142 143set -e 144 145exit 0 146