tools/testing/selftests/drivers/net/netdevsim/psample.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/netdevsim/psample.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/netdevsim/psample.sh- Extension
.sh- Size
- 4114 bytes
- Lines
- 184
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function psample_capture
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# This test is for checking the psample module. It makes use of netdevsim
# which periodically generates "sampled" packets.
lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="
psample_enable_test
psample_group_num_test
psample_md_test
"
NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR}
SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/
PSAMPLE_DIR=/sys/kernel/debug/netdevsim/$DEV/psample/
CAPTURE_FILE=$(mktemp)
NUM_NETIFS=0
source $lib_dir/lib.sh
DEVLINK_DEV=
source $lib_dir/devlink_lib.sh
DEVLINK_DEV=netdevsim/${DEV}
# Available at https://github.com/Mellanox/libpsample
require_command psample
psample_capture()
{
rm -f $CAPTURE_FILE
timeout 2 ip netns exec testns1 psample &> $CAPTURE_FILE
}
psample_enable_test()
{
RET=0
echo 1 > $PSAMPLE_DIR/enable
check_err $? "Failed to enable sampling when should not"
echo 1 > $PSAMPLE_DIR/enable 2>/dev/null
check_fail $? "Sampling enablement succeeded when should fail"
psample_capture
if [ $(cat $CAPTURE_FILE | wc -l) -eq 0 ]; then
check_err 1 "Failed to capture sampled packets"
fi
echo 0 > $PSAMPLE_DIR/enable
check_err $? "Failed to disable sampling when should not"
echo 0 > $PSAMPLE_DIR/enable 2>/dev/null
check_fail $? "Sampling disablement succeeded when should fail"
psample_capture
if [ $(cat $CAPTURE_FILE | wc -l) -ne 0 ]; then
check_err 1 "Captured sampled packets when should not"
fi
log_test "psample enable / disable"
}
psample_group_num_test()
{
RET=0
echo 1234 > $PSAMPLE_DIR/group_num
Annotation
- Detected declarations: `function psample_capture`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.