tools/memory-model/scripts/parseargs.sh

Source file repositories/reference/linux-study-clean/tools/memory-model/scripts/parseargs.sh

File Facts

System
Linux kernel
Corpus path
tools/memory-model/scripts/parseargs.sh
Extension
.sh
Size
3332 bytes
Lines
148
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+
#
# Parse arguments common to the various scripts.
#
# . scripts/parseargs.sh
#
# Include into other Linux kernel tools/memory-model scripts.
#
# Copyright IBM Corporation, 2018
#
# Author: Paul E. McKenney <paulmck@linux.ibm.com>

T=/tmp/parseargs.sh.$$
mkdir $T

# Initialize one parameter: initparam name default
initparam () {
	echo if test -z '"$'$1'"' > $T/s
	echo then >> $T/s
	echo	$1='"'$2'"' >> $T/s
	echo	export $1 >> $T/s
	echo fi >> $T/s
	echo $1_DEF='$'$1  >> $T/s
	. $T/s
}

initparam LKMM_DESTDIR "."
initparam LKMM_HERD_OPTIONS "-conf linux-kernel.cfg"
initparam LKMM_HW_MAP_FILE ""
initparam LKMM_JOBS `getconf _NPROCESSORS_ONLN`
initparam LKMM_PROCS "3"
initparam LKMM_TIMEOUT "1m"

scriptname=$0

usagehelp () {
	echo "Usage $scriptname [ arguments ]"
	echo "      --destdir path (place for .litmus.out, default by .litmus)"
	echo "      --herdopts -conf linux-kernel.cfg ..."
	echo "      --hw AArch64"
	echo "      --jobs N (number of jobs, default one per CPU)"
	echo "      --procs N (litmus tests with at most this many processes)"
	echo "      --timeout N (herd7 timeout (e.g., 10s, 1m, 2hr, 1d, '')"
	echo "Defaults: --destdir '$LKMM_DESTDIR_DEF' --herdopts '$LKMM_HERD_OPTIONS_DEF' --hw '$LKMM_HW_MAP_FILE' --jobs '$LKMM_JOBS_DEF' --procs '$LKMM_PROCS_DEF' --timeout '$LKMM_TIMEOUT_DEF'"
	exit 1
}

usage () {
	usagehelp 1>&2
}

# checkarg --argname argtype $# arg mustmatch cannotmatch
checkarg () {
	if test $3 -le 1
	then
		echo $1 needs argument $2 matching \"$5\"
		usage
	fi
	if echo "$4" | grep -q -e "$5"
	then
		:
	else
		echo $1 $2 \"$4\" must match \"$5\"
		usage
	fi
	if echo "$4" | grep -q -e "$6"
	then
		echo $1 $2 \"$4\" must not match \"$6\"
		usage

Annotation

Implementation Notes