Hash :
8504bcdd
Author :
Date :
2025-05-07T08:57:31
Fix "make sc_prohibit_leading_TABs" failures. * Makefile (exclude_file_name_regexp--sc_prohibit_leading_TABs): New variable. (sc_prohibit_leading_TABs): Use it. * lib/crc-x86_64-pclmul.c: Untabify. * tests/test-crc.c: Untabify. * tests/test-parse-duration.sh: Remove leading tabs from here documents.
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
#!/bin/sh
# Show all commands when run with environment variable VERBOSE=yes.
test -z "$VERBOSE" || set -x
prog=test-parse-duration
exe=`pwd`/${prog}${EXEEXT}
# func_tmpdir
# creates a temporary directory.
# Sets variable
# - tmp pathname of freshly created temporary directory
func_tmpdir ()
{
# Use the environment variable TMPDIR, falling back to /tmp. This allows
# users to specify a different temporary directory, for example, if their
# /tmp is filled up or too small.
: "${TMPDIR=/tmp}"
{
# Use the mktemp program if available. If not available, hide the error
# message.
tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
# Use a simple mkdir command. It is guaranteed to fail if the directory
# already exists. $RANDOM is bash specific and expands to empty in shells
# other than bash, ksh and zsh. Its use does not increase security;
# rather, it minimizes the probability of failure in a very cluttered /tmp
# directory.
tmp=$TMPDIR/gl$$-$RANDOM
(umask 077 && mkdir "$tmp")
} ||
{
echo "$0: cannot create a temporary directory in $TMPDIR" >&2
exit 1
}
}
die ()
{
echo "${prog} fatal error: $*" >&2
exit 1
}
func_tmpdir
trap 'rm -rf "${tmp}"' EXIT
tmpf="${tmp}/tests.txt"
# Tests where we expect success.
cat > "${tmpf}" <<_EOF_
1 Y 2 M 3 W 4 d 5 h 6 m 7 s
P 00010225 T 05:06:07
P 1Y2M3W4D T 5H6M7S
1 Y 2 M 25 D 5:6:7
1 Y 2 M 25 d 5h 6:7
1 Y 2 M 25 d 5h 6m 7
P 1-2-25 T 5:6:7
_EOF_
exec 3< "${tmpf}"
while read line <&3
do
v=`${CHECKER} ${exe} "${line}" | LC_ALL=C tr -d '\r'` \
|| { ls -l "${tmpf}"; die "Failed: ${exe} '${line}'"; }
test $v -eq 38898367 || die $v is not 38898367
done
exec 3>&-
# Tests where we expect failure.
cat > "${tmpf}" <<_EOF_
T-00302
T-0:3:2
T-0 H 3 M 2 S
P+04 Y 03 M 02 D
P04 Y +03 M 02 D
P04 Y 03 M +02 D
_EOF_
fail=0
exec 3< "${tmpf}"
while read line <&3
do
if ${CHECKER} ${exe} "${line}"; then
echo "Succeeded: ${exe} '${line}'" 1>&2
fail=1
fi
done
exec 3>&-
exit $fail