File: run-tests.sh

package info (click to toggle)
backup-manager 0.7.7-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,284 kB
  • ctags: 202
  • sloc: sh: 3,711; perl: 978; makefile: 220
file content (56 lines) | stat: -rwxr-xr-x 1,011 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

set -e
# set -x

function count()
{
    total=$(($total + 1))
}

function test_failure()
{
    file="$1"
    nb_failure=$(($nb_failure + 1))
    echo "failed"

}

function test_success()
{
    file="$1"
    nb_success=$(($nb_success + 1))
    echo "ok"
}

# the conffile to test
if [[ -f ./backup-manager.conf ]]; then
    conffile="./backup-manager.conf"
    source $conffile
    source $libdir/sanitize.sh
    init_default_vars
fi

total=0
nb_failure=0
# Now process the tests
for file in t[0-9][0-9]*.sh
do
        count
        echo -n "[t $total] Running test $file: "
        
        if /bin/bash $file 2>/dev/null; then
            test_success $file
        else
            test_failure $file
        fi              
done

echo "------------------------------------------------------------------------------"
pct_success=$(($nb_success * 100 / $total))
echo "Success score: $pct_success% ($nb_success/$total)"
if [[ "$nb_failure" -gt 0 ]]; then
    echo "Failed tests: $nb_failure"
fi