#
# test/Makefile.am --- automake input file for gawk
#
# Copyright (C) 1988-2012 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GAWK is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
#

## process this file with automake to produce Makefile.in

EXTRA_DIST = \
	reg \
	lib \
	ChangeLog.0 \
	Gentests \
	Gentests.vms \
	Maketests \
	README \
	aadelete1.awk \
	aadelete1.ok \
	aadelete2.awk \
	aadelete2.ok \
	aarray1.awk \
	aarray1.ok \
	aasort.awk \
	aasort.ok \
	aasorti.awk \
	aasorti.ok \
	addcomma.awk \
	addcomma.in \
	addcomma.ok \
	anchgsub.awk \
	anchgsub.in \
	anchgsub.ok \
	arraysort.awk \
	arraysort.ok \
	argarray.awk \
	argarray.in \
	argarray.ok \
	argtest.awk \
	argtest.ok \
	arrayparm.awk \
	arrayparm.ok \
	arrayprm2.awk \
	arrayprm2.ok \
	arrayprm3.awk \
	arrayprm3.ok \
	arrayref.awk \
	arrayref.ok \
	arrymem1.awk \
	arrymem1.ok \
	arryref2.awk \
	arryref2.ok \
	arryref3.awk \
	arryref3.ok \
	arryref4.awk \
	arryref4.ok \
	arryref5.awk \
	arryref5.ok \
	arynasty.awk \
	arynasty.ok \
	arynocls.awk \
	arynocls.in \
	arynocls.ok \
	aryprm1.awk \
	aryprm1.ok \
	aryprm2.awk \
	aryprm2.ok \
	aryprm3.awk \
	aryprm3.ok \
	aryprm4.awk \
	aryprm4.ok \
	aryprm5.awk \
	aryprm5.ok \
	aryprm6.awk \
	aryprm6.ok \
	aryprm7.awk \
	aryprm7.ok \
	aryprm8.awk \
	aryprm8.ok \
	arysubnm.awk \
	arysubnm.ok \
	asgext.awk \
	asgext.in \
	asgext.ok \
	asort.awk \
	asort.ok \
	asorti.awk \
	asorti.ok \
	awkpath.ok \
	back89.awk \
	back89.in \
	back89.ok \
	backgsub.awk \
	backgsub.in \
	backgsub.ok \
	backw.awk \
	backw.in \
	backw.ok \
	badargs.ok \
	beginfile1.awk \
	beginfile1.ok \
	beginfile2.in \
	beginfile2.ok \
	beginfile2.sh \
	binmode1.ok \
	childin.awk \
	childin.in \
	childin.ok \
	clobber.awk \
	clobber.ok \
	clos1way.awk \
	clos1way.ok \
	closebad.awk \
	closebad.ok \
	clsflnam.awk \
	clsflnam.in \
	clsflnam.ok \
	compare.awk \
	compare.in \
	compare.ok \
	compare2.awk \
	compare2.ok \
	concat1.awk \
	concat1.in \
	concat1.ok \
	concat2.awk \
	concat2.ok \
	concat3.awk \
	concat3.ok \
	concat4.awk \
	concat4.in \
	concat4.ok \
	convfmt.awk \
	convfmt.ok \
	datanonl.awk \
	datanonl.in \
	datanonl.ok \
	defref.awk \
	defref.ok \
	delargv.awk \
	delargv.ok \
	delarprm.awk \
	delarprm.ok \
	delarpm2.awk \
	delarpm2.ok \
	delfunc.awk \
	delfunc.ok \
	delsub.awk \
	delsub.ok \
	devfd.in1 \
	devfd.in2 \
	devfd.in4 \
	devfd.in5 \
	devfd.ok \
	devfd1.awk \
	devfd1.ok \
	devfd2.ok \
	dfastress.awk \
	dfastress.ok \
	double1.awk \
	double1.ok \
	double2.awk \
	double2.ok \
	dtdgport.awk \
	dumpvars.in \
	dumpvars.ok \
	dynlj.awk \
	dynlj.ok \
	eofsplit.awk \
	eofsplit.ok \
	exit.ok \
	exit.sh \
	exitval1.awk \
	exitval1.ok \
	exitval2.awk \
	exitval2.ok \
	exitval2.w32 \
	fcall_exit.awk \
	fcall_exit.ok \
	fcall_exit2.awk \
	fcall_exit2.ok \
	fcall_exit2.in \
	fflush.ok \
	fflush.sh \
	fieldwdth.awk \
	fieldwdth.in \
	fieldwdth.ok \
	fldchg.awk \
	fldchg.in \
	fldchg.ok \
	fldchgnf.awk \
	fldchgnf.in \
	fldchgnf.ok \
	fmtspcl.awk \
	fmtspcl.tok \
	fmttest.awk \
	fmttest.ok \
	fnamedat.awk \
	fnamedat.in \
	fnamedat.ok \
	fnarray.awk \
	fnarray.ok \
	fnarray2.awk \
	fnarray2.ok \
	fnarydel.awk \
	fnarydel.ok \
	fnaryscl.awk \
	fnaryscl.ok \
	fnasgnm.awk \
	fnasgnm.in \
	fnasgnm.ok \
	fnmisc.awk \
	fnmisc.ok \
	fnparydl.awk \
	fnparydl.ok \
	fpat1.awk \
	fpat1.in \
	fpat1.ok \
	fpat2.awk \
	fpat2.ok \
	fpat3.awk \
	fpat3.in \
	fpat3.ok \
	fpatnull.awk \
	fpatnull.in \
	fpatnull.ok \
	fordel.awk \
	fordel.ok \
	forref.awk \
	forref.ok \
	forsimp.awk \
	forsimp.ok \
	fsbs.awk \
	fsbs.in \
	fsbs.ok \
	fsfwfs.awk \
	fsfwfs.in \
	fsfwfs.ok \
	fsrs.awk \
	fsrs.in \
	fsrs.ok \
	fsspcoln.awk \
	fsspcoln.in \
	fsspcoln.ok \
	fstabplus.awk \
	fstabplus.in \
	fstabplus.ok \
	funlen.awk \
	funlen.in \
	funlen.ok \
	funsemnl.awk \
	funsemnl.ok \
	funsmnam.awk \
	funsmnam.ok \
	funstack.awk \
	funstack.in \
	funstack.ok \
	fwtest.awk \
	fwtest.in \
	fwtest.ok \
	fwtest2.awk \
	fwtest2.in \
	fwtest2.ok \
	fwtest3.awk \
	fwtest3.in \
	fwtest3.ok \
	gensub.awk \
	gensub.in \
	gensub.ok \
	gensub2.awk \
	gensub2.ok \
	getline.awk \
	getline.in \
	getline.ok \
	getline2.awk \
	getline2.ok \
	getline3.awk \
	getline3.ok \
	getline4.awk \
	getline4.in \
	getline4.ok \
	getlnbuf.awk \
	getlnbuf.in \
	getlnbuf.ok \
	getlndir.awk \
	getlndir.ok \
	getlnhd.awk \
	getlnhd.ok \
	getnr2tb.awk \
	getnr2tb.in \
	getnr2tb.ok \
	getnr2tm.awk \
	getnr2tm.in \
	getnr2tm.ok \
	gnuops2.awk \
	gnuops2.ok \
	gnuops3.awk \
	gnuops3.ok \
	gnureops.awk \
	gnureops.ok \
	gsubasgn.awk \
	gsubasgn.ok \
	gsubtest.awk \
	gsubtest.ok \
	gsubtst2.awk \
	gsubtst2.ok \
	gsubtst3.awk \
	gsubtst3.in \
	gsubtst3.ok \
	gsubtst4.awk \
	gsubtst4.ok \
	gsubtst5.awk \
	gsubtst5.in \
	gsubtst5.ok \
	gsubtst6.awk \
	gsubtst6.ok \
	gsubtst7.awk \
	gsubtst7.in \
	gsubtst7.ok \
	gsubtst8.awk \
	gsubtst8.in \
	gsubtst8.ok \
	gtlnbufv.awk \
	hex.awk \
	hex.ok \
	hsprint.awk \
	hsprint.ok \
	icasefs.awk \
	icasefs.ok \
	icasers.awk \
	icasers.in \
	icasers.ok \
	igncdym.awk \
	igncdym.in \
	igncdym.ok \
	igncfs.awk \
	igncfs.in \
	igncfs.ok \
	ignrcase.awk \
	ignrcase.in \
	ignrcase.ok \
	ignrcas2.awk \
	ignrcas2.ok \
	indirectcall.awk \
	indirectcall.in \
	indirectcall.ok \
	inftest.awk \
	inftest.ok \
	inputred.awk \
	inputred.ok \
	intest.awk \
	intest.ok \
	intformat.awk \
	intformat.ok \
	intprec.awk \
	intprec.ok \
	iobug1.awk \
	iobug1.ok \
	lc_num1.awk \
	lc_num1.ok \
	leaddig.awk \
	leaddig.ok \
	leadnl.awk \
	leadnl.in \
	leadnl.ok \
	lint.awk \
	lint.ok \
	lintold.awk \
	lintold.in \
	lintold.ok \
	lintwarn.awk \
	lintwarn.ok \
	litoct.awk \
	litoct.ok \
	localenl.ok \
	localenl.sh \
	longdbl.awk \
	longdbl.in \
	longdbl.ok \
	longsub.awk \
	longsub.in \
	longsub.ok \
	longwrds.awk \
	longwrds.ok \
	longwrds.in \
	manglprm.awk \
	manglprm.in \
	manglprm.ok \
	manyfiles.awk \
	manyfiles.ok \
	match1.awk \
	match1.ok \
	match2.awk \
	match2.ok \
	match3.awk \
	match3.in \
	match3.ok \
	math.awk \
	math.ok \
	mbfw1.awk \
	mbfw1.in \
	mbfw1.ok \
	mbprintf1.awk \
	mbprintf1.in \
	mbprintf1.ok \
	mbprintf2.awk \
	mbprintf2.ok \
	mbprintf3.awk \
	mbprintf3.in \
	mbprintf3.ok \
	mbstr1.awk \
	mbstr1.ok \
	membug1.awk \
	membug1.in \
	membug1.ok \
	messages.awk \
	minusstr.awk \
	minusstr.ok \
	mixed1.ok \
	mmap8k.in \
	mtchi18n.awk \
	mtchi18n.in \
	mtchi18n.ok \
	nasty.awk \
	nasty.ok \
	nasty2.awk \
	nasty2.ok \
	nastyparm.awk \
	nastyparm.ok \
	negexp.awk \
	negexp.ok \
	negrange.awk \
	negrange.ok \
	nested.awk \
	nested.in \
	nested.ok \
	next.ok \
	next.sh \
	nfldstr.awk \
	nfldstr.in \
	nfldstr.ok \
	nfneg.awk \
	nfneg.ok \
	nfset.awk \
	nfset.in \
	nfset.ok \
	nlfldsep.awk \
	nlfldsep.in \
	nlfldsep.ok \
	nlinstr.awk \
	nlinstr.in \
	nlinstr.ok \
	nlstrina.awk \
	nlstrina.ok \
	noeffect.awk \
	noeffect.ok \
	nofile.ok \
	nofmtch.awk \
	nofmtch.ok \
	noloop1.awk \
	noloop1.in \
	noloop1.ok \
	noloop2.awk \
	noloop2.in \
	noloop2.ok \
	nondec.awk \
	nondec.ok \
	nondec2.awk \
	nondec2.ok \
	nonl.awk \
	nonl.ok \
	noparms.awk \
	noparms.ok \
	nors.in \
	nors.ok \
	nulrsend.awk \
	nulrsend.in \
	nulrsend.ok \
	numindex.awk \
	numindex.in \
	numindex.ok \
	numsubstr.awk \
	numsubstr.in \
	numsubstr.ok \
	octsub.awk \
	octsub.ok \
	ofmt.awk \
	ofmt.in \
	ofmt.ok \
	ofmta.awk \
	ofmta.ok \
	ofmtbig.awk \
	ofmtbig.in \
	ofmtbig.ok \
	ofmtfidl.awk \
	ofmtfidl.in \
	ofmtfidl.ok \
	ofmts.awk \
	ofmts.in \
	ofmts.ok \
	onlynl.awk \
	onlynl.in \
	onlynl.ok \
	opasnidx.awk \
	opasnidx.ok \
	opasnslf.awk \
	opasnslf.ok \
	out1.ok \
	out2.ok \
	out3.ok \
	paramdup.awk \
	paramdup.ok \
	paramres.awk \
	paramres.ok \
	paramtyp.awk \
	paramtyp.ok \
	parse1.awk \
	parse1.in \
	parse1.ok \
	parsefld.awk \
	parsefld.in \
	parsefld.ok \
	parseme.awk \
	parseme.ok \
	patsplit.awk \
	patsplit.ok \
	pcntplus.awk \
	pcntplus.ok \
	pid.awk \
	pid.ok \
	pid.sh \
	pipeio1.awk \
	pipeio1.ok \
	pipeio2.awk \
	pipeio2.in \
	pipeio2.ok \
	posix.awk \
	posix.in \
	posix.ok \
	posix2008sub.awk \
	posix2008sub.ok \
	poundbang.awk \
	prdupval.awk \
	prdupval.in \
	prdupval.ok \
	profile2.ok \
	profile3.awk \
	profile3.ok \
	prec.awk \
	prec.ok \
	printf0.awk \
	printf0.ok \
	printf1.awk \
	printf1.ok \
	printfbad1.awk \
	printfbad1.ok \
	printfbad2.awk \
	printfbad2.in \
	printfbad2.ok \
	printfbad3.awk \
	printfbad3.ok \
	printfloat.awk \
	printlang.awk \
	prmarscl.awk \
	prmarscl.ok \
	prmreuse.awk \
	prmreuse.ok \
	procinfs.awk \
	procinfs.ok \
	prt1eval.awk \
	prt1eval.ok \
	prtoeval.awk \
	prtoeval.ok \
	pty1.awk \
	pty1.ok \
	rand.awk \
	rand.ok \
	range1.awk \
	range1.in \
	range1.ok \
	rebt8b1.awk \
	rebt8b1.ok \
	rebt8b2.awk \
	rebt8b2.ok \
	redfilnm.awk \
	redfilnm.in \
	redfilnm.ok \
	regeq.awk \
	regeq.in \
	regeq.ok \
	regrange.awk \
	regrange.ok \
	regtest.sh \
	regx8bit.awk \
	regx8bit.ok \
	rebuf.awk \
	rebuf.in \
	rebuf.ok \
	reindops.awk \
	reindops.in \
	reindops.ok \
	reint.awk \
	reint.in \
	reint.ok \
	reint2.awk \
	reint2.in \
	reint2.ok \
	reparse.awk \
	reparse.in \
	reparse.ok \
	resplit.awk \
	resplit.in \
	resplit.ok \
	rri1.awk \
	rri1.in \
	rri1.ok \
	rs.awk \
	rs.in \
	rs.ok \
	rsnul1nl.awk \
	rsnul1nl.in \
	rsnul1nl.ok \
	rsnulbig.ok \
	rsnulbig2.ok \
	rsstart1.awk \
	rsstart1.in \
	rsstart1.ok \
	rsstart2.awk \
	rsstart2.ok \
	rsstart3.ok \
	rstest1.awk \
	rstest1.ok \
	rstest2.awk \
	rstest2.ok \
	rstest3.awk \
	rstest3.ok \
	rstest4.awk \
	rstest4.ok \
	rstest5.awk \
	rstest5.ok \
	rstest6.awk \
	rstest6.in \
	rstest6.ok \
	rswhite.awk \
	rswhite.in \
	rswhite.ok \
	rtlen.ok \
	rtlen.sh \
	rtlen01.ok \
	rtlen01.sh \
	scalar.awk \
	scalar.ok \
	sclforin.awk \
	sclforin.ok \
	sclifin.awk \
	sclifin.ok \
	shadow.awk \
	shadow.ok \
	sort1.awk \
	sort1.ok \
	sortempty.awk \
	sortempty.ok \
	sortfor.awk \
	sortfor.in \
	sortfor.ok \
	sortu.awk \
	sortu.ok \
	space.ok \
	splitarg4.awk \
	splitarg4.in \
	splitarg4.ok \
	splitargv.awk \
	splitargv.in \
	splitargv.ok \
	splitarr.awk \
	splitarr.ok \
	splitdef.awk \
	splitdef.ok \
	splitvar.awk \
	splitvar.in \
	splitvar.ok \
	splitwht.awk \
	splitwht.ok \
	sprintfc.awk \
	sprintfc.in \
	sprintfc.ok \
	strcat1.awk \
	strcat1.ok \
	strtod.awk \
	strtod.in \
	strtod.ok \
	strnum1.awk \
	strnum1.ok \
	strtonum.awk \
	strtonum.ok \
	strftime.awk \
	strftlng.awk \
	strftlng.ok \
	subamp.awk \
	subamp.in \
	subamp.ok \
	subi18n.awk \
	subi18n.ok \
	subsepnm.awk \
	subsepnm.ok \
	subslash.awk \
	subslash.ok \
	substr.awk \
	substr.ok \
	swaplns.awk \
	swaplns.in \
	swaplns.ok \
	switch2.awk \
	switch2.ok \
	synerr1.awk \
	synerr1.ok \
	synerr2.awk \
	synerr2.ok \
	tradanch.awk \
	tradanch.in \
	tradanch.ok \
	tweakfld.awk \
	tweakfld.in \
	tweakfld.ok \
	uninit2.awk \
	uninit2.ok \
	uninit3.awk \
	uninit3.ok \
	uninit4.awk \
	uninit4.ok \
	uninit5.awk \
	uninit5.ok \
	uninitialized.awk \
	uninitialized.ok \
	unterm.awk \
	unterm.ok \
	uparrfs.awk \
	uparrfs.in \
	uparrfs.ok \
	wideidx.awk \
	wideidx.in \
	wideidx.ok \
	wideidx2.awk \
	wideidx2.ok \
	widesub.awk \
	widesub.ok \
	widesub2.awk \
	widesub2.ok \
	widesub3.awk \
	widesub3.in \
	widesub3.ok \
	widesub4.awk \
	widesub4.ok \
	wjposer1.awk \
	wjposer1.in \
	wjposer1.ok \
	xref.awk \
	xref.original \
	zero2.awk \
	zero2.ok \
	zeroe0.awk \
	zeroe0.ok \
	zeroflag.awk \
	zeroflag.ok

