slitaz-base-files annotate testsuite.sh @ rev 267

httphelper: fix bug with HTTP POST forms where tabs, multiple spaces, and ampersands disappeared.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Apr 22 11:55:25 2015 +0300 (2015-04-22)
parents 259c174621c7
children 3f16616140ea
rev   line source
pankso@125 1 #!/bin/sh
pankso@125 2 #
pankso@125 3 . rootfs/lib/libtaz.sh
pankso@125 4
pankso@136 5 check_libtaz() {
al@221 6 newline; longline "This package provides the base system files and \
al@221 7 directories, it is built using a wok receipt and Cookutils. The creation of \
al@221 8 the initial files are described in the SliTaz Scratchbook: http://www.slitaz.\
al@221 9 org/en/doc/scratchbook/"
al@221 10
al@221 11 newline; boldify Available functions list:
al@221 12 separator
al@221 13 optlist "\
paul@224 14 _ Alias for eval_gettext with newline. Can be used with success both instead of gettext and eval_gettext.
paul@224 15 _n Alias for eval_gettext without newline at end.
al@221 16 get_cols Get width of current terminal emulator or console. Number in columns.
al@221 17 status Output localized short message based on the previous command exit status (0 - OK, other than 0 - error).
al@221 18 separator Line separator for full terminal width.
al@221 19 newline Produces empty line.
al@221 20 boldify Display a bold message.
al@221 21 colorize Color messages for terminal.
al@221 22 indent Jump to specified column, useful for simple tabulated lists (tables).
al@221 23 emsg All-in-one tool that contains: boldify, colorize, newline, separator and indent.
paul@224 24 check_root Check if user has root permissions (logged as root or used su for becoming root) for executing something.
al@221 25 debug Display debug info when --debug is used.
paul@224 26 confirm Used at end of questions - adds '(y/N)?' and waits for answer. Press 'y' if yes, any other letters/words or just Enter - if no.
paul@224 27 Note that 'y' and 'N' can be localized and this function knows about that.
paul@224 28 log Log activities in /var/log/slitaz/libtaz.log (by default) or in specified log file.
al@221 29 optlist Sophisticated, UTF-8 friendly, function to print two-column list of options with descriptions.
paul@224 30 longline Doesn't break words into two lines of terminal when displaying long messages."
al@221 31 separator; newline
al@221 32
al@221 33
pankso@136 34 echo -n "Checking libtaz.sh: status() 0"
pankso@136 35 status
pankso@164 36
pankso@136 37 echo -n "Checking libtaz.sh: status() 1"
pankso@136 38 touch /tmp/1/2/2/4 2>/dev/null
pankso@136 39 status
pankso@164 40
pankso@136 41 echo -n "Checking libtaz.sh: boldify() "
pankso@136 42 boldify "Message"
pankso@164 43
pankso@167 44 echo -n "Checking libtaz.sh: colorize() "
meshca@175 45 echo -n $(colorize 33 "Message ")
meshca@175 46 echo -n $(colorize 35 "Message ")
meshca@175 47 colorize 36 "Message"
pankso@167 48
pankso@136 49 echo "Checking libtaz.sh: separator"
pankso@136 50 separator
al@193 51
al@193 52 echo -n "Checking libtaz.sh: emsg() "
al@193 53 emsg "<b>bold</b> color: <c 31>bold red</c> <c 32>bold green</c> separator:<->newline:<n> message with<i 26>indent"
pankso@136 54 }
pankso@125 55
pankso@170 56 # Usage: check_functions path/to/lib.sh
pankso@170 57 check_functions() {
pankso@170 58 lib=$1
pankso@170 59 echo -n "$(boldify "Checking: $(basename $lib) functions")"
meshca@176 60 indent 34 "$(colorize 32 $(grep "[a-z]() {" $lib | wc -l))"
pankso@170 61 separator
pankso@170 62 grep "[a-z]() {" $lib | while read line
pankso@170 63 do
pankso@170 64 func=`echo "$line" | cut -d '(' -f 1`
pankso@170 65 count=0
pankso@170 66 usage=0
pankso@170 67 echo -n "Checking: ${func}()"
pankso@170 68 for tool in /usr/bin/cook* /usr/bin/taz* /usr/bin/spk* /usr/sbin/spk* \
al@221 69 /sbin/taz* /sbin/hwsetup /var/www/cgi-bin/* /var/www/cooker/*.cgi \
al@221 70 /var/www/tazpanel/*.cgi
pankso@170 71 do
pankso@170 72 [ -x "$tool" ] || continue
pankso@170 73 count=$(grep "$func" $tool | wc -l)
pankso@170 74 usage=$(($usage + $count))
pankso@170 75 done
pankso@170 76 indent 34 "$usage"
pankso@170 77 done
pankso@170 78 separator
pankso@170 79 }
pankso@170 80
pankso@170 81 #clear
pankso@164 82 echo -n "Checking libtaz.sh: log()"
pankso@164 83 activity=/tmp/testsuite.log
pankso@164 84 log "Message from SliTaz testsuite"
pankso@164 85 status
pankso@164 86 cat $activity
pankso@164 87 rm -f $activity
pankso@164 88
pankso@136 89 check_libtaz
pankso@136 90 output="raw"
al@193 91 echo -e "\nChecking libtaz.sh: --output=raw"
pankso@136 92 check_libtaz
pankso@125 93
pankso@170 94 # Check libtaz.sh functions usage
pankso@170 95 output="term"
pankso@170 96 check_functions 'rootfs/lib/libtaz.sh'
pankso@170 97
pankso@170 98 # Check libpkg.sh functions usage
pankso@170 99 check_functions 'rootfs/usr/lib/slitaz/libpkg.sh'
pankso@170 100
pankso@137 101 [ "$forced" ] && echo "Checking option: forced=$forced"
pankso@137 102 [ "$root" ] && echo "Checking option: root=$root"
pankso@137 103 [ ! "$1" ] && echo "Check options: $(basename $0) --forced --root=/dev/null"
pankso@125 104 exit 0