Revision 79e40ab1 tests/qemu-iotests/common.rc

b/tests/qemu-iotests/common.rc
20 20
dd()
21 21
{
22 22
   if [ "$HOSTOS" == "Linux" ]
23
   then	
24
	command dd --help | grep noxfer > /dev/null 2>&1
25
	
26
	if [ "$?" -eq 0 ]
27
	    then
28
		command dd status=noxfer $@
29
	    else
30
		command dd $@
31
    	fi
23
   then
24
        command dd --help | grep noxfer > /dev/null 2>&1
25

  
26
        if [ "$?" -eq 0 ]
27
            then
28
                command dd status=noxfer $@
29
            else
30
                command dd $@
31
            fi
32 32
   else
33
	command dd $@
33
        command dd $@
34 34
   fi
35 35
}
36 36

  
......
193 193
{
194 194
    if [ $# -ne 1 ]
195 195
    then
196
	echo "Usage: _get_pids_by_name process-name" 1>&2
197
	exit 1
196
        echo "Usage: _get_pids_by_name process-name" 1>&2
197
        exit 1
198 198
    fi
199 199

  
200 200
    # Algorithm ... all ps(1) variants have a time of the form MM:SS or
......
206 206

  
207 207
    ps $PS_ALL_FLAGS \
208 208
    | sed -n \
209
	-e 's/$/ /' \
210
	-e 's/[ 	][ 	]*/ /g' \
211
	-e 's/^ //' \
212
	-e 's/^[^ ]* //' \
213
	-e "/[0-9]:[0-9][0-9]  *[^ ]*\/$1 /s/ .*//p" \
214
	-e "/[0-9]:[0-9][0-9]  *$1 /s/ .*//p"
209
        -e 's/$/ /' \
210
        -e 's/[         ][         ]*/ /g' \
211
        -e 's/^ //' \
212
        -e 's/^[^ ]* //' \
213
        -e "/[0-9]:[0-9][0-9]  *[^ ]*\/$1 /s/ .*//p" \
214
        -e "/[0-9]:[0-9][0-9]  *$1 /s/ .*//p"
215 215
}
216 216

  
217 217
# fqdn for localhost
......
229 229
    id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
230 230
    if [ "$id" -ne 0 ]
231 231
    then
232
	echo "Arrgh ... you need to be root (not uid=$id) to run this test"
233
	exit 1
232
        echo "Arrgh ... you need to be root (not uid=$id) to run this test"
233
        exit 1
234 234
    fi
235 235
}
236 236

  
......
248 248
_do()
249 249
{
250 250
    if [ $# -eq 1 ]; then
251
	_cmd=$1
251
        _cmd=$1
252 252
    elif [ $# -eq 2 ]; then
253
	_note=$1
254
	_cmd=$2
255
	echo -n "$_note... "
253
        _note=$1
254
        _cmd=$2
255
        echo -n "$_note... "
256 256
    else
257
	echo "Usage: _do [note] cmd" 1>&2
258
	status=1; exit
257
        echo "Usage: _do [note] cmd" 1>&2
258
        status=1; exit
259 259
    fi
260 260

  
261 261
    (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
262 262
    (eval "$_cmd") >$tmp._out 2>&1; ret=$?
263 263
    cat $tmp._out >>$here/$seq.full
264 264
    if [ $# -eq 2 ]; then
265
	if [ $ret -eq 0 ]; then
266
	    echo "done"
267
	else
268
	    echo "fail"
269
	fi
265
        if [ $ret -eq 0 ]; then
266
            echo "done"
267
        else
268
            echo "fail"
269
        fi
270 270
    fi
271 271
    if [ $ret -ne 0  ] \
272
	&& [ "$_do_die_on_error" = "always" \
273
	    -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
272
        && [ "$_do_die_on_error" = "always" \
273
            -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
274 274
    then
275
	[ $# -ne 2 ] && echo
276
	eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
277
	status=1; exit
275
        [ $# -ne 2 ] && echo
276
        eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
277
        status=1; exit
278 278
    fi
279 279

  
280 280
    return $ret
......
305 305
_supported_fmt()
306 306
{
307 307
    for f; do
308
	if [ "$f" = "$IMGFMT" -o "$f" = "generic" ]; then
309
	    return
310
	fi
308
        if [ "$f" = "$IMGFMT" -o "$f" = "generic" ]; then
309
            return
310
        fi
311 311
    done
312 312

  
313 313
    _notrun "not suitable for this image format: $IMGFMT"
......
318 318
_supported_proto()
319 319
{
320 320
    for f; do
321
	if [ "$f" = "$IMGPROTO" -o "$f" = "generic" ]; then
322
	    return
323
	fi
321
        if [ "$f" = "$IMGPROTO" -o "$f" = "generic" ]; then
322
            return
323
        fi
324 324
    done
325 325

  
326 326
    _notrun "not suitable for this image protocol: $IMGPROTO"
......
332 332
{
333 333
    for h
334 334
    do
335
	if [ "$h" = "$HOSTOS" ]
336
	then
337
	    return
338
	fi
335
        if [ "$h" = "$HOSTOS" ]
336
        then
337
            return
338
        fi
339 339
    done
340 340

  
341 341
    _notrun "not suitable for this OS: $HOSTOS"

Also available in: Unified diff