TESTS_WE_ARE_NOT_DOING_YET_FIXME_ONE_DAY = longdbl

# Get rid of core files when cleaning and generated .ok file
CLEANFILES = core core.* fmtspcl.ok

# try to keep these sorted. each letter starts a new line
BASIC_TESTS = \
	addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \
	arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 arynasty \
	arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \
	aryprm8 arysubnm asgext awkpath \
	back89 backgsub \
	childin clobber closebad clsflnam compare compare2 concat1 concat2 \
	concat3 concat4 convfmt \
	datanonl defref delargv delarpm2 delarprm delfunc dfastress dynlj \
	eofsplit exitval1 exitval2 \
	fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \
	fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \
	fstabplus funsemnl funsmnam funstack \
	getline getline2 getline3 getline4 getlnbuf getnr2tb getnr2tm \
	gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \
	gsubtst7 gsubtst8 \
	hex hsprint \
	inputred intest intprec iobug1 \
	leaddig leadnl litoct longsub longwrds \
	manglprm math membug1 messages minusstr mmap8k mtchi18n \
	nasty nasty2 negexp negrange nested nfldstr nfneg nfset nlfldsep \
	nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \
	noparms nors nulrsend numindex numsubstr \
	octsub ofmt ofmta ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf \
	paramdup paramres paramtyp parse1 parsefld parseme pcntplus \
	posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \
	prt1eval prtoeval \
	rand range1 rebt8b1 redfilnm regeq regrange reindops reparse \
	resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \
	rstest3 rstest4 rstest5 rswhite \
	scalar sclforin sclifin sortempty splitargv splitarr splitdef \
	splitvar splitwht strcat1 strnum1 strtod subamp subi18n \
	subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \
	uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \
	wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \
	zero2 zeroe0 zeroflag

