1
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++;
    }

我在日志文件中有两个测试用例ActivateJobGetJOBStatus如下所示。

我的 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
4

1 回答 1

4
if ($status = ~/ACTIVE/)

不是正则表达式检查,空格放错地方了。如果没有严格或警告,它可能会将 '~/ACTIVE/' 视为裸字字符串,然后将其分配给 $status。

于 2013-06-27T14:51:38.213 回答