2 # SPDX-License-Identifier: GPL-2.0+
4 # the corresponding .litmus.out file, and does not judge the result.
6 # . scripts/parseargs.sh
8 # Include into other Linux kernel tools/memory-model scripts.
10 # Copyright IBM Corporation, 2018
12 # Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
14 T
=/tmp
/parseargs.sh.$$
17 # Initialize one parameter: initparam name default
19 echo if test -z '"$'$1'"' > $T/s
21 echo $1='"'$2'"' >> $T/s
22 echo export $1 >> $T/s
24 echo $1_DEF='$'$1 >> $T/s
28 initparam LKMM_DESTDIR
"."
29 initparam LKMM_HERD_OPTIONS
"-conf linux-kernel.cfg"
30 initparam LKMM_JOBS
`getconf _NPROCESSORS_ONLN`
31 initparam LKMM_PROCS
"3"
32 initparam LKMM_TIMEOUT
"1m"
37 echo "Usage $scriptname [ arguments ]"
38 echo " --destdir path (place for .litmus.out, default by .litmus)"
39 echo " --herdopts -conf linux-kernel.cfg ..."
40 echo " --jobs N (number of jobs, default one per CPU)"
41 echo " --procs N (litmus tests with at most this many processes)"
42 echo " --timeout N (herd7 timeout (e.g., 10s, 1m, 2hr, 1d, '')"
43 echo "Defaults: --destdir '$LKMM_DESTDIR_DEF' --herdopts '$LKMM_HERD_OPTIONS_DEF' --jobs '$LKMM_JOBS_DEF' --procs '$LKMM_PROCS_DEF' --timeout '$LKMM_TIMEOUT_DEF'"
51 # checkarg --argname argtype $# arg mustmatch cannotmatch
55 echo $1 needs argument
$2 matching
\"$5\"
58 if echo "$4" |
grep -q -e "$5"
62 echo $1 $2 \"$4\" must match
\"$5\"
65 if echo "$4" |
grep -q -e "$6"
67 echo $1 $2 \"$4\" must not match
\"$6\"
76 checkarg
--destdir "(path to directory)" "$#" "$2" '.\+' '^--'
78 mkdir
$LKMM_DESTDIR > /dev
/null
2>&1
79 if ! test -e "$LKMM_DESTDIR"
81 echo "Cannot create directory --destdir '$LKMM_DESTDIR'"
84 if test -d "$LKMM_DESTDIR" -a -w "$LKMM_DESTDIR" -a -x "$LKMM_DESTDIR"
88 echo "Directory --destdir '$LKMM_DESTDIR' insufficient permissions to create files"
94 checkarg
--destdir "(herd7 options)" "$#" "$2" '.*' '^--'
95 LKMM_HERD_OPTIONS
="$2"
99 njobs
="`echo $1 | sed -e 's/^-j//'`"
100 trailchars
="`echo $njobs | sed -e 's/[0-9]\+\(.*\)$/\1/'`"
101 if test -n "$trailchars"
103 echo $1 trailing characters
"'$trailchars'"
106 LKMM_JOBS
="`echo $njobs | sed -e 's/^\([0-9]\+\).*$/\1/'`"
109 checkarg
--jobs "(number)" "$#" "$2" '^[1-9][0-9]\+$' '^--'
114 checkarg
--procs "(number)" "$#" "$2" '^[0-9]\+$' '^--'
119 checkarg
--timeout "(timeout spec)" "$#" "$2" '^\([0-9]\+[smhd]\?\|\)$' '^--'
124 echo Unknown argument
$1
130 if test -z "$LKMM_TIMEOUT"
132 LKMM_TIMEOUT_CMD
=""; export LKMM_TIMEOUT_CMD
134 LKMM_TIMEOUT_CMD
="timeout $LKMM_TIMEOUT"; export LKMM_TIMEOUT_CMD