~ubuntu-branches/debian/jessie/timelimit/jessie

« back to all changes in this revision

Viewing changes to t/02-subsecond.t

  • Committer: Bazaar Package Importer
  • Author(s): Peter Pentchev
  • Date: 2011-04-13 16:35:30 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110413163530-o1a228juhjpwa5jd
Tags: 1.8-1
* New upstream release
  - supports signal names now.  Closes: #621775
  - needs prove(1) for the test suite, so build-depend on perl
* Update the copyright file to the latest DEP 5 candidate format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Copyright (c) 2011  Peter Pentchev
 
4
# All rights reserved.
 
5
#
 
6
# Redistribution and use in source and binary forms, with or without
 
7
# modification, are permitted provided that the following conditions
 
8
# are met:
 
9
# 1. Redistributions of source code must retain the above copyright
 
10
#    notice, this list of conditions and the following disclaimer.
 
11
# 2. Redistributions in binary form must reproduce the above copyright
 
12
#    notice, this list of conditions and the following disclaimer in the
 
13
#    documentation and/or other materials provided with the distribution.
 
14
#
 
15
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
16
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
17
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
18
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
19
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
20
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
21
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
22
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
23
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
24
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
25
# SUCH DAMAGE.
 
26
 
 
27
[ -z "$TIMELIMIT" ] && TIMELIMIT='./timelimit'
 
28
 
 
29
echo '1..8'
 
30
 
 
31
echo '# return EX_UNAVAILABLE if subsecond precision not supported'
 
32
$TIMELIMIT -t 0.5 true 2>/dev/null
 
33
res="$?"
 
34
if [ "$res" = 69 ]; then
 
35
        echo '# Subsecond precision not supported, skipping this test set'
 
36
        for i in 1 2 3 4 5 6 7 8; do
 
37
                echo "ok $i"
 
38
        done
 
39
        exit 0
 
40
fi
 
41
if [ "$res" = 0 ]; then echo 'ok 1'; else echo "not ok 1 res is $res"; fi
 
42
 
 
43
echo '# kill a shell script during the sleep, only execute a single echo'
 
44
v=`$TIMELIMIT -t 0.7 sh -c 'echo 1; sleep 1; echo 2' 2>/dev/null`
 
45
res="$?"
 
46
if [ "$res" = 143 ]; then echo 'ok 2'; else echo "not ok 2 exit code $res"; fi
 
47
if expr "x$v" : 'x1' > /dev/null; then echo 'ok 3'; else echo "not ok 3 v is '$v'"; fi
 
48
if ! expr "x$v" : 'x.*2' > /dev/null; then echo 'ok 4'; else echo "not ok 4 v is '$v'"; fi
 
49
 
 
50
echo '# catch a signal, kill with a different one'
 
51
v=`$TIMELIMIT -t 0.7 -s 1 -T 0.8 -S 15 sh -c 'trap "" HUP; echo 1; sleep 1; echo 2; sleep 1; echo 3' 2>/dev/null`
 
52
res="$?"
 
53
if [ "$res" = 143 ]; then echo 'ok 5'; else echo "not ok 5 exit code $res"; fi
 
54
if expr "x$v" : 'x1' > /dev/null; then echo 'ok 6'; else echo "not ok 6 v is '$v'"; fi
 
55
if expr "x$v" : 'x.*2' > /dev/null; then echo 'ok 7'; else echo "not ok 7 v is '$v'"; fi
 
56
if ! expr "x$v" : 'x.*3' > /dev/null; then echo 'ok 8'; else echo "not ok 8 v is '$v'"; fi