1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# description: event trigger - test poll wait on histogram 4# requires: set_event events/sched/sched_process_free/trigger events/sched/sched_process_free/hist 5# flags: instance 6 7POLL=${FTRACETEST_ROOT}/poll 8 9if [ ! -x ${POLL} ]; then 10 echo "poll program is not compiled!" 11 exit_unresolved 12fi 13 14EVENT=events/sched/sched_process_free/ 15 16# Check poll ops is supported. Before implementing poll on hist file, it 17# returns soon with POLLIN | POLLOUT, but not POLLPRI. 18 19# This must wait >1 sec and return 1 (timeout). 20set +e 21${POLL} -I -t 1000 ${EVENT}/hist 22ret=$? 23set -e 24if [ ${ret} != 1 ]; then 25 echo "poll on hist file is not supported" 26 exit_unsupported 27fi 28 29# Test POLLIN 30echo > trace 31echo 'hist:key=comm if comm =="sleep"' > ${EVENT}/trigger 32echo 1 > ${EVENT}/enable 33 34# This sleep command will exit after 2 seconds. 35sleep 2 & 36BGPID=$! 37# if timeout happens, poll returns 1. 38${POLL} -I -t 4000 ${EVENT}/hist 39echo 0 > tracing_on 40 41if [ -d /proc/${BGPID} ]; then 42 echo "poll exits too soon" 43 kill -KILL ${BGPID} ||: 44 exit_fail 45fi 46 47if ! grep -qw "sleep" trace; then 48 echo "poll exits before event happens" 49 exit_fail 50fi 51 52# Test POLLPRI 53echo > trace 54echo 1 > tracing_on 55 56# This sleep command will exit after 2 seconds. 57sleep 2 & 58BGPID=$! 59# if timeout happens, poll returns 1. 60${POLL} -P -t 4000 ${EVENT}/hist 61echo 0 > tracing_on 62 63if [ -d /proc/${BGPID} ]; then 64 echo "poll exits too soon" 65 kill -KILL ${BGPID} ||: 66 exit_fail 67fi 68 69if ! grep -qw "sleep" trace; then 70 echo "poll exits before event happens" 71 exit_fail 72fi 73 74exit_pass 75