- 论坛徽章:
- 12
|
本帖最后由 523066680 于 2017-05-22 12:09 编辑
没有测试环境,人肉编辑了一下。不知道能不能正常运行
1. 字符串数组改用qw//括起来省去双引号和逗号。
2. if (xxx ) 改为了 "next unless (xxx);" 少了几层镶嵌,8个空格缩进改为4个空格
3. 左边花括号统一换行
4. foreach 统一改成 for
5. Logger::log(Logger::INFORMATIONAL, "") 这么长,弄到小函数里了
不知道 $testCommand 的内容是咋样的,有些 for + if 可能可以换成 $test ~~ @array 的形式,可能。
my $cmd = undef;
my $cmdresult = undef;
my $recordFile = undef;
my $line = undef;
my $recordFileName = undef;
my $dumpFormat = undef;
my $playList = undef;
# Used for getting the record file
my @recordFileName = qw/cam fromfile dump encoder videosrcsh264enc/;
#Used for getting the dump file which can't be playback in the device
my @dumpFormat = qw/.avi .mkv .h263 .264 .h265 .NV12 .nv12 .dump .mpeg4 .yuv/;
#Used for checking the record file could be playback
my @playList = qw/.avi .mkv .h263 .264 .h265 .mpeg4/;
#core dump format, no need to play
my @nonPlayList = qw/.NV12 .nv12 .dump .yuv/;
my $checkResult = CommonUtils::FAIL;
#Got dunmp file name from the testCommand first;
for $recordFile (split/\/+|\s/,$testCommand)
{
for $recordFileName (@recordFileName)
{
next unless ( $recordFile =~ /$recordFileName/ );
for $dumpFormat (@dumpFormat)
{
next unless ( $recordFile =~ /$dumpFormat/ );
next unless ( CommonUtils::isExists("$recordPath/$recordFile","-f") );
loginfo("Found the recorded file: $recordFile");
for $playList (@playList)
{
$checkResult = CommonUtils::FAIL;
next unless ( $recordFile =~ /$playList/ );
$cmd = "adb shell su -c 'gst-play-1.0 $recordPath/$recordFile'";
$cmdresult = Command::getOutput($cmd);
for $line (split /\n/, $cmdresult)
{
loginfo($line);
next unless ($line =~ /Setting pipeline to PLAYING/);
loginfo("\n play the recored file: $recordFile successfully\n");
$checkResult = CommonUtils::PASS;
}
}
for $playList (@nonPlayList)
{
if ($recordFile =~ /$playList/ )
{
$checkResult = CommonUtils::PASS;
}
}
if ($checkResult == CommonUtils::FAIL)
{
loginfo("\n Found error with recored file: $recordFile \n");
}
}
}
}
print("checkResult: $checkResult\n\n");
return $checkResult;
sub loginfo
{
Logger::log(Logger::INFORMATIONAL, shift);
}
|
|
|