tags:

views:

80

answers:

2

Hi, I wanted to embed gcc and gcov command as part of expect script..

I tried as..

#!/usr/bin/expect -f
send ":gcc -fprofile-arcs -ftest-coverage c.c\r"

send ":gcov c.c\r"

But it doesnt run and execute the commands.

Any insights to this? Thanks.

+1  A: 

Expect is useful for interactive programs, not for command-line utilities. If you want to just execute gcc and gcov as part of expect script, do this:

exec gcc -fprofile-arcs -ftest-coverage c.c
exec gcov c.c

BTW, running gcov without first running the executable is futile: you need to produce the runtime coverage data before you can analyze it.

Employed Russian
A: 

Hi,

The problem I have is I am not sure how can I embed the command at the right place. All I know was there is a given test cases as below :-

!/usr/bin/expect -f

spawn $env(SUBJECTS_SRC_DIR)/vim -u $env(HOME)/.vimrc $env(TESTS_SRC)/copy1 expect "copy1" sleep 1 send ":se lines=24\r" send ":se columns=80\r" send ":redir >> move_2.1.1.out\r" send "$" send "\007" send "5h"

send "\007" send ":redir END\r"

send ":wq\r" expect exit -onexit { interact }

This is contained in a specific file named testfile. Once this testfile is executed in Perl script, an output is generated.

Something like below:- $IN_DIR/$SCRIPT_FILE;

$outfile = "$OUT_DIR/t$scriptCounter";

I tried to put the expect command which you have suggested earlier in a separate file named and passed to a new variable named...$MY_FILE in $IN_DIR.

And then, i passed $IN_DIR/$MY_FILE;

but it doesnt do anything. The .gcno files are not executed either so thus .gcov.

-joey

joey
This script seems to be extracting some info from copy1 and putting it in move_2.1.1.out, can't understand what without seeing the input and output files. But the method used (using expect to drive a vim sesssion) is unbelievably awkward. Since Perl is also involved it probably be far simpler to to all this processing directly in perl.
Colin Macleod
Also, this isn't a discussion forum. Instead of posting an answer which merely clarifies the question, please *edit* the original question (and delete this "pseudo answer").
Employed Russian