On Jun 30, 2009, at 6:46 AM, venutaurus...@gmail.com wrote:

      I have to write an automted script which will test my c
program. That program when run will ask for the commands.

Keep in mind that, if your test script checks the program's output before giving it input, you can run into problems with buffering. The standard C library uses line-based buffering when a program is using a terminal for output, but when it's outputting to a pipe it uses block buffering. This can be a problem when running a process using subprocess--your program will buffer the prompt, and your test script won't see it, so the test will deadlock. The problem can also exist in the opposite direction.

Possible solutions:
- Explicitly set both your test script and your program to have line- buffered output. - Add a flush statement whenever you finish writing output and expect input. - Use pexpect, which uses a pseudo-tty and will make C stdio default to line buffering. - Use pdpi's solution, which, since it doesn't wait for a prompt before supplying input, doesn't have this issue.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to