tools/testing/selftests/sysctl/sysctl.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/sysctl/sysctl.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/sysctl/sysctl.sh- Extension
.sh- Size
- 22611 bytes
- Lines
- 1100
- 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 allow_user_defaultsfunction check_production_sysctl_writes_strictfunction load_req_modfunction test_numfunction remove_leading_zerosfunction run_all_testsfunction watch_logfunction watch_casefunction test_casefunction parse_args
Annotated Snippet
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later OR copyleft-next-0.3.1
# Copyright (C) 2017 Luis R. Rodriguez <mcgrof@kernel.org>
# This performs a series tests against the proc sysctl interface.
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
TEST_NAME="sysctl"
TEST_DRIVER="test_${TEST_NAME}"
TEST_DIR=$(dirname $0)
TEST_FILE=$(mktemp)
# This represents
#
# TEST_ID:TEST_COUNT:ENABLED:TARGET:SKIP_NO_TARGET
#
# TEST_ID: is the test id number
# TEST_COUNT: number of times we should run the test
# ENABLED: 1 if enabled, 0 otherwise
# TARGET: test target file required on the test_sysctl module
# SKIP_NO_TARGET: 1 skip if TARGET not there
# 0 run even though TARGET not there
#
# Once these are enabled please leave them as-is. Write your own test,
# we have tons of space.
ALL_TESTS="0001:1:1:int_0001:1"
ALL_TESTS="$ALL_TESTS 0002:1:1:string_0001:1"
ALL_TESTS="$ALL_TESTS 0003:1:1:int_0002:1"
ALL_TESTS="$ALL_TESTS 0004:1:1:uint_0001:1"
ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003:1"
ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001:1"
ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int:1"
ALL_TESTS="$ALL_TESTS 0008:1:1:match_int:1"
ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error:0"
ALL_TESTS="$ALL_TESTS 0010:1:1:mnt/mnt_error:0"
ALL_TESTS="$ALL_TESTS 0011:1:1:empty_add:0"
ALL_TESTS="$ALL_TESTS 0012:1:1:u8_valid:0"
function allow_user_defaults()
{
if [ -z $DIR ]; then
DIR="/sys/module/test_sysctl/"
fi
if [ -z $DEFAULT_NUM_TESTS ]; then
DEFAULT_NUM_TESTS=50
fi
if [ -z $SYSCTL ]; then
SYSCTL="/proc/sys/debug/test_sysctl"
fi
if [ -z $PROD_SYSCTL ]; then
PROD_SYSCTL="/proc/sys"
fi
if [ -z $WRITES_STRICT ]; then
WRITES_STRICT="${PROD_SYSCTL}/kernel/sysctl_writes_strict"
fi
}
function check_production_sysctl_writes_strict()
{
echo -n "Checking production write strict setting ... "
if [ ! -e ${WRITES_STRICT} ]; then
echo "FAIL, but skip in case of old kernel" >&2
else
old_strict=$(cat ${WRITES_STRICT})
if [ "$old_strict" = "1" ]; then
echo "OK"
else
echo "FAIL, strict value is 0 but force to 1 to continue" >&2
Annotation
- Detected declarations: `function allow_user_defaults`, `function check_production_sysctl_writes_strict`, `function load_req_mod`, `function test_num`, `function remove_leading_zeros`, `function run_all_tests`, `function watch_log`, `function watch_case`, `function test_case`, `function parse_args`.
- 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.