This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: frysk.expunit, Expect like functionality within JUnit


Andrew Cagney wrote:
Hello,

The Expect program lets the user interact with a console based program, sending it input and checking its output. The existing testing framework dejagnu builds on expect.

The package frysk.expunit provides functionality similar to Expect, but in a way that integrates into the JUnit framework. By doing this, developers:

-> need only learn JUnit, and this extension, and not an entirely new language (tcl/tk) and test framework (dejagnu)

The current expect tests use tcl, so having the expect-like tests in Java will be a welcome addition. For fcore, the tests are: create an expected fail condition, check that it fails like it should. Here is an existing test:



#start test program, and store pid.
set funit_path [findfile "$pwd/frysk/pkglibdir/funit-child" "$pwd/frysk/pkglibdir/funit-child" funit-child]
set funit_pid [spawn ${funit_path} 100 0 0]
set funit_sid $spawn_id


#start tester program with valid pid, but wrong -console argument
spawn $fcore_path -console frysk=BADLOG $funit_pid

#test output.
expect {
   -re "fcore: Invalid log console: BADLOG"
   {pass test_fcore_bad_console_log_argument}
   default     {fail test_fcore_bad_console_log_argument}
}

So for the purposes of the above test, the new Java Expect should simplfy things nicely. Given the above, would the correct java code be something like:

{start up an example java process, using DetachedAckProcess or AckDaemonProcess}

e = new Expect (new String[] { "fcore", "-console","frysk=BADLOG",myPid});
e.assertExpect ("fcore: Invalid log console: BADLOG");

I'm not sure how you would find the fcore in the above (in-tree and out-of-tree testing), but if the test converts to as simply as above, that is great!

Regards

Phil


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]