1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
#!/bin/csh -f
#
# INSTALL_TEST_CSH, csh-kind test launcher for install non-reg suite
# Copyright (C) 2017-2021 Xavier Delaruelle
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##########################################################################
set progpath=$0
set progdir=`dirname $progpath`
if ( "$progdir" == '' ) then
set progdir='.'
endif
set ret=0
if ( $#argv < 4 ) then
# print usage message
echo "Usage: $progpath initfile mode shell command"
exit 1
endif
set initfile="$1"
shift
set mode=$1
shift
set sh=$1
shift
set cmdlist="$*"
# get shell kind and options for sublaunch
set shname=`basename $sh`
switch ($shname)
case bash:
case ksh:
case ksh93:
case zsh:
set shkind='sh'
breaksw
case tcsh:
set shkind='csh'
breaksw
default:
set shkind=$shname
endsw
switch ($shkind)
# ignore global csh system init file to avoid side effect
case csh:
set shopts='-f'
breaksw
default:
set shopts=''
endsw
# init module via autoinit cmd if modulecmd.tcl is initfile
if ( "`basename '$initfile'`" == 'modulecmd.tcl' ) then
set autoinit=0
else
set autoinit=1
endif
if ( $autoinit == 0 && ! -x "$initfile" ) then
echo "ERROR: Cannot execute $initfile"
exit 1
else if ( $autoinit != 0 && ! -r "$initfile" ) then
echo "ERROR: Cannot read $initfile"
exit 1
endif
# source module init file if first step of given mode
if ( "$mode" == 'top' || "$mode" == 'sub' || "$mode" == 'subsub' ) then
if ( $autoinit == 0 ) then
eval "`'$initfile' $shname autoinit`"
else
source "$initfile"
endif
endif
# execute command list or perform recursive call
switch ($mode)
case top:
case launch:
# hardcode single quote test from 080-args to correctly pass the single
# quotes to the module command
set hardcodetest=1
if ( "$cmdlist" == "module load ''" ) then
module load ''
set ret=($ret + $status)
set hardcodetest=0
endif
if ( "$cmdlist" == "module load \'\'" ) then
module load \'\'
set ret=($ret + $status)
set hardcodetest=0
endif
if ( "$cmdlist" == "module append-path -d ' ' FOO /path/to/dir2;module source $TESTSUITEDIR/modulefiles.2/putsvar" ) then
module append-path -d ' ' FOO /path/to/dir2
set ret=($ret + $status)
module source $TESTSUITEDIR/modulefiles.2/putsvar
set ret=($ret + $status)
set hardcodetest=0
endif
if ( "$cmdlist" =~ "*module sh-to-mod *csh testsuite/example/sh-to-mod.csh*" ) then
module sh-to-mod csh testsuite/example/sh-to-mod.csh v\'l val\"e val\\\"e "" >& shtomod;
set ret=($ret + $status)
module load ./shtomod;
set ret=($ret + $status)
echo "${FOOCB}:${FOOEM}:${FOOSP}:${FOOWC}:${FOOARG1}:${FOOARG2}:${FOOARG3}:${FOOARG4}";
set ret=($ret + $status)
alfoo;
set ret=($ret + $status)
alcb;
set ret=($ret + $status)
alsp;
set ret=($ret + $status)
set hardcodetest=0
endif
if ( $hardcodetest != 0 ) then
foreach cmd ("`echo '${cmdlist}' | tr ';' '\n'`")
eval $cmd
set ret=($ret + $status)
end
endif
breaksw
case sub:
case sublaunch:
$sh $shopts $progdir/install_test_${shkind} "$initfile" launch $sh "$cmdlist"
set ret=$status
breaksw
case subsub:
$sh $shopts $progdir/install_test_${shkind} "$initfile" sublaunch $sh "$cmdlist"
set ret=$status
breaksw
default:
echo "ERROR: Unrecognized mode option. Valid mode are 'top', 'sub', 'subsub'"
exit 1
endsw
# throw command exit code
exit $ret
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent:
|