~ubuntu-branches/ubuntu/saucy/devscripts/saucy

« back to all changes in this revision

Viewing changes to test/bashisms/unknown-fns.sh

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung, Christoph Berg, James McCoy, Dmitry Smirnov, Paul Wise, Benjamin Drung, Cyril Brulebois, Tony Mancill, David Prévot, Josselin Mouette, Raphael Geissert, Regid Ichira, Colin Watson
  • Date: 2013-02-18 21:50:11 UTC
  • mfrom: (10.7.8 squeeze)
  • mto: (10.10.1 sid)
  • mto: This revision was merged to the branch mainline in revision 132.
  • Revision ID: package-import@ubuntu.com-20130218215011-efervwilveqwzzzx
Tags: 2.13.0
[ Christoph Berg ]
* origtargz: New script: fetch the orig tarball of a Debian package from
  various sources, and unpack it
* debcommit: --changelog-info will pass --author and --date for git commits.

[ James McCoy ]
* licensecheck: Recognize MPL 2.0 licenses.  Thanks to Ryan Pavlik for the
  patch.  (Closes: #687664)
* namecheck: Check Apache's projects page for names.  (Closes: #686862)
* debcommit:
  + Drop checks for old dpkg versions and always use the necessary Perl
    modules (Dpkg::Changelog::Parse, Dpkg::Vendor::Ubuntu,
    Dpkg::Changelog::Entry::Debian).
  + Add changelog info support for hg and bzr.
* annotate-output:
  + Handle an incomplete line of output.  (Closes: #695609)
  + Don't treat backslashes in the command's output as an escape.  (Closes:
    #695613)
  + Don't swallow leading whitespace.  (Closes: #695612, LP: #1120917)
* dscverify: Use "gpg --status-fd" to determine if a valid signature is
  found and only use the signed content.  (Closes: #695914)
* wrap-and-sort: Fix repeated word in man page.  (Closes: #696363)

[ Dmitry Smirnov ]
* licensecheck:
  + Remove any regular comments pattern. (Closes: #526698)
  + Improve command line parsing.
  + Fix GPL license version detection bug.
  + Fix BSD-3-clause detection.

[ Paul Wise ]
* checkbashisms: When examining a bash script, indicate the lack of use of
  bashisms.
* uscan:
  + Access GitHub directly instead of using githubredir.debian.net in
    example GitHub watch URL.
  + Add an example watch URL that matches the various file extensions used
    by common archive formats.
  + Add an example watch URL for Google Code projects.

[ Benjamin Drung ]
* Add bashism test cases from Raphael Geissert.
* Add autopkgtest support. (LP: #1073330)
* suspicious-source: Add inode/symlink and image/x-xpmi to whitelisted
  mime-types.
* wrap-and-sort:
  + Put special entries (variables and placeholders) at the end of the list.
  + Sort debian/control*.in files too.
* licensecheck: detect (L)GPL licenses more permissively. Thanks to
  Laurent Rineau for the patch. (Closes: #659231)
* Bump Standards-Version to 3.9.4 (no changes needed).

[ Cyril Brulebois ]
* Don't auto reverse diffs when DEBDIFF_AUTO_VER_SORT is set to yes, and
  when the version in both packages is the same. (Closes: #650732)

[ Tony Mancill ]
* debsnap: Escape the package name when used in regex.  (Closes: #696018)

[ David Prévot ]
* Minor manpages convention fix: do not terminate the SEE ALSO lists with a
  period. (Closes: #696416)
* French translation update.

[ Josselin Mouette ]
* nmudiff: Use dpkg-parsechangelog to fix manual parsing bug (Closes: #700584)

[ Raphael Geissert ]
* checkbashisms:
  + allow -FOO- as heredoc delimiter
  + simplify mixed single/double balanced quotes correctly
  + correct description of 'setvar'
  + detect traps for DEBUG, ERRNO, or RETURN
  + check for incorrect args. to 'exit' (Closes: #687450)
  + fix handling of # characters in quoted strings
  + detect use of $FUNCNAME, $TMOUT, and $TIMEFORMAT
  + detect uses of sleep with anything other than an int.
  + detect the use of the hash utility and $_
  + check for other forms of brace expansion
  + check for use of non-standard tilde expansion
  + check for case modification expansions
  + check for the use of $GLOBIGNORE

[ Regid Ichira ]
* rc-alert: Support using curl as alternative to wget. (Closes: #690024)
* wnpp-alert: Support using curl as alternative to wget. (Closes: #690056)
* wnpp-check: Support using curl as alternative to wget. (Closes: #690059)

[ Colin Watson ]
* debian/control: Mark devscripts Multi-Arch: foreign. (Closes: #694760)
* debchange, debcommit: Set the timestamp of temporary editor files back
  one second, to make modification detection more reliable in the absence
  of subsecond granularity. (Closes: #697923)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
################################################################################
 
4
#                                                                              #
 
5
# Copyright (c) 2009 FUJITSU LIMITED                                           #
 
6
#                                                                              #
 
7
# This program is free software;  you can redistribute it and#or modify        #
 
8
# it under the terms of the GNU General Public License as published by         #
 
9
# the Free Software Foundation; either version 2 of the License, or            #
 
10
# (at your option) any later version.                                          #
 
11
#                                                                              #
 
12
# This program is distributed in the hope that it will be useful, but          #
 
13
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY   #
 
14
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License     #
 
15
# for more details.                                                            #
 
16
#                                                                              #
 
17
# You should have received a copy of the GNU General Public License            #
 
18
# along with this program;  if not, write to the Free Software                 #
 
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA      #
 
20
#                                                                              #
 
21
# Author: Miao Xie <miaox@cn.fujitsu.com>                                      #
 
22
#                                                                              #
 
23
################################################################################
 
24
 
 
25
cd $LTPROOT/testcases/bin
 
26
 
 
27
. ./cpuset_funcs.sh
 
28
 
 
29
export TCID="cpuset01"
 
30
export TST_TOTAL=97
 
31
export TST_COUNT=1
 
32
 
 
33
nr_cpus=$NR_CPUS
 
34
nr_mems=$N_NODES
 
35
 
 
36
cpus_all="$(seq -s, 0 $((nr_cpus-1)))"
 
37
mems_all="$(seq -s, 0 $((nr_mems-1)))"
 
38
 
 
39
exit_status=0
 
40
 
 
41
cfile_name=
 
42
 
 
43
# base_op_write_and_test <write_file_name> <write_string> <expect_string>
 
44
base_op_write_and_test()
 
45
{
 
46
        local write_file="$1"
 
47
        local write_string="$2"
 
48
        local expect_string="$3"
 
49
        local write_result=
 
50
        local ret=0
 
51
 
 
52
        mkdir -p "$(dirname $write_file)" || {
 
53
                tst_brkm TFAIL "Failed to mkdir -p $(basename $write_file)"
 
54
                return 1
 
55
        }
 
56
        [ "$write_string" = NULL ] && write_string=" "
 
57
        
 
58
        /bin/echo "$write_string" > "$write_file" 2> $CPUSET_TMP/stderr
 
59
        ret=$?
 
60
        write_result="$(cat "$write_file")"
 
61
        
 
62
        case "$expect_string" in
 
63
        EMPTY)
 
64
                test -z "$write_result" -a $ret = 0
 
65
                ret=$?
 
66
                ;;
 
67
        WRITE_ERROR)
 
68
                ret=$((!$ret))
 
69
                ;;
 
70
        *)
 
71
                test "$expect_string" = "$write_result" -a $ret = 0
 
72
                ret=$?
 
73
                ;;
 
74
        esac
 
75
 
 
76
        if [ $ret -eq 0 ]; then
 
77
                tst_resm TPASS "$cfile_name: Get the expected string"
 
78
        else
 
79
                tst_resm TFAIL "$cfile_name: Test result - $write_result Expected string - \"$expect_string\""
 
80
        fi
 
81
        return $ret
 
82
}
 
83
 
 
84
base_op_test()
 
85
{
 
86
        setup
 
87
        if [ $? -ne 0 ]; then
 
88
                exit_status=1
 
89
        else
 
90
                base_op_write_and_test "$@"
 
91
                if [ $? -ne 0 ]; then
 
92
                        exit_status=1
 
93
                fi
 
94
 
 
95
                cleanup
 
96
                if [ $? -ne 0 ]; then
 
97
                        exit_status=1
 
98
                fi
 
99
        fi
 
100
        : $((TST_COUNT++)) #BASHISM
 
101
}
 
102
 
 
103
test_cpus()
 
104
{
 
105
        cfile_name="cpus"
 
106
        while read cpus result
 
107
        do
 
108
                base_op_test "$CPUSET/1/cpus" "$cpus" "$result"
 
109
        done <<- EOF
 
110
                NULL                                    EMPTY
 
111
                0                                       0
 
112
                $nr_cpus                                WRITE_ERROR
 
113
                $cpus_all                               0-$((nr_cpus-1))
 
114
                ${cpus_all}$nr_cpus                     WRITE_ERROR
 
115
                0,0                                     0
 
116
                0-0                                     0
 
117
                0-$((nr_cpus-1))                        0-$((nr_cpus-1))
 
118
                -1                                      WRITE_ERROR
 
119
                0-$nr_cpus                              WRITE_ERROR
 
120
                0-                                      WRITE_ERROR
 
121
                0--$((nr_cpus-1))                       WRITE_ERROR
 
122
                0,1-$((nr_cpus-2)),$((nr_cpus-1))       0-$((nr_cpus-1))
 
123
                0,1-$((nr_cpus-2)),                     0-$((nr_cpus-2))
 
124
                0AAA                                    WRITE_ERROR
 
125
                AAA                                     WRITE_ERROR
 
126
        EOF
 
127
        # while read cpus result
 
128
}
 
129
 
 
130
test_mems()
 
131
{
 
132
        cfile_name="mems"
 
133
        while read mems result
 
134
        do
 
135
                base_op_test "$CPUSET/1/mems" "$mems" "$result"
 
136
        done <<- EOF
 
137
                NULL                                    EMPTY
 
138
                0                                       0
 
139
                $nr_mems                                WRITE_ERROR
 
140
                $mems_all                               0-$((nr_mems-1))
 
141
                ${mems_all}$nr_mems                     WRITE_ERROR
 
142
                0,0                                     0
 
143
                0-0                                     0
 
144
                0-$((nr_mems-1))                        0-$((nr_mems-1))
 
145
                -1                                      WRITE_ERROR
 
146
                0-$nr_mems                              WRITE_ERROR
 
147
                0-                                      WRITE_ERROR
 
148
                0--$((nr_mems-1))                       WRITE_ERROR
 
149
                0,1-$((nr_mems-2)),$((nr_mems-1))       0-$((nr_mems-1))
 
150
                0,1-$((nr_mems-2)),                     0-$((nr_mems-2))
 
151
                0AAA                                    WRITE_ERROR
 
152
                AAA                                     WRITE_ERROR
 
153
        EOF
 
154
        # while read mems result
 
155
}
 
156
 
 
157
test_flags()
 
158
{
 
159
        for filename in cpu_exclusive mem_exclusive mem_hardwall \
 
160
                        memory_migrate memory_spread_page memory_spread_slab \
 
161
                        sched_load_balance memory_pressure_enabled
 
162
        do
 
163
                cfile_name="$filename"
 
164
                while read flags result
 
165
                do
 
166
                        base_op_test "$CPUSET/$filename" "$flags" "$result"
 
167
                done <<- EOF
 
168
                        NULL    0
 
169
                        0       0
 
170
                        1       1
 
171
                        -1      WRITE_ERROR
 
172
                        A       WRITE_ERROR
 
173
                        2       1
 
174
                EOF
 
175
                # while read flags, result
 
176
        done # for filename in flagfiles
 
177
}
 
178
 
 
179
test_domain()
 
180
{
 
181
        cfile_name="sched_relax_domain_level"
 
182
        while read domain_level result
 
183
        do
 
184
                base_op_test "$CPUSET/sched_relax_domain_level" "$domain_level" "$result"
 
185
        done <<- EOF
 
186
                NULL    0
 
187
                0       0
 
188
                1       1
 
189
                2       2
 
190
                3       3
 
191
                4       4
 
192
                5       5
 
193
                6       WRITE_ERROR
 
194
                -1      -1
 
195
                -2      WRITE_ERROR
 
196
                A       WRITE_ERROR
 
197
        EOF
 
198
        # while read domain_level result
 
199
}
 
200
 
 
201
# attach_task_test <cpus> <mems> <expect>
 
202
attach_task_test()
 
203
{
 
204
        local cpus=$1
 
205
        local mems=$2
 
206
        local expect=$3
 
207
 
 
208
        local pid=
 
209
        local ret=
 
210
 
 
211
        setup
 
212
        if [ $? -ne 0 ]; then
 
213
                exit_status=1
 
214
                cleanup
 
215
                ((TST_COUNT++)) #BASHISM
 
216
                return
 
217
        fi
 
218
 
 
219
        # create sub cpuset
 
220
        mkdir "$CPUSET/sub_cpuset" > /dev/null
 
221
        if [ $? -ne 0 ]; then
 
222
                exit_status=1
 
223
                cleanup
 
224
                ((TST_COUNT++)) # BASHISM
 
225
                return
 
226
        fi
 
227
 
 
228
        if [ "$cpus" != "NULL" ]; then
 
229
                echo $cpus > "$CPUSET/sub_cpuset/cpus"
 
230
        fi
 
231
        if [ "$mems" != "NULL" ]; then
 
232
                echo $mems > "$CPUSET/sub_cpuset/mems"
 
233
        fi
 
234
 
 
235
        cat /dev/zero > /dev/null &
 
236
        pid=$!
 
237
 
 
238
        # attach task into the cpuset group
 
239
        echo $pid > "$CPUSET/sub_cpuset/tasks" 2> /dev/null
 
240
        if [ $? -eq $expect ]; then
 
241
                tst_resm TPASS "Attaching Task Test successed!!"
 
242
        else
 
243
                tst_resm TFAIL "Attaching Task Test failed!! cpus - \"$cpus\", mems - \"$mems\", Expect - \"$expect\", Fact - \"$ret\". (0 - Attach Success, 1 - Attach Fail)"
 
244
                exit_status=1
 
245
        fi
 
246
 
 
247
        /bin/kill $pid &> /dev/null # BASHISM
 
248
        cleanup
 
249
        if [ $? -ne 0 ]; then
 
250
                exit_status=1
 
251
        fi
 
252
        ((TST_COUNT++)) # BASHISM
 
253
}
 
254
 
 
255
 
 
256
test_attach_task()
 
257
{
 
258
        cfile_name="tasks"
 
259
        while read cpus mems expect
 
260
        do
 
261
                attach_task_test "$cpus" "$mems" "$expect"
 
262
        done <<- EOF
 
263
                0       NULL    1
 
264
                0       0       0
 
265
                NULL    0       1
 
266
        EOF
 
267
        # while read cpus mems expect
 
268
}
 
269
 
 
270
test_readonly_cfiles()
 
271
{
 
272
        for filename in cpus mems memory_pressure
 
273
        do
 
274
                cfile_name="$filename(READONLY)"
 
275
                base_op_test "$CPUSET/$filename" "0" "WRITE_ERROR"
 
276
        done # for filename in readonly cfiles
 
277
}
 
278
 
 
279
# Case 1-3
 
280
test_readonly_cfiles
 
281
 
 
282
# Case 4-19
 
283
test_cpus
 
284
 
 
285
# Case 20-35
 
286
test_mems
 
287
 
 
288
# Case 36-83
 
289
test_flags
 
290
 
 
291
# Case 84-94
 
292
test_domain
 
293
 
 
294
# Case 95-97
 
295
test_attach_task
 
296
 
 
297
exit $exit_status