~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/memory-model/scripts/parseargs.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/memory-model/scripts/parseargs.sh (Version linux-6.11.5) and /tools/memory-model/scripts/parseargs.sh (Version linux-6.3.13)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0+                 2 # SPDX-License-Identifier: GPL-2.0+
  3 #                                                   3 #
  4 # Parse arguments common to the various script !!   4 # the corresponding .litmus.out file, and does not judge the result.
  5 #                                                   5 #
  6 # . scripts/parseargs.sh                            6 # . scripts/parseargs.sh
  7 #                                                   7 #
  8 # Include into other Linux kernel tools/memory      8 # Include into other Linux kernel tools/memory-model scripts.
  9 #                                                   9 #
 10 # Copyright IBM Corporation, 2018                  10 # Copyright IBM Corporation, 2018
 11 #                                                  11 #
 12 # Author: Paul E. McKenney <paulmck@linux.ibm.c !!  12 # Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
 13                                                    13 
 14 T=/tmp/parseargs.sh.$$                             14 T=/tmp/parseargs.sh.$$
 15 mkdir $T                                           15 mkdir $T
 16                                                    16 
 17 # Initialize one parameter: initparam name def     17 # Initialize one parameter: initparam name default
 18 initparam () {                                     18 initparam () {
 19         echo if test -z '"$'$1'"' > $T/s           19         echo if test -z '"$'$1'"' > $T/s
 20         echo then >> $T/s                          20         echo then >> $T/s
 21         echo    $1='"'$2'"' >> $T/s                21         echo    $1='"'$2'"' >> $T/s
 22         echo    export $1 >> $T/s                  22         echo    export $1 >> $T/s
 23         echo fi >> $T/s                            23         echo fi >> $T/s
 24         echo $1_DEF='$'$1  >> $T/s                 24         echo $1_DEF='$'$1  >> $T/s
 25         . $T/s                                     25         . $T/s
 26 }                                                  26 }
 27                                                    27 
 28 initparam LKMM_DESTDIR "."                         28 initparam LKMM_DESTDIR "."
 29 initparam LKMM_HERD_OPTIONS "-conf linux-kerne     29 initparam LKMM_HERD_OPTIONS "-conf linux-kernel.cfg"
 30 initparam LKMM_HW_MAP_FILE ""                  << 
 31 initparam LKMM_JOBS `getconf _NPROCESSORS_ONLN     30 initparam LKMM_JOBS `getconf _NPROCESSORS_ONLN`
 32 initparam LKMM_PROCS "3"                           31 initparam LKMM_PROCS "3"
 33 initparam LKMM_TIMEOUT "1m"                        32 initparam LKMM_TIMEOUT "1m"
 34                                                    33 
 35 scriptname=$0                                      34 scriptname=$0
 36                                                    35 
 37 usagehelp () {                                     36 usagehelp () {
 38         echo "Usage $scriptname [ arguments ]"     37         echo "Usage $scriptname [ arguments ]"
 39         echo "      --destdir path (place for      38         echo "      --destdir path (place for .litmus.out, default by .litmus)"
 40         echo "      --herdopts -conf linux-ker     39         echo "      --herdopts -conf linux-kernel.cfg ..."
 41         echo "      --hw AArch64"              << 
 42         echo "      --jobs N (number of jobs,      40         echo "      --jobs N (number of jobs, default one per CPU)"
 43         echo "      --procs N (litmus tests wi     41         echo "      --procs N (litmus tests with at most this many processes)"
 44         echo "      --timeout N (herd7 timeout     42         echo "      --timeout N (herd7 timeout (e.g., 10s, 1m, 2hr, 1d, '')"
 45         echo "Defaults: --destdir '$LKMM_DESTD !!  43         echo "Defaults: --destdir '$LKMM_DESTDIR_DEF' --herdopts '$LKMM_HERD_OPTIONS_DEF' --jobs '$LKMM_JOBS_DEF' --procs '$LKMM_PROCS_DEF' --timeout '$LKMM_TIMEOUT_DEF'"
 46         exit 1                                     44         exit 1
 47 }                                                  45 }
 48                                                    46 
 49 usage () {                                         47 usage () {
 50         usagehelp 1>&2                             48         usagehelp 1>&2
 51 }                                                  49 }
 52                                                    50 
 53 # checkarg --argname argtype $# arg mustmatch      51 # checkarg --argname argtype $# arg mustmatch cannotmatch
 54 checkarg () {                                      52 checkarg () {
 55         if test $3 -le 1                           53         if test $3 -le 1
 56         then                                       54         then
 57                 echo $1 needs argument $2 matc     55                 echo $1 needs argument $2 matching \"$5\"
 58                 usage                              56                 usage
 59         fi                                         57         fi
 60         if echo "$4" | grep -q -e "$5"             58         if echo "$4" | grep -q -e "$5"
 61         then                                       59         then
 62                 :                                  60                 :
 63         else                                       61         else
 64                 echo $1 $2 \"$4\" must match \     62                 echo $1 $2 \"$4\" must match \"$5\"
 65                 usage                              63                 usage
 66         fi                                         64         fi
 67         if echo "$4" | grep -q -e "$6"             65         if echo "$4" | grep -q -e "$6"
 68         then                                       66         then
 69                 echo $1 $2 \"$4\" must not mat     67                 echo $1 $2 \"$4\" must not match \"$6\"
 70                 usage                              68                 usage
 71         fi                                         69         fi
 72 }                                                  70 }
 73                                                    71 
 74 while test $# -gt 0                                72 while test $# -gt 0
 75 do                                                 73 do
 76         case "$1" in                               74         case "$1" in
 77         --destdir)                                 75         --destdir)
 78                 checkarg --destdir "(path to d     76                 checkarg --destdir "(path to directory)" "$#" "$2" '.\+' '^--'
 79                 LKMM_DESTDIR="$2"                  77                 LKMM_DESTDIR="$2"
 80                 mkdir $LKMM_DESTDIR > /dev/nul     78                 mkdir $LKMM_DESTDIR > /dev/null 2>&1
 81                 if ! test -e "$LKMM_DESTDIR"       79                 if ! test -e "$LKMM_DESTDIR"
 82                 then                               80                 then
 83                         echo "Cannot create di     81                         echo "Cannot create directory --destdir '$LKMM_DESTDIR'"
 84                         usage                      82                         usage
 85                 fi                                 83                 fi
 86                 if test -d "$LKMM_DESTDIR" -a  !!  84                 if test -d "$LKMM_DESTDIR" -a -w "$LKMM_DESTDIR" -a -x "$LKMM_DESTDIR"
 87                 then                               85                 then
 88                         :                          86                         :
 89                 else                               87                 else
 90                         echo "Directory --dest     88                         echo "Directory --destdir '$LKMM_DESTDIR' insufficient permissions to create files"
 91                         usage                      89                         usage
 92                 fi                                 90                 fi
 93                 shift                              91                 shift
 94                 ;;                                 92                 ;;
 95         --herdopts|--herdopt)                      93         --herdopts|--herdopt)
 96                 checkarg --destdir "(herd7 opt     94                 checkarg --destdir "(herd7 options)" "$#" "$2" '.*' '^--'
 97                 LKMM_HERD_OPTIONS="$2"             95                 LKMM_HERD_OPTIONS="$2"
 98                 shift                              96                 shift
 99                 ;;                                 97                 ;;
100         --hw)                                  << 
101                 checkarg --hw "(.map file arch << 
102                 LKMM_HW_MAP_FILE="$2"          << 
103                 shift                          << 
104                 ;;                             << 
105         -j[1-9]*)                                  98         -j[1-9]*)
106                 njobs="`echo $1 | sed -e 's/^-     99                 njobs="`echo $1 | sed -e 's/^-j//'`"
107                 trailchars="`echo $njobs | sed    100                 trailchars="`echo $njobs | sed -e 's/[0-9]\+\(.*\)$/\1/'`"
108                 if test -n "$trailchars"          101                 if test -n "$trailchars"
109                 then                              102                 then
110                         echo $1 trailing chara    103                         echo $1 trailing characters "'$trailchars'"
111                         usagehelp                 104                         usagehelp
112                 fi                                105                 fi
113                 LKMM_JOBS="`echo $njobs | sed     106                 LKMM_JOBS="`echo $njobs | sed -e 's/^\([0-9]\+\).*$/\1/'`"
114                 ;;                                107                 ;;
115         --jobs|--job|-j)                          108         --jobs|--job|-j)
116                 checkarg --jobs "(number)" "$# !! 109                 checkarg --jobs "(number)" "$#" "$2" '^[1-9][0-9]\+$' '^--'
117                 LKMM_JOBS="$2"                    110                 LKMM_JOBS="$2"
118                 shift                             111                 shift
119                 ;;                                112                 ;;
120         --procs|--proc)                           113         --procs|--proc)
121                 checkarg --procs "(number)" "$    114                 checkarg --procs "(number)" "$#" "$2" '^[0-9]\+$' '^--'
122                 LKMM_PROCS="$2"                   115                 LKMM_PROCS="$2"
123                 shift                             116                 shift
124                 ;;                                117                 ;;
125         --timeout)                                118         --timeout)
126                 checkarg --timeout "(timeout s    119                 checkarg --timeout "(timeout spec)" "$#" "$2" '^\([0-9]\+[smhd]\?\|\)$' '^--'
127                 LKMM_TIMEOUT="$2"                 120                 LKMM_TIMEOUT="$2"
128                 shift                             121                 shift
129                 ;;                             << 
130         --)                                    << 
131                 shift                          << 
132                 break                          << 
133                 ;;                                122                 ;;
134         *)                                        123         *)
135                 echo Unknown argument $1          124                 echo Unknown argument $1
136                 usage                             125                 usage
137                 ;;                                126                 ;;
138         esac                                      127         esac
139         shift                                     128         shift
140 done                                              129 done
141 if test -z "$LKMM_TIMEOUT"                        130 if test -z "$LKMM_TIMEOUT"
142 then                                              131 then
143         LKMM_TIMEOUT_CMD=""; export LKMM_TIMEO    132         LKMM_TIMEOUT_CMD=""; export LKMM_TIMEOUT_CMD
144 else                                              133 else
145         LKMM_TIMEOUT_CMD="timeout $LKMM_TIMEOU    134         LKMM_TIMEOUT_CMD="timeout $LKMM_TIMEOUT"; export LKMM_TIMEOUT_CMD
146 fi                                                135 fi
147 rm -rf $T                                         136 rm -rf $T
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php