foreach (@raw_data) {
if ($raw_data[$count] =~ /Date/) {
@dur = split(/:/, $raw_data[$count]);
$durtime = "$dur[1]" . ":" . "$dur[2]" . ":$dur[3]";
@dur = split(/,/, $durtime);
$startlocaltime = $dur[1];
$starttime = str2time($dur[1]);
# $starttime=10000;
$count++;
$status = "PASS";
if ($raw_data[$count] =~ /Command/) {
@cmdsyntax = split(/:/, $raw_data[$count]);
$cmdcount++;
#Splitting Command name
@cmdname = split(/\(/, $cmdsyntax[1]);
$cmdlog = $cmdsyntax[1] . "\n";
$count += 2;
#Parsing for command output
while ($raw_data[$count] =~ /[COMPLETED]/) {
#Checking status of commmand
if ($raw_data[$count] =~ /Error/i) {
$status = "FAIL";
}
if ($raw_data[$count] =~ s/\"/\'/g) {
$raw_data[$count] = $raw_data[$count];
}
if ($raw_data[$count] =~ s/&/ /g) {
$raw_data[$count] = $raw_data[$count];
}
#Forming comandlog
$cmdlog .= $raw_data[$count] . "\n";
$count++;
}
#Changes Added
my $xyz = "false";
if ($raw_data[$count] =~ /^GetFTSJOBStatusResult/) {
my $xyz = "true";
next;
}
if ($xyz =~ /true/) {
if ($line =~ /.*,([A-Za-z]*),.*/) {
$status = $1;
if ($status = ~/ACTIVE/) {
sleep(1000);
system("/bin/sh /tmp/uday/cliTestExecution1.sh 135.250.70.161 alcatel Linux1.* 11.54");
goto START;
}
}
}
#Changes ends
$cmdlog .= $raw_data[$count] . "\n";
$count++;
}
我在日志文件ActivateJob
和GetJOBStatus
中有两个测试用例,如下所示。
我的Perl脚本目前将PASS
设置为默认值,并在以下测试用例中搜索Error
。
如果发现错误,则将测试用例标记为FAIL
。
对于GetJOBStatus
测试用例,如果ACTIVE
脚本必须休眠几分钟,并且必须再次执行GetJOBStatus
,如果成功则必须通过测试用例或者失败。
我已经尝试过添加睡眠几秒钟并再次调用脚本,但这不起作用。
请帮助我找到合适的逻辑。
日志文件
Date and Time is:Thu, 20-06-2013 06:04:19
Line 4 Command:ActivateJob(Job=Test_Abort_New1);
Answer:
ActivateFTSJobResult = Success
COMPLETED
Date and Time is:Thu, 20-06-2013 06:04:19
Line 5 Command:GetJOBStatus(Job=Test_Abort_New1);
Answer:
GetJOBStatusResult = NELabel,Status,ErrorReason,Progress,CurrentUnit,Total
TSS_320_1,ACTIVE,No Error,0,BACKUP.DSC,0
COMPLETED
答案 0 :(得分:4)
if ($status = ~/ACTIVE/)
不是正则表达式检查,空间是在错误的地方。如果没有严格或警告,它可能会将'〜/ ACTIVE /'视为一个裸字符串然后将其分配给$ status。