public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Dejagnu testing howto:
@ 2006-12-14 19:58 Nurdin Premji
  0 siblings, 0 replies; only message in thread
From: Nurdin Premji @ 2006-12-14 19:58 UTC (permalink / raw)
  To: frysk

Here is the good news: most of the work for getting dejagnu tests for
command line utilities are already set up.

Here is what is needed for specific tests:

1. Create a new folder under frysk-core/testsuite (or just use the util
directory).

2. Create a file called testname.exp. (Add the (C) to it).

3. Load up some variables and libraries.
global objdir
global srcdir
global frysk_testsuite

load_lib frysk.exp
set pwd [eval pwd]
frysk_init

the pwd is set to the working directory of /builddir/frysk-core/

4. Start up an funit-child process. (Or whatever test process is
needed):

set funit_pid [spawn $pwd/frysk/pkglibdir/funit-child 100 0 0]
set funit_sid $spawn_id

spawn returns a pid which can be stored and used later on if needed.

the spawn_id is used by the function tool_exit (defined in frysk.exp) to
exit a process.

So near the end of your test, when finished with funit-child, run:

tool_exit $funit_sid

5. Run tester program with appropriate input.

spawn $pwd/frysk/bindir/fstack $funit_pid

Here the pid is not needed so it isn't stored, and this function will
exit by itself immediately when finished so the sid is not stored.

6. Test that the tester program output fits what you expect.

Usually this means playing with regular expressions.
Don't use "'s to wrap strings. They are interpreted and can cause
ugliness.

A good way to set up a regular expression is to use a variable and
append to it, this helps break up long regular expressions.

set regex {^First Line\r\n}
append regex {Other Lines...\r\n}
append regex {Last Line \r\n$}

To check the output of your tester program use the command expect:

expect {

	-re regex {pass test_name}
	default	{fail test_name}
}

7. Finish up:

Kill off all test processes:
tool_exit $funit_sid.

clean up testsuite:
frysk_term.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-12-14 19:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-14 19:58 Dejagnu testing howto: Nurdin Premji

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).