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