File: test.sh

package info (click to toggle)
shtool 2.0.8-9
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 808 kB
  • ctags: 12
  • sloc: perl: 399; makefile: 110; sh: 42
file content (75 lines) | stat: -rw-r--r-- 2,327 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
##
##  test.sh -- GNU shtool test suite driver
##  Copyright (c) 1999-2008 Ralf S. Engelschall <rse@engelschall.com>
##
##  This file is part of shtool and free software; you can redistribute
##  it and/or modify it under the terms of the GNU General Public
##  License as published by the Free Software Foundation; either version
##  2 of the License, or (at your option) any later version.
##
##  This file is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
##  General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program; if not, write to the Free Software
##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
##

shtool=../shtool
testdb=../test.db

#   move to a subdirectory
rm -rf test.sd >/dev/null 2>&1
mkdir test.sd || exit 1
cd test.sd || exit 1

#   make sure the tool and database exists
test -f $shtool || exit 1
test -f $testdb || exit 1

#   iterate over all tool tests
TOOLS=`grep '^@begin' $testdb | sed -e 's/^@begin{//' -e 's/}.*$//'`
failed=0
passed=0
ran=0
for tool in $TOOLS; do
    rm -rf ./* >/dev/null 2>&1
    echo "${tool}..............." | awk '{ printf("%s", substr($0, 0, 15)); }'
    sed -e "/^@begin{$tool}/,/^@end{$tool}/p" -e '1,$d' $testdb |\
    sed -e '/^@begin/d' -e '/^@end/d' \
        -e 's/\([^\\]\)[ 	]*$/\1 || exit 1/g' \
        -e "s;shtool;$shtool;g" >run.sh
    echo "exit 0" >>run.sh
    sh -x run.sh >run.log 2>&1
    if [ $? -ne 0 ]; then
        #   generate report
        echo "FAILED"
        echo "+---Test------------------------------"
        cat run.sh | sed -e 's/^/| /g'
        echo "+---Trace-----------------------------"
        cat run.log | sed -e 's/^/| /g'
        failed=`expr $failed + 1`
        echo "+-------------------------------------"
    else
        passed=`expr $passed + 1`
        echo "ok"
    fi
    ran=`expr $ran + 1`
done

#   cleanup
cd ..
rm -rf test.sd >/dev/null 2>&1

#   result
if [ $failed -gt 0 ]; then
    echo "FAILED: passed: $passed/$ran, failed: $failed/$ran"
else
    echo "OK: passed: $passed/$ran"
fi
exit 0