blob: 136838efad83c69acbf2b7c45f9c87b153cc00b2 (
plain) (
tree)
|
|
#! /bin/sh
#
# Process a test template directory into the baseline for a new test
#
toggle()
{
case $1 in
no) echo "yes" ;;
yes) echo "no" ;;
*) fatal "Unknown value to toggle ($1)" ;;
esac
}
check_status()
{
if [ $1 -ne 0 ] ; then
shift
echo "FAILED: " "$*" >&2
exit 1
fi
}
usage()
{
echo "$progname -s SOURCE -d DEST -D description -n NUMBER [-v]"
echo " OR"
echo "$progname -c -d DEST"
cat <<EOF
The first form is to generate a new test.
The second form is to add the new test to CVS.
EOF
exit 1
}
addToCVS=no
source=
dest=
desc=
testNum=
verbose=no
while getopts cd:D:s:n:v OPT
do
case "$OPT" in
c) addToCVS=`toggle ${addToCVS}` ;;
d) dest=$OPTARG ;;
D) desc=$OPTARG ;;
s) source=$OPTARG ;;
n) testNum=$OPTARG ;;
v) verbose=`toggle ${verbose}` ;;
*) usage ;;
esac
done
# Error check
test "X${dest}" != "X"
check_status $? No destination provided
test -r configure.ac
check_status $? Not in test suite directory
if [ ${addToCVS} == yes ] ; then
test -d ${dest}
check_status $? "Cannot add ${dest} -- does not exist"
cvs add ${dest}
cd ${dest}
for f in `ls -1 .cvsignore Makefile.am *.doc *.scn *.[ch] 2>/dev/null`
do
cvs add -kkv ${f}
done
exit 0
fi
test "X${source}" != "X"
check_status $? No source provided
test -d "${source}"
check_status $? Source directory not present
test "X${testNum}" != "X"
check_status $? No test number provided
test ! -d ${dest}/CVS
check_status $? "Are you sure about ${dest}? Already a CVS directory in it"
let $((shiftcount = $OPTIND - 1))
shift #shiftcount
args=$*
destCaps=`echo ${dest} | tr [:lower:] [:upper:]`
echo ${destCaps}
# Process the test
rm -rf ${dest}
check_status $? "Unable to remove ${dest}"
mkdir ${dest}
check_status $? "Unable to make ${dest}"
# all the source code we know about
for s in ${source}/*
do
if [ -r ${s} -a ! -d ${s} ] ; then
b=`basename ${s}`
d=`echo ${dest}/${b} | sed "s/TEST\./${dest}\./"`
echo Processing ${s} to ${d}
sed -e "s/@LOWER@/${dest}/g" \
-e "s/@UPPER@/${destCaps}/g" \
-e "s/@DESC@/${desc}/g" \
-e "s/@TESTNUM@/${testNum}/g" \
<${s} >${d}
check_status $? "Unable to process ${d}"
fi
done
cat <<EOF >${dest}/.cvsignore
Makefile
Makefile.in
EOF
cat <<EOF
You need to add the test to the Makefile.am and configure.ac by hand
before you can build.
You will have to add content to the test itself including screen
and doc files.
EOF
exit 0
|