tools/testing/selftests/cpufreq/main.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/cpufreq/main.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/cpufreq/main.sh
Extension
.sh
Size
4241 bytes
Lines
219
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

source cpu.sh
source cpufreq.sh
source governor.sh
source module.sh
source special-tests.sh

DIR="$(dirname $(readlink -f "$0"))"
source "${DIR}"/../kselftest/ktap_helpers.sh

FUNC=basic	# do basic tests by default
OUTFILE=cpufreq_selftest
SYSFS=
CPUROOT=
CPUFREQROOT=

helpme()
{
	printf "Usage: $0 [-h] [-todg args]
	[-h <help>]
	[-o <output-file-for-dump>]
	[-t <basic: Basic cpufreq testing
	     suspend: suspend/resume,
	     hibernate: hibernate/resume,
	     suspend_rtc: suspend/resume back using the RTC wakeup alarm,
	     hibernate_rtc: hibernate/resume back using the RTC wakeup alarm,
	     modtest: test driver or governor modules. Only to be used with -d or -g options,
	     sptest1: Simple governor switch to produce lockdep.
	     sptest2: Concurrent governor switch to produce lockdep.
	     sptest3: Governor races, shuffle between governors quickly.
	     sptest4: CPU hotplugs with updates to cpufreq files.>]
	[-d <driver's module name: only with \"-t modtest>\"]
	[-g <governor's module name: only with \"-t modtest>\"]
	\n"
	exit "${KSFT_FAIL}"
}

prerequisite()
{
	msg="skip all tests:"

	if [ $UID != 0 ]; then
		ktap_skip_all "$msg must be run as root"
		exit "${KSFT_SKIP}"
	fi

	taskset -p 01 $$

	SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`

	if [ ! -d "$SYSFS" ]; then
		ktap_skip_all "$msg sysfs is not mounted"
		exit "${KSFT_SKIP}"
	fi

	CPUROOT=$SYSFS/devices/system/cpu
	CPUFREQROOT="$CPUROOT/cpufreq"

	if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then
		ktap_skip_all "$msg cpus not available in sysfs"
		exit "${KSFT_SKIP}"
	fi

	if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then
		ktap_skip_all "$msg cpufreq directory not available in sysfs"
		exit "${KSFT_SKIP}"
	fi
}

Annotation

Implementation Notes