Blame test/strftime.awk

Packit 575503
# strftime.awk ; test the strftime code
Packit 575503
#
Packit 575503
# input is the output of `date', see Makefile.in
Packit 575503
Packit 575503
BEGIN {
Packit 575503
	maxtries = 10
Packit 575503
	# On DOS/Windows, DATECMD is set by the Makefile to point to
Packit 575503
	# Unix-like 'date' command.
Packit 575503
	datecmd = DATECMD
Packit 575503
	if (datecmd == "")
Packit 575503
	    datecmd = "date"
Packit 575503
	fmt = "%a %b %e %H:%M:%S %Z %Y"
Packit 575503
Packit 575503
	# loop until before equals after, thereby protecting
Packit 575503
	# against a race condition where the seconds field might have
Packit 575503
	# incremented between running date and strftime
Packit 575503
	i = 0
Packit 575503
	while (1) {
Packit 575503
		if (++i > maxtries) {
Packit 575503
			printf "Warning: this system is so slow that after %d attempts, we could never get two sequential invocations of strftime to give the same result!\n", maxtries > "/dev/stderr"
Packit 575503
			break
Packit 575503
		}
Packit 575503
		before = strftime(fmt)
Packit 575503
		datecmd | getline sd
Packit 575503
		after = strftime(fmt)
Packit 575503
		close(datecmd)
Packit 575503
		if (before == after) {
Packit 575503
			if (i > 1)
Packit 575503
				printf "Notice: it took %d loops to get the before and after strftime values to match\n", i > "/dev/stderr"
Packit 575503
			break
Packit 575503
		}
Packit 575503
	}
Packit 575503
	print sd > "strftime.ok"
Packit 575503
	print after > OUTPUT
Packit 575503
}