Current-Users archive

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

Re: atf for libcurses

On Wed, Nov 03, 2010 at 01:00:08PM +0000, Antti Kantee wrote:
> Awesome!  Soon I'll have the courage to touch curses and be sure
> I didn't break anything.

Well, that is the whole idea of doing this :)

> Apologies if I missed it, but I didn't find how to create the
> expected output files.  The ones I did look at looked, hmm, cryptic,
> so if there some tool to create an output check file which verifies
> that "hello" is printed in exactly the right place on the screen?

Sorry for arm waving over that.  This is probably the hardest bit at
the moment.  What I don't want to do is automate capturing current
output because there may be lurking bugs and we would just enshrine
them into a test which I think is bad.

What I have done is set up a custom terminfo database for a terminal
called "atf", most of the terminfo output sequences are mapped to
their names.  If you look in the source files at the atf.terminfo file
you will see what I mean.  When curses uses the terminfo capabilities
they will be emitted as their names.  So the output stream should be
somewhat readable.

What I have been doing so far is setting the check file to /dev/null
and running the director in verbose mode (-v) which will tell you what
characters in the output stream were mismatched.  Having a look and
think about the output stream and if I believe it correct then putting
that sequence into a check file.

Note that the common sequences can be put into a single check file and
in the test file you can use the "include" directive to check for
common sequences.  An example of this is the initialisation sequence
for curses, I have a "curses_start" file in tests that is included
"curses_getch" which means the normal startup sequence is validated
before we do the getch work.

> Also, can this scheme be extended to curses applications (say, vi)
> and even further to similar applications which don't necessarily
> use curses?

Yes, I think this is doable.  In fact I think it is almost there.  I
have had a bit of a rethink about how I do the output validation.  At
the moment the director looks for a set of function calls that it has
been told will result in output and expects an extra argument to that
call which is the check file.  I think this is a bit limiting now and
that I should introduce a new keyword, something like "validate" or
"verify_output" that will use the check file and perform the stream
comparisons.  If I do this then it would be a matter of doing a new
slave that can exec a program and drive it using the "input"
directives.  Definitely worth thinking about.

> (and finally, do you have a script which ascends in nethack ?)

Given the last time I played rogue my dog bit me and I went blind from
drinking some random potion... I think not.

Brett Lymn
The information contained in this email and any attached files is
confidential to BAE Systems Australia. If you are not the intended
recipient, any use, disclosure or copying of this email or any
attachments is expressly prohibited.  If you have received this email
in error, please notify us immediately. VIRUS: Every care has been
taken to ensure this email and its attachments are virus free,
however, any loss or damage incurred in using this email is not the
sender's responsibility.  It is your responsibility to ensure virus
checks are completed before installing any data sent in this email to
your computer."

Home | Main Index | Thread Index | Old Index