summaryrefslogtreecommitdiff
path: root/qa/542
blob: b77ac9bd99e44b9e228a496668a8da325f429f9d (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
#! /bin/sh
# PCP QA Test No. 542
# pmdate buffer overflow ... #666344
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

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

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

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

# real QA test starts here
for fmt in "%H:%M" "%A %B" "%c" "some stuff to pad: %c"
do
    echo
    echo "=== $fmt ==="
    match=false
    echo >$tmp.err

    # try 3 times to avoid clock changes between the date(1) and pmdate(1)
    # executions
    #
    for i in 1 2 3
    do
	# need to dodge AM/PM and timezone abbreviation and move year
	# to the end and change "16 May" to "May 16", and deal with
	# leading spaces for days before the 10th, for %c on Linux
	#
	x1=`date +"$fmt" \
	    | sed \
	        -e 's/ AM//' \
		-e '/ PM/{
s/ PM//
s/ 00:/ 12:/
s/ 01:/ 13:/
s/ 02:/ 14:/
s/ 03:/ 15:/
s/ 04:/ 16:/
s/ 05:/ 17:/
s/ 06:/ 18:/
s/ 07:/ 19:/
s/ 08:/ 20:/
s/ 09:/ 21:/
s/ 10:/ 22:/
s/ 11:/ 23:/
}' \
		-e 's/ [A-Z][A-Z][A-Z]$//' \
		-e 's/ \([1-2][0-9][0-9][0-9]\) \(.*\)/ \2 \1/' \
		-e 's/\([A-Z][a-z][a-z]\) 0\([1-9]\) /\1  \2 /' \
		-e 's/\([ 1-3][0-9]\) \([A-Z][a-z][a-z]\)/\2 \1/'`
	x2=`pmdate "$fmt"`
	if [ "$x1" = "$x2" ]
	then
	    match=true
	    break
	else
	    echo "date -> \"`date +"$fmt"`\" -> \"$x1\"" >>$tmp.err
	    echo "pmdate -> \"$x2\"" >>$tmp.err
	fi
    done
    if $match
    then
	echo "match"
    else
	echo "errors ..."
	cat $tmp.err
	status=1
    fi
done

# error checks
#
echo
echo "=== error checks ==="

$sudo rm -f core* $seq.core*
pmdate "%A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B %A%B"
_check_core

exit