|
Revision 1161, 2.7 kB
(checked in by frisco, 15 months ago)
|
|
Major updates to scripts for unit tests and pydoc
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | GETOPT="getopt" |
|---|
| 13 | BASE_DIR=$(cd "$(dirname $0)/.."; pwd) |
|---|
| 14 | |
|---|
| 15 | export PYTHONPATH=$BASE_DIR/src |
|---|
| 16 | |
|---|
| 17 | disable_filecheck() |
|---|
| 18 | { |
|---|
| 19 | sed -i "s/^OVERRIDE_FILECHECK = .*$/OVERRIDE_FILECHECK = True/" "$BASE_DIR/bin/CryptoBoxRootActions" |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | enable_filecheck() |
|---|
| 23 | { |
|---|
| 24 | sed -i "s/^OVERRIDE_FILECHECK = .*$/OVERRIDE_FILECHECK = False/" "$BASE_DIR/bin/CryptoBoxRootActions" |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | run_tests() |
|---|
| 29 | { |
|---|
| 30 | |
|---|
| 31 | cd "${BASE_DIR}/bin" |
|---|
| 32 | |
|---|
| 33 | disable_filecheck |
|---|
| 34 | |
|---|
| 35 | if test -n "$files" |
|---|
| 36 | then |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | for a in $files |
|---|
| 43 | do eval testoob -v $a |
|---|
| 44 | done |
|---|
| 45 | else |
|---|
| 46 | for a in ${BASE_DIR}/src/cryptobox/tests/test.*.py |
|---|
| 47 | do testoob -v "$a" |
|---|
| 48 | done |
|---|
| 49 | fi |
|---|
| 50 | |
|---|
| 51 | enable_filecheck |
|---|
| 52 | |
|---|
| 53 | return 0 |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | usage() |
|---|
| 58 | { |
|---|
| 59 | echo -e "Usage:" |
|---|
| 60 | echo -e "\tbin/do_unittests.sh --clobber=foo [ files... ]" |
|---|
| 61 | echo -e "\t" |
|---|
| 62 | echo -e "\t(Where \"files\", if given, are absolute pathnames)" |
|---|
| 63 | echo -e "\t(Example: bin/do_unittests.sh --clobber=sdX)" |
|---|
| 64 | echo -e "***Warning: All data on /dev/foo will be DESTROYED!" |
|---|
| 65 | echo -e "\t" |
|---|
| 66 | exit 1 |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | CNAS_UTEST_CLOBBER="" |
|---|
| 74 | files="" |
|---|
| 75 | clobber_dev_arg="" |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | getopt_str=`${GETOPT} -o c: --long clobber: \ |
|---|
| 80 | -n do_unittests.sh -- "$@"` |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | getopt_arr=($getopt_str) |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | if [ "${getopt_arr[0]}" == "--clobber" ] \ |
|---|
| 91 | && [ "${getopt_arr[2]}" == "--" ]; then |
|---|
| 92 | clobber_dev_arg="${getopt_arr[1]}" |
|---|
| 93 | |
|---|
| 94 | clobber_dev_arg="${clobber_dev_arg//\'/}" |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | files="`expr match \"${getopt_str}\" '.*--\(.*\)'`" |
|---|
| 98 | |
|---|
| 99 | if [ -b "/dev/${clobber_dev_arg}" ]; then |
|---|
| 100 | export CNAS_UTEST_CLOBBER="${clobber_dev_arg}" |
|---|
| 101 | |
|---|
| 102 | run_tests |
|---|
| 103 | else |
|---|
| 104 | echo "Error: /dev/${clobber_dev_arg} is not a valid block device" |
|---|
| 105 | exit 2 |
|---|
| 106 | fi |
|---|
| 107 | else |
|---|
| 108 | usage |
|---|
| 109 | fi |
|---|
| 110 | |
|---|
| 111 | |
|---|