slitaz-base-files annotate testsuite.sh @ rev 299
/etc/profile: use applications.conf
(Use variable BROWSER to open links from Sakura terminal)
(Use variable BROWSER to open links from Sakura terminal)
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Mar 25 00:03:56 2016 +0200 (2016-03-25) |
parents | 3a790a182103 |
children | 65248d132cd2 |
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@271 | 11 |
al@271 | 12 title 'Available functions list:' |
al@271 | 13 |
al@221 | 14 optlist "\ |
al@271 | 15 _ Alias for gettext function with newline. Can be used with success both instead of gettext and eval_gettext. |
al@271 | 16 _n Alias for gettext function without newline at end. |
al@271 | 17 _p Alias for plural gettext function. |
al@221 | 18 get_cols Get width of current terminal emulator or console. Number in columns. |
al@221 | 19 status Output localized short message based on the previous command exit status (0 - OK, other than 0 - error). |
al@221 | 20 separator Line separator for full terminal width. |
al@221 | 21 newline Produces empty line. |
al@221 | 22 boldify Display a bold message. |
al@221 | 23 colorize Color messages for terminal. |
al@221 | 24 indent Jump to specified column, useful for simple tabulated lists (tables). |
al@221 | 25 emsg All-in-one tool that contains: boldify, colorize, newline, separator and indent. |
paul@224 | 26 check_root Check if user has root permissions (logged as root or used su for becoming root) for executing something. |
al@221 | 27 debug Display debug info when --debug is used. |
paul@224 | 28 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 | 29 Note that 'y' and 'N' can be localized and this function knows about that. |
paul@224 | 30 log Log activities in /var/log/slitaz/libtaz.log (by default) or in specified log file. |
al@221 | 31 optlist Sophisticated, UTF-8 friendly, function to print two-column list of options with descriptions. |
al@271 | 32 longline Doesn't break words into two lines of terminal when displaying long messages. |
al@271 | 33 title Print localized title. |
al@271 | 34 footer Print footer. |
al@271 | 35 action Print action. |
al@271 | 36 itemize Print long line as list item, check for markers: colon (:), dash (-), and asterisk (*)." |
al@271 | 37 separator '~'; newline |
al@221 | 38 |
al@221 | 39 |
al@271 | 40 action 'Checking libtaz.sh: status() 0' |
pankso@136 | 41 status |
pankso@164 | 42 |
al@271 | 43 action 'Checking libtaz.sh: status() 1' |
pankso@136 | 44 touch /tmp/1/2/2/4 2>/dev/null |
pankso@136 | 45 status |
pankso@164 | 46 |
al@271 | 47 action 'Checking libtaz.sh: boldify() ' |
pankso@136 | 48 boldify "Message" |
pankso@164 | 49 |
al@271 | 50 action 'Checking libtaz.sh: colorize() ' |
meshca@175 | 51 echo -n $(colorize 33 "Message ") |
meshca@175 | 52 echo -n $(colorize 35 "Message ") |
meshca@175 | 53 colorize 36 "Message" |
pankso@167 | 54 |
al@271 | 55 action 'Checking libtaz.sh: separator'; newline |
pankso@136 | 56 separator |
al@193 | 57 |
al@271 | 58 action 'Checking libtaz.sh: emsg() ' |
al@271 | 59 emsg '<b>bold</b> color: <c 31>bold red</c> <c 32>bold green</c> separator:<->newline:<n> message with<i 26>indent' |
al@271 | 60 |
al@271 | 61 itemize "Fish: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed\ |
al@271 | 62 do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad mini\ |
al@271 | 63 m veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commo\ |
al@271 | 64 do consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse ci\ |
al@271 | 65 llum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non pro\ |
al@271 | 66 ident, sunt in culpa qui officia deserunt mollit anim id est laborum." |
al@271 | 67 |
al@271 | 68 newline |
al@271 | 69 |
al@271 | 70 itemize " * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed d\ |
al@271 | 71 o eiusmod tempor incididunt ut labore et dolore magna aliqua." |
al@271 | 72 itemize " * Ut enim ad minim veniam, quis nostrud exercitation ullamco lab\ |
al@271 | 73 oris nisi ut aliquip ex ea commodo consequat." |
al@271 | 74 itemize " * Duis aute irure dolor in reprehenderit in voluptate velit esse\ |
al@271 | 75 cillum dolore eu fugiat nulla pariatur." |
al@271 | 76 itemize " * Excepteur sint occaecat cupidatat non proident, sunt in culpa \ |
al@271 | 77 qui officia deserunt mollit anim id est laborum." |
al@271 | 78 |
al@271 | 79 |
al@271 | 80 newline; echo 'Using itemize() in the tazpkg:' |
al@271 | 81 tazpkg info gtk+ |
al@279 | 82 |
al@279 | 83 title "$(emsg '<c 31>C<c 32>o<c 33>l<c 34>o<c 35>r<c 36>s</c>')" |
al@279 | 84 for i in $(seq 0 7); do |
al@279 | 85 case $i in |
al@279 | 86 0) c='Gray ';; |
al@279 | 87 1) c='Red ';; |
al@279 | 88 2) c='Green ';; |
al@279 | 89 3) c='Yellow ';; |
al@279 | 90 4) c='Blue ';; |
al@279 | 91 5) c='Magenta';; |
al@279 | 92 6) c='Cyan ';; |
al@279 | 93 7) c='White ';; |
al@279 | 94 esac |
al@279 | 95 echo -n "$c " |
al@279 | 96 echo -n "$(colorize "03$i" "03$i") $(colorize "3$i" "3$i") " # test `colorize`: fg |
al@279 | 97 echo -n "$(colorize "04$i" "04$i") $(colorize "4$i" "4$i") " # test `colorize`: bg |
al@279 | 98 echo -n ": " |
al@279 | 99 emsg "<c 03$i>03$i $c</c> <c 3$i>3$i Bold $c</c> <c 04$i>04$i $c</c> <c 4$i>4$i Bold $c</c>" # test `emsg` |
al@279 | 100 done |
pankso@136 | 101 } |
pankso@125 | 102 |
pankso@170 | 103 # Usage: check_functions path/to/lib.sh |
pankso@170 | 104 check_functions() { |
al@271 | 105 lib="$1" |
pankso@170 | 106 echo -n "$(boldify "Checking: $(basename $lib) functions")" |
al@271 | 107 indent 34 "$(colorize 32 $(grep "[a-z_]() {" $lib | wc -l))" |
pankso@170 | 108 separator |
al@271 | 109 grep "[a-z_]() *{" $lib | while read line; do |
al@271 | 110 func=`echo "$line" | cut -d'(' -f1` |
al@271 | 111 count='0' |
al@271 | 112 usage='0' |
pankso@170 | 113 for tool in /usr/bin/cook* /usr/bin/taz* /usr/bin/spk* /usr/sbin/spk* \ |
al@221 | 114 /sbin/taz* /sbin/hwsetup /var/www/cgi-bin/* /var/www/cooker/*.cgi \ |
al@221 | 115 /var/www/tazpanel/*.cgi |
pankso@170 | 116 do |
pankso@170 | 117 [ -x "$tool" ] || continue |
al@271 | 118 count=$(grep "$func[^a-z]" $tool | wc -l) |
pankso@170 | 119 usage=$(($usage + $count)) |
pankso@170 | 120 done |
al@271 | 121 printf '%-34s%4d\n' "Checking: ${func}()" "$usage" |
pankso@170 | 122 done |
pankso@170 | 123 separator |
pankso@170 | 124 } |
pankso@170 | 125 |
pankso@170 | 126 #clear |
al@271 | 127 action 'Checking libtaz.sh: log()' |
al@271 | 128 activity='/tmp/testsuite.log' |
al@271 | 129 log 'Message from SliTaz testsuite' |
pankso@164 | 130 status |
pankso@164 | 131 cat $activity |
pankso@164 | 132 rm -f $activity |
pankso@164 | 133 |
al@289 | 134 for output in '' raw gtk html; do |
al@289 | 135 export output |
al@289 | 136 newline; newline |
al@289 | 137 title 'Checking libtaz.sh: --output=$output' |
al@289 | 138 check_libtaz |
al@289 | 139 done |
pankso@125 | 140 |
pankso@170 | 141 # Check libtaz.sh functions usage |
al@271 | 142 output='term' |
pankso@170 | 143 check_functions 'rootfs/lib/libtaz.sh' |
pankso@170 | 144 |
pankso@170 | 145 # Check libpkg.sh functions usage |
pankso@170 | 146 check_functions 'rootfs/usr/lib/slitaz/libpkg.sh' |
pankso@170 | 147 |
al@271 | 148 [ -n "$forced" ] && echo "Checking option: forced=$forced" |
al@271 | 149 [ -n "$root" ] && echo "Checking option: root=$root" |
al@271 | 150 [ -z "$1" ] && echo "Check options: $(basename $0) --forced --root=/dev/null" |
pankso@125 | 151 exit 0 |