tools/testing/selftests/ftrace/test.d/remotes/reset.tc

Source file repositories/reference/linux-study-clean/tools/testing/selftests/ftrace/test.d/remotes/reset.tc

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/ftrace/test.d/remotes/reset.tc
Extension
.tc
Size
1867 bytes
Lines
91
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 trace remote reset
# requires: remotes/test

. $TEST_DIR/remotes/functions

check_reset()
{
    write_event_path="write_event"
    taskset=""

    clear_trace

    # Is the buffer empty?
    output=$(dump_trace_pipe)
    test $(wc -l $output | cut -d ' ' -f1) -eq 0

    if $(echo $(pwd) | grep -q "per_cpu/cpu"); then
        write_event_path="../../write_event"
        cpu_id=$(echo $(pwd) | sed -e 's/.*per_cpu\/cpu//')
        taskset="taskset -c $cpu_id"
    fi
    rm $output

    # Can we properly write a new event?
    $taskset echo 7890 > $write_event_path
    output=$(dump_trace_pipe)
    test $(wc -l $output | cut -d ' ' -f1) -eq 1
    grep -q "id=7890" $output
    rm $output
}

test_global_interface()
{
    output=$(mktemp $TMPDIR/remote_test.XXXXXX)

    # Confidence check
    echo 123456 > write_event
    output=$(dump_trace_pipe)
    grep -q "id=123456" $output
    rm $output

    # Reset single event
    echo 1 > write_event
    check_reset

    # Reset lost events
    for i in $(seq 1 10000); do
        echo 1 > write_event
    done
    check_reset
}

test_percpu_interface()
{
    [ "$(get_cpu_ids | wc -l)" -ge 2 ] || return 0

    for cpu in $(get_cpu_ids); do
        taskset -c $cpu echo 1 > write_event
    done

    check_non_empty=0
    for cpu in $(get_cpu_ids); do
        cd per_cpu/cpu$cpu/

        if [ $check_non_empty -eq 0 ]; then
            check_reset
            check_non_empty=1
        else

Annotation

Implementation Notes