UNIX_TESTS = \
	fflush getlnhd localenl pid pipeio1 pipeio2 poundbang rtlen rtlen01 \
	space strftlng

GAWK_EXT_TESTS = \
	aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \
	backw badargs beginfile1 beginfile2  binmode1 \
	clos1way delsub devfd devfd1 devfd2 dumpvars exit \
	fieldwdth fpat1 fpat2 fpat3  fpatnull fsfwfs funlen \
	fwtest fwtest2 fwtest3 \
	gensub gensub2 getlndir gnuops2 gnuops3 gnureops \
	icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall \
	lint  lintold lintwarn \
	manyfiles match1 match2 match3 mbstr1 \
	nastyparm  next nondec nondec2 \
	patsplit posix printfbad1 printfbad2 printfbad3 procinfs \
	profile1 profile2 profile3 pty1 \
	rebuf regx8bit reint reint2 rsstart1 \
	rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \
	strtonum switch2

EXTRA_TESTS = inftest regtest

INET_TESTS = inetdayu inetdayt inetechu inetecht

MACHINE_TESTS = double1 double2 fmtspcl intformat

LOCALE_CHARSET_TESTS = \
	asort asorti fmttest fnarydel fnparydl lc_num1 mbfw1 \
	mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc

# List of the tests which should be run with --lint option:
NEED_LINT = \
	defref fmtspcl lintwarn noeffect nofmtch shadow \
	uninit2 uninit3 uninit4 uninit5 uninitialized

