mirror of https://github.com/PCSX2/pcsx2.git
test: improve the test runner
Improve the configuration of the build (log) Run on multiple CPU (not tested) Remove the logging hack in the GUI Still miss: * result * help
This commit is contained in:
parent
b9c5ab08a8
commit
68daf5f0ad
|
@ -496,9 +496,6 @@ bool Pcsx2App::OnInit()
|
|||
else if ( Startup.SysAutoRunElf )
|
||||
{
|
||||
g_Conf->EmuOptions.UseBOOT2Injection = true;
|
||||
// Enable iop/ee logging
|
||||
SysConsole.eeConsole.Enabled = true;
|
||||
SysConsole.iopConsole.Enabled = true;
|
||||
|
||||
sApp.SysExecute( Startup.CdvdSource, Startup.ElfFile );
|
||||
}
|
||||
|
|
|
@ -6,17 +6,23 @@ use threads;
|
|||
|
||||
use Getopt::Long;
|
||||
use File::Find;
|
||||
use File::Spec;
|
||||
use Cwd;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
sub help {
|
||||
# always useful
|
||||
exit
|
||||
}
|
||||
|
||||
my ($o_suite, $o_help, $o_exe);
|
||||
my ($o_suite, $o_help, $o_exe, $o_cfg, $o_max_cpu);
|
||||
$o_max_cpu = 1;
|
||||
my $status = Getopt::Long::GetOptions(
|
||||
'suite=s' => \$o_suite,
|
||||
'cfg=s' => \$o_cfg,
|
||||
'cpu' => \$o_max_cpu, # FIXME not tested
|
||||
'exe=s' => \$o_exe,
|
||||
'help' => \$o_help,
|
||||
'suite=s' => \$o_suite,
|
||||
);
|
||||
|
||||
unless ($status) {
|
||||
|
@ -33,24 +39,35 @@ unless (defined $o_exe) {
|
|||
help();
|
||||
}
|
||||
|
||||
unless (defined $o_cfg) {
|
||||
print "Error: require a deafult cfg directory\n";
|
||||
help();
|
||||
}
|
||||
$o_cfg = abs_path($o_cfg);
|
||||
|
||||
|
||||
# Round 1: Collect the tests
|
||||
my $g_test_db;
|
||||
print "Info: search test in $o_suite\n";
|
||||
find(\&add_test_cmd_for_elf, $o_suite);
|
||||
find({ wanted => \&add_test_cmd_for_elf, no_chdir => 1 }, $o_suite);
|
||||
|
||||
# Round 2: Run the tests (later in thread)
|
||||
foreach my $t (keys(%$g_test_db)) {
|
||||
my $info = $g_test_db->{$t};
|
||||
run_elf($t, $info->{"CFG_DIR"}, $info->{"OUT"});
|
||||
# wait free CPU slot
|
||||
while( scalar(threads->list() >= $o_max_cpu) ) {
|
||||
if (close_joinnable_threads() == 0) {
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
create_thread($t);
|
||||
}
|
||||
wait_all_threads();
|
||||
|
||||
# Round 3: Collect the results
|
||||
|
||||
#####################################################
|
||||
|
||||
sub generate_cfg {
|
||||
}
|
||||
|
||||
sub collect_result {
|
||||
}
|
||||
|
@ -58,18 +75,53 @@ sub collect_result {
|
|||
sub add_test_cmd_for_elf {
|
||||
my $file = $_;
|
||||
return 0 unless ($file =~ /\.elf/);
|
||||
return 0 unless ($file =~ /branchdelay/);
|
||||
# Fast test
|
||||
#return 0 unless ($file =~ /branchdelay/);
|
||||
|
||||
my $dir = $File::Find::dir;
|
||||
print "INFO: found $file in $dir\n";
|
||||
|
||||
$g_test_db->{$File::Find::name}->{"CFG_DIR"} = $File::Find::dir;
|
||||
$g_test_db->{$File::Find::name}->{"CFG_DIR"} = $File::Find::name =~ s/\.elf/_cfg/r;
|
||||
$g_test_db->{$File::Find::name}->{"EXPECTED"} = $File::Find::name =~ s/\.elf/.expected/r;
|
||||
$g_test_db->{$File::Find::name}->{"OUT"} = $File::Find::name =~ s/\.elf/.PCSX2.out/r;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub run_thread {
|
||||
my $test = shift;
|
||||
my $info = $g_test_db->{$test};
|
||||
|
||||
generate_cfg($info->{"CFG_DIR"});
|
||||
|
||||
run_elf($test, $info->{"CFG_DIR"}, $info->{"OUT"});
|
||||
}
|
||||
|
||||
sub generate_cfg {
|
||||
my $out_dir = shift;
|
||||
|
||||
#system("rm -fr $out_dir");
|
||||
system("cp -a --remove-destination --no-target-directory $o_cfg $out_dir");
|
||||
# Enable the logging to get the trace log
|
||||
my $ui_ini = File::Spec->catfile($out_dir, "PCSX2_ui.ini");
|
||||
my $vm_ini = File::Spec->catfile($out_dir, "PCSX2_vm.ini");
|
||||
|
||||
my %sed;
|
||||
# Enable logging for test
|
||||
$sed{".EEout"} = "enabled";
|
||||
$sed{".IOPout"} = "enabled";
|
||||
$sed{"ConsoleToStdio"} = "enabled";
|
||||
# FIXME add interpreter vs recompiler
|
||||
# FIXME add clamping / rounding option
|
||||
# FIXME need separate cfg dir !
|
||||
|
||||
foreach my $option (keys(%sed)) {
|
||||
my $v = $sed{$option};
|
||||
system("sed -i -e 's/$option=.*/$option=$v/' $ui_ini");
|
||||
system("sed -i -e 's/$option=.*/$option=$v/' $vm_ini");
|
||||
}
|
||||
}
|
||||
|
||||
sub run_elf {
|
||||
my $elf = shift;
|
||||
my $cfg = shift;
|
||||
|
@ -79,8 +131,8 @@ sub run_elf {
|
|||
my $dump = 0;
|
||||
open(my $run, ">$out") or die "Impossible to open $!";
|
||||
|
||||
# FIXME timeout + cfg support
|
||||
my $pid = open(my $log, "$o_exe --elf $elf |") or die "Impossible to pipe $!";
|
||||
# FIXME timeout
|
||||
my $pid = open(my $log, "$o_exe --elf $elf --cfgpath=$cfg |") or die "Impossible to pipe $!";
|
||||
print "Info: Execute $elf (PID=$pid) with cfg ($cfg)\n";
|
||||
|
||||
while ($line = <$log>) {
|
||||
|
@ -98,3 +150,33 @@ sub run_elf {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#####################################################
|
||||
# Thread management
|
||||
#####################################################
|
||||
my $g_counter = 0;
|
||||
sub create_thread {
|
||||
my $cmd = shift;
|
||||
|
||||
my $thr = threads->create(\&run_thread, $cmd );
|
||||
|
||||
$g_counter++;
|
||||
}
|
||||
|
||||
sub close_joinnable_threads {
|
||||
my $closed = 0;
|
||||
foreach my $thr (threads->list(threads::joinable)) {
|
||||
$thr->join();
|
||||
$closed = 1;
|
||||
$g_counter--;
|
||||
}
|
||||
|
||||
return $closed;
|
||||
}
|
||||
|
||||
sub wait_all_threads {
|
||||
foreach my $thr (threads->list()) {
|
||||
$thr->join();
|
||||
$g_counter--;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue