summaryrefslogtreecommitdiff
path: root/qa/316
blob: b519cb9d541a146c18138bb325489a883ae791e9 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh
# PCP QA Test No. 316
# exercise pmParseInterval
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard filters
. ./common.product
. ./common.filter
. ./common.check

status=1	# failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

_args()
{
    _a=`echo "$1" | sed -e 's/ /\\\\ /g'`
    shift
    for s
    do
	arg="$arg $_a$s"
	S=`echo "$s" | tr '[a-z]' '[A-Z]'`
	arg="$arg $_a$S"
    done
}

do_msec()
{
    arg=""
    for a
    do
	_args "$a" millisecond milliseconds msec msecs
    done
    # sed needed for arithmetic precision and rounding differences between machines
    #
    eval src/parseinterval $arg \
    | sed \
	-e 's/0.122999 sec/0.123000 sec/' \
	-e 's/0.009122 sec/0.009123 sec/' \
	-e 's/0.007999 sec/0.008000 sec/'
}

do_sec()
{
    arg=""
    for a
    do
	_args "$a" second seconds sec secs s
    done
    eval src/parseinterval $arg
    for a
    do
	src/parseinterval "$a"
    done
}

do_min()
{
    arg=""
    for a
    do
	_args "$a" minute minutes min mins m
    done
    eval src/parseinterval $arg
}

do_hour()
{
    arg=""
    for a
    do
	_args "$a" hour hours hr hrs h
    done
    eval src/parseinterval $arg
}

do_day()
{
    arg=""
    for a
    do
	_args "$a" day d
    done
    eval src/parseinterval $arg
}

# real QA test starts here

echo
echo "milliseconds ..."
do_msec 123 45.67 8. "   9.123   "

echo
echo "seconds ..."
do_sec 123 45.67 8. "   9.123   "

echo 
echo "minutes ..."
do_min 60 1.25 2. "   0.16666667  "

echo
echo "hours ..."
do_hour 2 1.5 10. "   0.333333333333  "

echo
echo "days ..."
do_day 1 1.5 10. "   0.083333333333  "

echo
echo "some hybrids ..."
src/parseinterval 1min30sec 1d1h1m1s1msec "1.5 hr 10 min 15 sec" \
| sed \
    -e 's/90061.000999 sec/90061.001000 sec/'
src/parseinterval "1 2 3 4 5 6 7 8 9 10" 55seconds

echo
echo "some errors ..."
src/parseinterval 123+sec 123.456.789min "4minutes 30secoonds" sec "123sec min" \
| sed \
    -e 's/170.796000/170.795999/'

# success, all done
status=0
exit