开发者

How to embed gcc and gcov command in expect script

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.


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 开发者_C百科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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