autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AT_CHECK within for loop


From: Joel E. Denny
Subject: Re: AT_CHECK within for loop
Date: Fri, 28 Jan 2011 12:49:59 -0500 (EST)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

Hi,

On Fri, 28 Jan 2011, Eric Blake wrote:

> On 01/27/2011 05:20 PM, Daily, Jeff A wrote:
> > In a nutshell, I've written a drop-in replacement of another tool and would 
> > like to test that it functions identical to the original.  All you need to 
> > know about these tools is that they take as input one or more binary files 
> > and produce a single binary file.  Of course they do more than that, but 
> > the details aren't important.  Also, in order to compare the binary output 
> > files, I've written another tool "pgcmp".
> > 
> > The input files are stored in a data directory.  The number of files in 
> > this directory can change.  It'd like to perform the same tests against 
> > every input file in the data directory, but have the ability to skep files 
> > which might not meet some sort of criteria.  Something like:
> > 
> > AT_SETUP([testing $file, no arguments])
> > for file in $datadir/*
> > do
> >     AS_IF([bad $file], [continue])
> >     AT_CHECK([replacement $file -o replacement.out])
> >     AT_CHECK([original $file -o original.out])
> >     AT_CHECK([pgcmp replacement.out original.out])
> > done
> > AT_CLEANUP
> > 
> > Is this allowed/okay?

Jeff's AT_SETUP argument references $file.  That implies he really wants 
the AT_SETUP and AT_CLEANUP inside the loop.  That's a use case I've 
encountered recently.

> Absolutely!  AT_CHECK is just a macro that expands to shell code; it is
> perfectly legal to surround it by additional shell code that adds
> conditions on whether the AT_CHECK will be reached.

In my experience, that's true for AT_CHECK, but it isn't true for AT_SETUP 
and AT_CLEANUP.  In that case, the loop must be written using m4 
constructs not shell constructs.  Because I speak shell more easily than 
m4, I'd be happy to hear that I'm wrong.

Another alternative is to generate the Autotest script from some other 
script.  Ultimately, this is the solution I settled on in order to save 
myself and my co-workers from having to maintain complex m4 code.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]