# List of the tests which should be run with --lint-old option:
NEED_LINT_OLD = lintold

# List of the tests which fail with EXIT CODE 1
FAIL_CODE1 = \
	fnarray2 fnmisc gsubasgn mixed1 noparms paramdup synerr1 synerr2 unterm

# List of the files that appear in manual tests or are for reserve testing:
GENTESTS_UNUSED = Makefile.in gtlnbufv.awk printfloat.awk

CMP = cmp
AWKPROG = ../gawk$(EXEEXT)
PGAWKPROG = ../pgawk$(EXEEXT)

# This business forces the locale to be C for running the tests,
# unless we override it to something else for testing.
#
# This can also be done in individual tests where we wish to
# check things specifically not in the C locale.
AWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(AWKPROG)
PGAWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(PGAWKPROG)

# Message stuff is to make it a little easier to follow.
# Make the pass-fail last and dependent on others to avoid
# spurious errors if `make -j' in effect.
check:	msg \
	printlang \
	basic-msg-start  basic           basic-msg-end \
	unix-msg-start   unix-tests      unix-msg-end \
	extend-msg-start gawk-extensions extend-msg-end \
	machine-msg-start machine-tests machine-msg-end \
	charset-msg-start charset-tests charset-msg-end
	@$(MAKE) pass-fail

