如何在expect脚本中嵌入gcc和gcov命令
我想嵌入 gcc 和 gcov 命令作为期望脚本的一部分..
我尝试了..
#!/usr/bin/expect -f
send ":gcc -fprofile-arcs -ftest-coverage c.c\r"
send ":gcov c.c\r"
但它不运行并执行命令。
对此有何见解?谢谢。
我遇到的问题是我不确定如何将命令嵌入到正确的位置。我所知道的是有一个给定的测试用例,如下所示:-
#!/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
}
它包含在名为 testfile.txt 的特定文件中。在 Perl 脚本中执行此测试文件后,就会生成输出。
如下所示:
$IN_DIR/$SCRIPT_FILE;
$outfile = "$OUT_DIR/t$scriptCounter";
我尝试将您之前建议的期望命令放在一个名为的单独文件中,并将其传递给 $IN_DIR
中名为 ...$MY_FILE
的新变量。
然后,我通过了 $IN_DIR/$MY_FILE
;
但它没有做任何事情。 .gcno 文件也不会执行,因此 .gcov 文件也不会被执行。
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Expect 对于交互式程序很有用,而不是命令行实用程序。如果您只想执行
gcc
和gcov
作为 Expect 脚本的一部分,请执行以下操作:顺便说一句,在不先运行可执行文件的情况下运行
gcov
是徒劳的:您需要生成运行时覆盖率数据,然后才能对其进行分析。Expect is useful for interactive programs, not for command-line utilities. If you want to just execute
gcc
andgcov
as part of expect script, do this:BTW, running
gcov
without first running the executable is futile: you need to produce the runtime coverage data before you can analyze it.