tools/testing/selftests/ptp/phc.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/ptp/phc.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/ptp/phc.sh
Extension
.sh
Size
3108 bytes
Lines
195
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/bash
# SPDX-License-Identifier: GPL-2.0

ALL_TESTS="
	settime
	adjtime
	adjfreq
"
DEV=$1

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

##############################################################################
# Sanity checks

if [[ "$(id -u)" -ne 0 ]]; then
	echo "SKIP: need root privileges"
	exit $ksft_skip
fi

if [[ "$DEV" == "" ]]; then
	echo "SKIP: PTP device not provided"
	exit $ksft_skip
fi

require_command()
{
	local cmd=$1; shift

	if [[ ! -x "$(command -v "$cmd")" ]]; then
		echo "SKIP: $cmd not installed"
		exit $ksft_skip
	fi
}

phc_sanity()
{
	phc_ctl $DEV get &> /dev/null

	if [ $? != 0 ]; then
		echo "SKIP: unknown clock $DEV: No such device"
		exit $ksft_skip
	fi
}

require_command phc_ctl
phc_sanity

##############################################################################
# Helpers

# Exit status to return at the end. Set in case one of the tests fails.
EXIT_STATUS=0
PASS_COUNT=0
# Per-test return value. Clear at the beginning of each test.
RET=0

check_err()
{
	local err=$1

	if [[ $RET -eq 0 && $err -ne 0 ]]; then
		RET=$err
	fi
}

log_test()
{
	local test_name=$1

Annotation

Implementation Notes