Skip to content

Instantly share code, notes, and snippets.

Last active November 18, 2020 14:11
What would you like to do?
Run and display a cts test, save the result image in a directory png/<testname.png> for later, ./run_cts -h
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";
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";
if ($line =~ m/^.*\<Image\sName\=\"Result.*$/) {
$is_image_data = 1;
} elsif ($line =~ m/^.*\<\/Image>.*$/) {
$is_image_data = 0;
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