Run and display a cts test, save the result image in a directory png/<testname.png> for later, ./run_cts -h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use diagnostics; | |
use Getopt::Long; | |
use Cwd qw(cwd); | |
my $test = ""; | |
my $dir = ""; | |
my $help; | |
my $silent; | |
my $file_res = "TestResults.qpa"; | |
my $png_dir = "png"; | |
GetOptions("d=s" => \$dir, | |
"t=s" => \$test, | |
"s" => \$silent, | |
"h" => \$help); | |
if ($help) { | |
print qq[Help: | |
-t <test>, which test | |
-d <directory>, where is deqp-vk (default is current directory) | |
-h print this help and exit]."\n"; | |
exit; | |
} | |
if ($test eq "") { | |
die "You must specify the test name\n"; | |
} | |
if ($dir eq "") { | |
$dir = cwd; | |
} | |
if (!(-d $dir)) { | |
die "$dir is not a valid directory:".$!."\n"; | |
} | |
chdir $dir or die "chdir failed to $dir failed:".$!."\n"; | |
#unlink $file_res; | |
if (!(-d $png_dir)) { | |
mkdir $png_dir; | |
} | |
my $bin = qq[deqp-vk]; | |
die "$bin not found in directory: $dir\n" unless -f $bin; | |
my $ret = `./deqp-vk -n $test`; | |
if (!(-f $file_res)) { | |
die "TestResults.qpa not found!\n"; | |
} | |
my $png = $png_dir."/".$test; | |
open (my $ih, '>>', $png) or die $!." failed to open $png\n"; | |
open (my $fh, '<', $file_res) or die $!."\n"; | |
my $is_image_data = 0; | |
my $found_image = 0; | |
while (!eof($fh)){ | |
defined(my $line = readline $fh) or die $!."\n"; | |
chomp($line); | |
if ($line =~ m/^.*\<Image\sName\=\"Result.*$/) { | |
$is_image_data = 1; | |
$found_image++; | |
next; | |
} elsif ($line =~ m/^.*\<\/Image>.*$/) { | |
$is_image_data = 0; | |
next; | |
} | |
if ($is_image_data == 1) { | |
$line =~ s/\s+//g; | |
print $ih $line."\n"; | |
} | |
} | |
close ($fh); | |
close ($ih); | |
if ($found_image) { | |
my $filename_png = $png.".png"; | |
`base64 -d $png > $filename_png`; | |
if (!$silent) { | |
`display $filename_png &`; | |
} | |
} | |
unlink $png; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment