HIT: Support make_named_test
Change-Id: I7472c14595f10c4f2e2cf8d0228cc0373458a0b7
[ROCm/hip commit: b4426e4c26]
This commit is contained in:
@@ -8,29 +8,38 @@ use File::Spec;
|
||||
sub parse_file {
|
||||
my $file = shift;
|
||||
(my $exe = $file) =~ s/\.[^.]+$//g;
|
||||
my (@buildCMDs, @runCMDs);
|
||||
my (@buildCMDs, @runCMDs, @runNamedCMDs);
|
||||
if (open (SOURCE, '<:encoding(UTF-8)', "$file")) {
|
||||
while (<SOURCE>) {
|
||||
my $line=$_;
|
||||
# Look for BUILD instructions
|
||||
if ($line =~ /^ \* BUILD:/) {
|
||||
$line =~ s/^ \* BUILD: //g; # Remove " * BUILD: "
|
||||
$line =~ s/%s/$file/g; # Substitute %s -> filename
|
||||
$line =~ s/%t/$exe/g; # Substitute %t -> targetname
|
||||
$line =~ s/\R//g; # Remove line endings
|
||||
$line =~ s/^ \* BUILD: //g; # Remove " * BUILD: "
|
||||
$line =~ s/%s/$file/g; # Substitute %s -> filename
|
||||
$line =~ s/%t/$exe/g; # Substitute %t -> targetname
|
||||
$line =~ s/\R//g; # Remove line endings
|
||||
push @buildCMDs, $line;
|
||||
}
|
||||
# Look for RUN instructions
|
||||
if ($line =~ /^ \* RUN:/) {
|
||||
$line =~ s/^ \* RUN: //g; # Remove " * RUN: "
|
||||
$line =~ s/%t/$exe/g; # Subsitute %t -> targetname
|
||||
$line =~ s/\R//g; # Remove line endings
|
||||
$line =~ s/^ \* RUN: //g; # Remove " * RUN: "
|
||||
$line =~ s/%s/$file/g; # Substitute %s -> filename
|
||||
$line =~ s/%t/$exe/g; # Subsitute %t -> targetname
|
||||
$line =~ s/\R//g; # Remove line endings
|
||||
push @runCMDs, $line;
|
||||
}
|
||||
# Look for RUN_NAMED instructions
|
||||
if ($line =~ /^ \* RUN_NAMED:/) {
|
||||
$line =~ s/^ \* RUN_NAMED: //g; # Remove " * RUN_NAMED: "
|
||||
$line =~ s/%s/$file/g; # Substitute %s -> filename
|
||||
$line =~ s/%t/$exe/g; # Subsitute %t -> targetname
|
||||
$line =~ s/\R//g; # Remove line endings
|
||||
push @runNamedCMDs, $line;
|
||||
}
|
||||
}
|
||||
close(SOURCE);
|
||||
}
|
||||
return (\@buildCMDs, \@runCMDs);
|
||||
return (\@buildCMDs, \@runCMDs, \@runNamedCMDs);
|
||||
}
|
||||
|
||||
# Exit if no arguments specified
|
||||
@@ -43,8 +52,9 @@ if(scalar @ARGV == 0){
|
||||
my @options = ();
|
||||
my $retBuildCMDs = 0;
|
||||
my $retRunCMDs = 0;
|
||||
my $retRunNamedCMDs = 0;
|
||||
foreach $arg (@ARGV) {
|
||||
if ($retBuildCMDs or $retRunCMDs) {
|
||||
if ($retBuildCMDs or $retRunCMDs or $retRunNamedCMDs) {
|
||||
push (@options, $arg);
|
||||
}
|
||||
if ($arg eq '--buildCMDs') {
|
||||
@@ -53,18 +63,21 @@ foreach $arg (@ARGV) {
|
||||
if ($arg eq '--runCMDs') {
|
||||
$retRunCMDs = 1;
|
||||
}
|
||||
if ($arg eq '--runNamedCMDs') {
|
||||
$retRunNamedCMDs = 1;
|
||||
}
|
||||
}
|
||||
|
||||
# Atleast one command needs to be specified
|
||||
if ($retBuildCMDs eq 0 and $retRunCMDs eq 0) {
|
||||
die "Usage: $0 <--buildCMDs|--runCMDs> FILENAMEs\n";
|
||||
if (($retBuildCMDs eq 0) and ($retRunCMDs eq 0) and ($retRunNamedCMDs eq 0)) {
|
||||
die "Usage: $0 <--buildCMDs|--runCMDs|--runNamedCMDs> FILENAMEs\n";
|
||||
}
|
||||
|
||||
# Iterate over input files
|
||||
foreach $file (@options) {
|
||||
# Convert absolute path to path relative to working directory
|
||||
my $relfile = File::Spec->abs2rel($file);
|
||||
my ($buildCMDs, $runCMDs) = parse_file("$relfile");
|
||||
my ($buildCMDs, $runCMDs, $runNamedCMDs) = parse_file("$relfile");
|
||||
if ($retBuildCMDs) {
|
||||
# print "BuildCMDs:\n";
|
||||
print "$_\n" for @$buildCMDs;
|
||||
@@ -73,6 +86,10 @@ foreach $file (@options) {
|
||||
# print "RunCMDs:\n";
|
||||
print "$_\n" for @$runCMDs;
|
||||
}
|
||||
if ($retRunNamedCMDs) {
|
||||
# print "RunNamedCMDs:\n";
|
||||
print "$_\n" for @$runNamedCMDs;
|
||||
}
|
||||
}
|
||||
|
||||
# vim: ts=4:sw=4:expandtab:smartindent
|
||||
|
||||
Reference in New Issue
Block a user