opensubscriber
   Find in this group all groups
 
Unknown more information…

e : expect@listserv.ActiveState.com 18 August 2005 • 9:20PM -0400

[Expect] Expect for windows and DejaGNU
by Frederic RISS

REPLY TO AUTHOR
 
REPLY TO GROUP




Hello,

We are currently evaluating the feasibilty of porting one of our tools
from unix to a native win32 environment using mingw. With the tool comes
its testsuite using the DejaGNU framework and thus Expect for Windows.

I managed to get a lot of things working but I'm still facing some
issues.

First question : has somebody used DejaGNU with expect for windows and
must we be prepared for specific issues with it ?

The second question is about a specific problem I'll explain/demonstrate
here. Take the following little C code :

-------8<----- system.c --------8<----------
#include <windows.h>

int main()
{
  printf("This is the beginning.\n");
  getch();
  system("echo Hello world!");
  getch();
  printf("This is the end.\n");
  return 0;
}
-------8<-----------------------8<----------

It prints a string, waits for a keypress, asks the command interpreter
to run something, waits for a second keypress and prints another string.
It seems there's a strang interaction between the 'system' call and
expect. To test, I use the following expect script :


-------8<----- system.tcl --------8<----------
#!/bin/sh
# \
exec tclsh "$0"  ${1+"$@"}

package require Expect

proc my_expect { expected } {
    expect {
$expected { send_user "Got '$expected' output.\n" }
timeout   { send_user "Timeout triggered for '$expected'.\n" }
    }
}

set timeout 3
spawn system.exe
my_expect "This is the beginning.\n"
send "y"
my_expect "Hello world!\n"
send "y"
my_expect "This is the end.\n"
-------8<-------------------------8<----------

The script times out when waiting for 'Hello world!'. The output I get
is :

D:\test-expect>tclsh system.tcl
This is the beginning.
Got 'This is the beginning.
' output.
Timeout triggered for 'Hello world!
'.
write(spawn_id=]: broken pipe
    while executing
"send "y""
    (file "system.tcl" line 20)

D:\test-expect>

So we timeout looking for the 'system' result, but the very bad thing is
that after this timeout, expect can't send anything to the tested
program anymore. So the question is two-fold :
1 - is there any way to 'expect' the result of the 'system' call ?
2 - Even if there's no way to get it, why does it break the rest of the
script ?

On a related note, I would be glad if someone could point me to a good
documentation regarding the console on windows, and particularly its
behavour when multiple process' (created via 'system' or
'CreateProcess') share a single console. I think I've seen cases where
expect  wasn't able to read outputs of a child process, but I don't have
an example handy.

Kind regards,
Fred


_______________________________________________
Expect mailing list
Expect@list...
http://listserv.ActiveState.com/mailman/listinfo/expect

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.