basic:	$(BASIC_TESTS)

unix-tests: $(UNIX_TESTS)

gawk-extensions: $(GAWK_EXT_TESTS)

charset-tests: $(LOCALE_CHARSET_TESTS)

extra:	$(EXTRA_TESTS) inet

inet:	inetmesg $(INET_TESTS)

machine-tests: $(MACHINE_TESTS)

msg::
	@echo ''
	@echo 'Any output from "cmp" is bad news, although some differences'
	@echo 'in floating point values are probably benign -- in particular,'
	@echo 'some systems may omit a leading zero and the floating point'
	@echo 'precision may lead to slightly different output in a few cases.'

printlang::
	@$(AWK) -f $(srcdir)/printlang.awk

basic-msg-start:
	@echo "======== Starting basic tests ========"

basic-msg-end:
	@echo "======== Done with basic tests ========"

unix-msg-start:
	@echo "======== Starting Unix tests ========"

unix-msg-end:
	@echo "======== Done with Unix tests ========"

extend-msg-start:
	@echo "======== Starting gawk extension tests ========"

extend-msg-end:
	@echo "======== Done with gawk extension tests ========"

machine-msg-start:
	@echo "======== Starting machine-specific tests ========"

machine-msg-end:
	@echo "======== Done with machine-specific tests ========"

charset-msg-start:
	@echo "======== Starting tests that can vary based on character set or locale support ========"

charset-msg-end:
	@echo "======== Done with tests that can vary based on character set or locale support ========"


lc_num1:
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@


# This test is a PITA because increasingly, /tmp is getting
# mounted noexec.  So, we'll test it locally.  Sigh.
#
# More PITA; some systems have medium short limits on #! paths,
# so this can still fail
poundbang::
	@echo $@
	@sed "s;/tmp/gawk;`pwd`/$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk
	@chmod +x ./_pbd.awk
	@if ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@` ; \
	then : ; \
	else \
		sed "s;/tmp/gawk;../$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk ; \
		chmod +x ./_pbd.awk ; \
		LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@`;  \
	fi
	@-$(CMP) $(srcdir)/poundbang.awk _`basename $@` && rm -f _`basename $@` _pbd.awk

