tools/testing/selftests/ftrace/test.d/instances/instance-event.tc

Source file repositories/reference/linux-study-clean/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
Extension
.tc
Size
2096 bytes
Lines
143
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Test creation and deletion of trace instances while setting an event
# requires: instances

fail() { # mesg
    rmdir foo 2>/dev/null
    echo $1
    set -e
    exit_fail
}

cd instances

# we don't want to fail on error
set +e

mkdir x
rmdir x
result=$?

if [ $result -ne 0 ]; then
    echo "instance rmdir not supported"
    exit_unsupported
fi

instance_slam() {
        while :; do
                mkdir foo 2> /dev/null
                rmdir foo 2> /dev/null
        done
}

instance_read() {
        while :; do
                cat foo/trace 1> /dev/null 2>&1
        done
}

instance_set() {
        while :; do
                echo 1 > foo/events/sched/sched_switch/enable
        done 2> /dev/null
}

instance_slam &
p1=$!
echo $p1

instance_set &
p2=$!
echo $p2

instance_read &
p3=$!
echo $p3

sleep 1

kill -1 $p3
kill -1 $p2
kill -1 $p1

echo "Wait for processes to finish"
wait $p1 $p2 $p3
echo "all processes finished, wait for cleanup"
sleep 1

mkdir foo
ls foo > /dev/null

Annotation

Implementation Notes