Major updates to scripts for unit tests and pydoc

This commit is contained in:
frisco 2009-06-06 23:24:26 +00:00
parent 9cd3d7dd42
commit 2e8609b0d2
2 changed files with 124 additions and 64 deletions

View file

@ -1,5 +1,5 @@
#!/bin/sh
#do_unittests.sh
#
# run this script _before_ you do a commit and fix errors before uploading
#
@ -24,51 +24,89 @@ enable_filecheck()
sed -i "s/^OVERRIDE_FILECHECK = .*$/OVERRIDE_FILECHECK = False/" "$BASE_DIR/bin/CryptoBoxRootActions"
}
#Using getopt(1) would be the super-thorough way to do this; use the
#quick-and-dirty method instead
# case $1 in
# --clobber=*)
# TEST_DISK=`echo $1 | sed 's/[-a-zA-Z0-9]*=//'`
# ;;
# *)
# ;;
#
#esac
#parse out the remaining command line arguments
## now check that TEST_DISK is not empty and is a block device (more flexibility could possibly be added)
####################################################################3
##Attention!!! Don't check this in with the following variable set!
##
## the "/dev/" prefix is already assumed by the test classes
#CNAS_UTEST_CLOBBER="sdb"
CNAS_UTEST_CLOBBER=""
export CNAS_UTEST_CLOBBER
dest_files=""
while test $# -gt 0
do files="${files} $(cd $(dirname $1); pwd)/$(basename $1)"
shift
done
# chdir to 'bin' - all config settings depend on this
cd "${BASE_DIR}/bin"
disable_filecheck
if test -n "$files"
then # do the specified tests
run_tests()
{
# chdir to 'bin' - all config settings depend on this
cd "${BASE_DIR}/bin"
disable_filecheck
if test -n "$files"
then # do the specified tests
##The use of "eval", plus not using double quotes for
##$a below are
##required because getopt already puts argument names in
##single-quotes, and the script will not work with both sets
##of quotes.
for a in $files
do testoob -v "$a"
done
else # do all tests
do eval testoob -v $a
done
else # do all tests
for a in ${BASE_DIR}/src/cryptobox/tests/test.*.py
do testoob -v "$a"
done
fi
do testoob -v "$a"
done
fi
enable_filecheck
return 0
}
usage()
{
echo -e "Usage:"
echo -e "\tbin/do_unittests.sh --clobber=foo [ files... ]"
echo -e "\t"
echo -e "\t(Where \"files\", if given, are absolute pathnames)"
echo -e "\t(Example: bin/do_unittests.sh --clobber=sdX)"
echo -e "***Warning: All data on /dev/foo will be DESTROYED!"
echo -e "\t"
exit 1
}
##### main() section #####
##Declare global variables with empty contents
CNAS_UTEST_CLOBBER=""
files=""
clobber_dev_arg=""
##Use the getopt command line utility to simplify parsing
getopt_str=`${GETOPT} -o c: --long clobber: \
-n do_unittests.sh -- "$@"`
#echo $getopt_str
##Assign the tokens to an array
getopt_arr=($getopt_str)
##Note: Output of getopt in this script should look like:
## --clobber 'sdX' -- file1 file2 file3 ...
##Read the following code with that in mind.
##If there is exactly one option, and it has an argument
if [ "${getopt_arr[0]}" == "--clobber" ] \
&& [ "${getopt_arr[2]}" == "--" ]; then
clobber_dev_arg="${getopt_arr[1]}"
##Strip any single quotes from the device name
clobber_dev_arg="${clobber_dev_arg//\'/}"
#echo ${clobber_dev_arg}
##Grab the part of $getopt_str that follows "--"
files="`expr match \"${getopt_str}\" '.*--\(.*\)'`"
#echo $files
if [ -b "/dev/${clobber_dev_arg}" ]; then
export CNAS_UTEST_CLOBBER="${clobber_dev_arg}"
##Run the tests using testoob...
run_tests
else
echo "Error: /dev/${clobber_dev_arg} is not a valid block device"
exit 2
fi
else
usage
fi
enable_filecheck