~straemer/ubuntu/quantal/update-manager/fix-for-1058070

« back to all changes in this revision

Viewing changes to DistUpgrade/base-installer/kernel/tests/runtests

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2012-06-29 10:59:30 UTC
  • mfrom: (389.1.2 precise-security)
  • Revision ID: package-import@ubuntu.com-20120629105930-0oaj9vdvykmvkjum
Tags: 1:0.165
* Implementation of "update on start" feature from spec
  https://wiki.ubuntu.com/SoftwareUpdates
* Use a single main window that changes instead of having modal dialogs
* Implement several special-purpose dialogs like "No updates" or
  "Dist upgrade needed" accordingn to the above spec
* Split out release upgrader code and DistUpgrade module into a separate
  source package
* Drop python-update-manager, as it is unused
* debian/tests:
  - Add dep8 tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
set -e
3
 
 
4
 
if [ -z "$1" ]; then
5
 
        echo "Usage: runtests <architecture>" >&2
6
 
        exit 1
7
 
fi
8
 
 
9
 
ARCH="$1"
10
 
PASSES=0
11
 
FAILURES=0
12
 
 
13
 
[ "$TEST_VERBOSE" ] || export TEST_VERBOSE=1
14
 
 
15
 
verbose () {
16
 
        if [ "$TEST_VERBOSE" -ge 2 ]; then
17
 
                echo "$@"
18
 
        fi
19
 
        eval "$@"
20
 
}
21
 
 
22
 
# Run a test based on a test file.
23
 
run_test () {
24
 
        TEST="$1"
25
 
 
26
 
        unset SUBARCH CPUINFO MACHINE FLAVOUR KERNEL_26 KERNEL_7 KERNEL_8 USABLE UNUSABLE \
27
 
                || true
28
 
        NUMCPUS=1
29
 
        MAJORS=2.6
30
 
 
31
 
        while read name value; do
32
 
                case $name in
33
 
                        subarch)
34
 
                                SUBARCH="$value"
35
 
                                ;;
36
 
                        cpuinfo)
37
 
                                CPUINFO="${TEST%/*}/$value"
38
 
                                ;;
39
 
                        numcpus)
40
 
                                NUMCPUS="$value"
41
 
                                ;;
42
 
                        machine)
43
 
                                MACHINE="$value"
44
 
                                ;;
45
 
                        majors)
46
 
                                MAJORS="$value"
47
 
                                ;;
48
 
                        flavour)
49
 
                                FLAVOUR="$value"
50
 
                                ;;
51
 
                        kernel-2.6)
52
 
                                KERNEL_26="$value"
53
 
                                ;;
54
 
                        kernel-7)
55
 
                                KERNEL_7="$value"
56
 
                                ;;
57
 
                        kernel-8)
58
 
                                KERNEL_8="$value"
59
 
                                ;;
60
 
                        usable)
61
 
                                USABLE="$value"
62
 
                                ;;
63
 
                        unusable)
64
 
                                UNUSABLE="$value"
65
 
                                ;;
66
 
                        env)
67
 
                                # TODO: is there any quote-safe way to do
68
 
                                # this?
69
 
                                eval "export ${value%% *}='${value#* }'"
70
 
                                ;;
71
 
                esac
72
 
        done < "$TEST"
73
 
 
74
 
        export ARCH SUBARCH CPUINFO NUMCPUS MACHINE
75
 
        export MAJORS FLAVOUR KERNEL_26 KERNEL_7 KERNEL_8
76
 
        export USABLE UNUSABLE
77
 
 
78
 
        TMP="$(mktemp -t base-installer-tests.XXXXXX)"
79
 
        trap 'rm -f "$TMP"' 0 HUP INT QUIT TERM
80
 
 
81
 
        # Run the actual testset.
82
 
        verbose ./dotest >"$TMP"
83
 
 
84
 
        # Massage testset output into a more useful form.
85
 
        while read state message; do
86
 
                case "$state" in
87
 
                        PASS)
88
 
                                PASSES="$(($PASSES + 1))"
89
 
                                ;;
90
 
                        FAIL)
91
 
                                FAILURES="$(($FAILURES + 1))"
92
 
                                ;;
93
 
                esac
94
 
                if [ "$state" != PASS ] || [ "$TEST_VERBOSE" -ge 2 ]; then
95
 
                        echo "$state $TEST $message"
96
 
                fi
97
 
        done <"$TMP"
98
 
        rm -f "$TMP"
99
 
        trap 0 HUP INT QUIT TERM
100
 
}
101
 
 
102
 
if [ "$2" ]; then
103
 
        ONETEST="$2"
104
 
        run_test "$ONETEST"
105
 
else
106
 
        for test in "$ARCH"/*.test; do
107
 
                # Sanity check: check test file for incorrect line continuations
108
 
                if ! awk 'BEGIN {lc=0}
109
 
                          /\\[[:space:]]*$/ {if (lc==1 && substr($0,1,1)!=" ") {exit 1}; lc=1}
110
 
                          /[^\\][:space:]*$/ {lc=0}
111
 
                          END {if (lc==1) {exit 1}}' $test
112
 
                then
113
 
                        echo "Incorrect line continuation in test file '$test'"
114
 
                        exit 1
115
 
                fi
116
 
                run_test "$test"
117
 
        done
118
 
fi
119
 
 
120
 
if [ "$TEST_VERBOSE" -ge 1 ]; then
121
 
        echo "$ARCH: $PASSES passes, $FAILURES failures."
122
 
fi
123
 
 
124
 
if [ "$FAILURES" -eq 0 ]; then
125
 
        exit 0
126
 
else
127
 
        exit 1
128
 
fi