summaryrefslogtreecommitdiffstats
path: root/doc/skeleton.sh
blob: 22a7cc2cdca6d1c63ad35cf7940810bbc9854537 (plain)
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
#!/bin/bash

result=unkown
ANIMALS=42
PENGUINS=0

get_result () {
    if [ $? -eq "0" ]; then
        echo "pass"
    else
        echo "fail"
    fi
}

get_animals_count() {
    echo $ANIMALS
}

get_penguins_count() {
    echo $PENGUINS
}

echo "My test skeleton"

set -x

# Reporting commands results as they get executed
lava-test-set start print-to-log
echo "Hello"
result=$(get_result)
lava-test-case echo-hello --result $result
echo "Bye !"
result=$(get_result)
lava-test-case echo-bye --result $result
ls
result=$(get_result)
lava-test-case ls --result $result
lava-test-set stop print-to-log

set +x

# Reporting constant tests
lava-test-set start constant
lava-test-case always-pass --result pass
lava-test-case always-fail --result fail
lava-test-set stop constant

# Animals custom testing
animals_count=$(get_animals_count)
if [ $animals_count -ne 0 ]; then
    result_animals=pass
else
    result_animals=fail
fi
penguins_count=$(get_penguins_count)
if [ $penguins_count -ne 0 ]; then
    result_penguins=pass
else
    result_penguins=fail
fi

# Reporting of animals tests
lava-test-set start animals-measure
lava-test-case any-animals --result $result_animals --measurement $animals_count --units animals
lava-test-case any-penguins --result $result_penguins --measurement $penguins_count --units penguins
lava-test-set stop animals-measure

exit 0