messages::
	@echo $@
	@$(AWK) -f $(srcdir)/messages.awk >out2 2>out3
	@-$(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3

argarray::
	@echo $@
	@case $(srcdir) in \
	.)	: ;; \
	*)	cp $(srcdir)/argarray.in . ;; \
	esac
	@TEST=test echo just a test | $(AWK) -f $(srcdir)/argarray.awk ./argarray.in - >_$@
	@case $(srcdir) in \
	.)	: ;; \
	*)	rm -f ./argarray.in ;; \
	esac
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

regtest::
	@echo 'Some of the output from regtest is very system specific, do not'
	@echo 'be distressed if your output differs from that distributed.'
	@echo 'Manual inspection is called for.'
	AWK=$(AWKPROG) $(srcdir)/regtest.sh

manyfiles::
	@echo manyfiles
	@rm -rf junk
	@mkdir junk
	@$(AWK) 'BEGIN { for (i = 1; i <= 1030; i++) print i, i}' >_$@
	@$(AWK) -f $(srcdir)/manyfiles.awk _$@ _$@
	@wc -l junk/* | $(AWK) '$$1 != 2' | wc -l | sed "s/  *//g" > _$@
	@rm -rf junk
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

compare::
	@echo $@
	@$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

inftest::
	@echo $@
	@echo This test is very machine specific...
	@$(AWK) -f $(srcdir)/inftest.awk | sed "s/inf/Inf/g" >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

getline2::
	@echo $@
	@$(AWK) -f $(srcdir)/getline2.awk $(srcdir)/getline2.awk $(srcdir)/getline2.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

awkpath::
	@echo $@
	@AWKPATH="$(srcdir)$(PATH_SEPARATOR)$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

argtest::
	@echo $@
	@$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

badargs::
	@echo $@
	@-$(AWK) -f 2>&1 | grep -v patchlevel >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

nonl::
	@echo $@
	@-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

strftime::
	@echo This test could fail on slow machines or on a minute boundary,
	@echo so if it does, double check the actual results:
	@echo $@
	@GAWKLOCALE=C; export GAWKLOCALE; \
	TZ=GMT0; export TZ; \
	(LC_ALL=C date) | $(AWK) -v OUTPUT=_$@ -f $(srcdir)/strftime.awk
	@-$(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0

litoct::
	@echo $@
	@echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

devfd::
	@echo $@
	@$(AWK) 1 /dev/fd/4 /dev/fd/5 4<$(srcdir)/devfd.in4 5<$(srcdir)/devfd.in5 >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

fflush::
	@echo $@
	@$(srcdir)/fflush.sh >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

tweakfld::
	@echo $@
	@$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@
	@rm -f errors.cleanup
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mmap8k::
	@echo $@
	@$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@
	@-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@

tradanch::
	@echo $@
	@$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

# AIX /bin/sh exec's the last command in a list, therefore issue a ":"
# command so that pid.sh is fork'ed as a child before being exec'ed.
pid::
	@echo pid
	@AWKPATH=$(srcdir) AWK=$(AWKPROG) $(SHELL) $(srcdir)/pid.sh $$$$ > _`basename $@` ; :
	@-$(CMP) $(srcdir)/pid.ok _`basename $@` && rm -f _`basename $@`

strftlng::
	@echo $@
	@TZ=UTC; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@
	@if $(CMP) $(srcdir)/strftlng.ok _$@ >/dev/null 2>&1 ; then : ; else \
	TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \
	fi
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

nors::
	@echo $@
	@echo A B C D E | tr -d '\12\15' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

fmtspcl.ok: fmtspcl.tok Makefile
	@$(AWK) -v "sd=$(srcdir)" 'BEGIN {pnan = sprintf("%g",sqrt(-1)); nnan = sprintf("%g",-sqrt(-1)); pinf = sprintf("%g",-log(0)); ninf = sprintf("%g",log(0))} {sub(/positive_nan/,pnan); sub(/negative_nan/,nnan); sub(/positive_infinity/,pinf); sub(/negative_infinity/,ninf); sub(/fmtspcl/,(sd"/fmtspcl")); print}' < $(srcdir)/fmtspcl.tok > $@ 2>/dev/null

fmtspcl: fmtspcl.ok
	@echo fmtspcl
	@$(AWK) -f $(srcdir)/fmtspcl.awk  --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $@.ok _$@ && rm -f _$@

reint::
	@echo $@
	@$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

pipeio1::
	@echo $@
	@$(AWK) -f $(srcdir)/pipeio1.awk >_$@
	@rm -f test1 test2
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

pipeio2::
	@echo $@
	@$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

clobber::
	@echo $@
	@$(AWK) -f $(srcdir)/clobber.awk >_$@
	@-$(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@
	@rm -f seq

arynocls::
	@echo $@
	@-AWKPATH=$(srcdir) $(AWK) -v INPUT=$(srcdir)/arynocls.in -f arynocls.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

getlnbuf::
	@echo $@
	@-AWKPATH=$(srcdir) $(AWK) -f getlnbuf.awk $(srcdir)/getlnbuf.in > _$@
	@-AWKPATH=$(srcdir) $(AWK) -f gtlnbufv.awk $(srcdir)/getlnbuf.in > _2$@
	@-$(CMP) $(srcdir)/getlnbuf.ok _$@ && $(CMP) $(srcdir)/getlnbuf.ok _2$@ && rm -f _$@ _2$@

inetmesg::
	@echo These tests only work if your system supports the services
	@echo "'discard'" at port 9 and "'daytimed'" at port 13. Check your
	@echo file /etc/services and do "'netstat -a'".

inetechu::
	@echo This test is for establishing UDP connections
	@$(AWK) 'BEGIN {print "" |& "/inet/udp/0/127.0.0.1/9"}'

inetecht::
	@echo This test is for establishing TCP connections
	@$(AWK) 'BEGIN {print "" |& "/inet/tcp/0/127.0.0.1/9"}'

inetdayu::
	@echo This test is for bidirectional UDP transmission
	@$(AWK) 'BEGIN { print "" |& "/inet/udp/0/127.0.0.1/13"; \
	"/inet/udp/0/127.0.0.1/13" |& getline; print $0}'

inetdayt::
	@echo This test is for bidirectional TCP transmission
	@$(AWK) 'BEGIN { print "" |& "/inet/tcp/0/127.0.0.1/13"; \
	"/inet/tcp/0/127.0.0.1/13" |& getline; print $0}'

redfilnm::
	@echo $@
	@$(AWK) -f $(srcdir)/redfilnm.awk srcdir=$(srcdir) $(srcdir)/redfilnm.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

leaddig::
	@echo $@
	@$(AWK) -v x=2E  -f $(srcdir)/leaddig.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

gsubtst3::
	@echo $@
	@$(AWK) --re-interval -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

space::
	@echo $@
	@$(AWK) -f ' ' $(srcdir)/space.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

printf0::
	@echo $@
	@$(AWK) --posix -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rsnulbig::
	@echo $@
	@ : Suppose that block size for pipe is at most 128kB:
	@$(AWK) 'BEGIN { for (i = 1; i <= 128*64+1; i++) print "abcdefgh123456\n" }' 2>&1 | \
	$(AWK) 'BEGIN { RS = ""; ORS = "\n\n" }; { print }' 2>&1 | \
	$(AWK) '/^[^a]/; END{ print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rsnulbig2::
	@echo $@
	@$(AWK) 'BEGIN { ORS = ""; n = "\n"; for (i = 1; i <= 10; i++) n = (n n); \
		for (i = 1; i <= 128; i++) print n; print "abc\n" }' 2>&1 | \
		$(AWK) 'BEGIN { RS = ""; ORS = "\n\n" };{ print }' 2>&1 | \
		$(AWK) '/^[^a]/; END { print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

wideidx::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk  < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

wideidx2::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

widesub::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

widesub2::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

widesub3::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk  < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

widesub4::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

ignrcas2::
	@echo $@
	@GAWKLOCALE=en_US ; export GAWKLOCALE ; \
	$(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

subamp::
	@echo $@
	@GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
	$(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

# This test makes sure gawk exits with a zero code.
# Thus, unconditionally generate the exit code.
exitval1::
	@echo $@
	@$(AWK) -f $(srcdir)/exitval1.awk >_$@ 2>&1; echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

fsspcoln::
	@echo $@
	@$(AWK) -f $(srcdir)/$@.awk 'FS=[ :]+' $(srcdir)/$@.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rsstart1::
	@echo $@
	@$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rsstart2::
	@echo $@
	@$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rsstart3::
	@echo $@
	@head $(srcdir)/rsstart1.in | $(AWK) -f $(srcdir)/rsstart2.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rtlen::
	@echo $@
	@$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rtlen01::
	@echo $@
	@$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rtlenmb::
	@echo $@
	@GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
	$(srcdir)/rtlen.sh >_$@ || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/rtlen.ok _$@ && rm -f _$@

nondec2::
	@echo $@
	@$(AWK) --non-decimal-data -v a=0x1 -f $(srcdir)/$@.awk >_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

nofile::
	@echo $@
	@$(AWK) '{}' no/such/file >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

binmode1::
	@echo $@
	@$(AWK) -v BINMODE=3 'BEGIN { print BINMODE }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

subi18n::
	@echo $@
	@GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk > _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

concat4::
	@echo $@
	@GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in > _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

devfd1::
	@echo $@
	@$(AWK) -f $(srcdir)/$@.awk 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

# The program text is the '1' which will print each record. How compact can you get?
devfd2::
	@echo $@
	@$(AWK) 1 /dev/fd/4 /dev/fd/5 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mixed1::
	@echo $@
	@$(AWK) -f /dev/null --source 'BEGIN {return junk}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mtchi18n::
	@echo $@
	@GAWKLOCALE=ru_RU.UTF-8 ; export GAWKLOCALE ; \
	$(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

reint2::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) --re-interval -f $@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

localenl::
	@echo $@
	@$(srcdir)/$@.sh >_$@ 2>/dev/null
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mbprintf1::
	@echo $@
	@GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
	$(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mbprintf2::
	@echo $@
	@GAWKLOCALE=ja_JP.UTF-8 ; export GAWKLOCALE ; \
	$(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mbprintf3::
	@echo $@
	@GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
	$(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mbfw1::
	@echo $@
	@GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \
	$(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

gsubtst6::
	@echo $@
	@GAWKLOCALE=C ; $(AWK) -f $(srcdir)/$@.awk > _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

mbstr1::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

printfbad2: printfbad2.ok
	@echo $@
	@$(AWK) --lint -f $(srcdir)/$@.awk $(srcdir)/$@.in 2>&1 | sed 's;\$(srcdir)/;;g' >_$@ || echo EXIT CODE: $$?  >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

beginfile1::
	@echo $@
	@AWKPATH=$(srcdir) $(AWK) -f $@.awk $(srcdir)/$@.awk . ./no/such/file Makefile  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

beginfile2:
	@echo $@
	@-( cd $(srcdir) && LC_ALL=C AWK="$(abs_builddir)/$(AWKPROG)" $(srcdir)/$@.sh $(srcdir)/$@.in ) > _$@ 2>&1
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

dumpvars::
	@echo $@
	@AWKPATH=$(srcdir) $(AWK) --dump-variables 1 < $(srcdir)/$@.in >/dev/null 2>&1 || echo EXIT CODE: $$? >>_$@
	@mv awkvars.out _$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

profile1:
	@echo $@
	@$(AWK) --profile=ap-$@.out -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > _$@.out1
	@$(AWK) -f ap-$@.out $(srcdir)/dtdgport.awk > _$@.out2 ; rm ap-$@.out
	@cmp _$@.out1 _$@.out2 && rm _$@.out[12] || echo EXIT CODE: $$? >>_$@

profile2:
	@echo $@
	@$(PGAWK) --profile=ap-$@.out -v sortcmd=sort -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > /dev/null
	@sed 1,2d < ap-$@.out > _$@; rm ap-$@.out
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

profile3:
	@echo $@
	@$(PGAWK) --profile=ap-$@.out -f $(srcdir)/$@.awk > /dev/null
	@sed 1,2d < ap-$@.out > _$@; rm ap-$@.out
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

posix2008sub:
	@echo $@
	@$(AWK) --posix -f $(srcdir)/$@.awk > _$@ 2>&1
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

next:
	@echo $@
	@-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
	@-LC_ALL=C $(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

exit:
	@echo $@
	@-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rri1::
	@echo $@
	@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
	AWKPATH=$(srcdir) $(AWK) -f $@.awk  < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
	@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

# Targets generated for other tests:
include Maketests

$(srcdir)/Maketests: $(srcdir)/Makefile.am $(srcdir)/Gentests
	files=`cd "$(srcdir)" && echo *.awk *.in`; \
	$(AWK) -f $(srcdir)/Gentests "$(srcdir)/Makefile.am" $$files > $(srcdir)/Maketests

clean:
	rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 test2 seq *~

# An attempt to print something that can be grepped for in build logs
pass-fail:
	@COUNT=`ls _* 2>/dev/null | wc -l` ; \
	if test $$COUNT = 0 ; \
	then	echo ALL TESTS PASSED ; \
	else	echo $$COUNT TESTS FAILED ; \
	fi

# This target for my convenience to look at all the results
diffout:
	for i in _* ; \
	do  \
		if [ "$$i" != "_*" ]; then \
		echo ============== $$i ============= ; \
		if [ -r $${i#_}.ok ]; then \
		diff -c $${i#_}.ok $$i ; \
		else \
		diff -c $(srcdir)/$${i#_}.ok  $$i ; \
		fi ; \
		fi ; \
	done | more

# convenient way to scan valgrind results for errors
valgrind-scan:
	@echo "Scanning valgrind log files for problems:"
	@$(AWK) '\
	function show() {if (cmd) {printf "%s: %s\n",FILENAME,cmd; cmd = ""}; \
	  printf "\t%s\n",$$0}; \
	{$$1 = ""}; \
	/Prog and args are:/ {incmd = 1; cmd = ""; next}; \
	incmd {if (NF == 1) incmd = 0; else {cmd = (cmd $$0); next}}; \
	/ERROR SUMMARY:/ && !/: 0 errors from 0 contexts/ {show()}; \
	/definitely lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \
	/possibly lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \
	/ suppressed:/ && !/: 0 bytes in 0 blocks/ {show()}; \
	' log.[0-9]*

# This target is for testing with electric fence.
efence:
	for i in $$(ls _* | sed 's;_\(.*\);\1;') ; \
	do \
		bad=$$(wc -l < _$$i) \
		ok=$$(wc -l < $$i.ok) ; \
		if (( $$bad == $$ok + 2 )) ; \
		then \
			rm _$$i ; \
		fi ; \
	done
