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 )
|
else if ( Startup.SysAutoRunElf )
|
||||||
{
|
{
|
||||||
g_Conf->EmuOptions.UseBOOT2Injection = true;
|
g_Conf->EmuOptions.UseBOOT2Injection = true;
|
||||||
// Enable iop/ee logging
|
|
||||||
SysConsole.eeConsole.Enabled = true;
|
|
||||||
SysConsole.iopConsole.Enabled = true;
|
|
||||||
|
|
||||||
sApp.SysExecute( Startup.CdvdSource, Startup.ElfFile );
|
sApp.SysExecute( Startup.CdvdSource, Startup.ElfFile );
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,23 @@ use threads;
|
||||||
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
|
use File::Spec;
|
||||||
|
use Cwd;
|
||||||
|
use Cwd 'abs_path';
|
||||||
|
|
||||||
sub help {
|
sub help {
|
||||||
# always useful
|
# always useful
|
||||||
exit
|
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(
|
my $status = Getopt::Long::GetOptions(
|
||||||
'suite=s' => \$o_suite,
|
'cfg=s' => \$o_cfg,
|
||||||
|
'cpu' => \$o_max_cpu, # FIXME not tested
|
||||||
'exe=s' => \$o_exe,
|
'exe=s' => \$o_exe,
|
||||||
'help' => \$o_help,
|
'help' => \$o_help,
|
||||||
|
'suite=s' => \$o_suite,
|
||||||
);
|
);
|
||||||
|
|
||||||
unless ($status) {
|
unless ($status) {
|
||||||
|
@ -33,24 +39,35 @@ unless (defined $o_exe) {
|
||||||
help();
|
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
|
# Round 1: Collect the tests
|
||||||
my $g_test_db;
|
my $g_test_db;
|
||||||
print "Info: search test in $o_suite\n";
|
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)
|
# Round 2: Run the tests (later in thread)
|
||||||
foreach my $t (keys(%$g_test_db)) {
|
foreach my $t (keys(%$g_test_db)) {
|
||||||
my $info = $g_test_db->{$t};
|
# wait free CPU slot
|
||||||
run_elf($t, $info->{"CFG_DIR"}, $info->{"OUT"});
|
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
|
# Round 3: Collect the results
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
sub generate_cfg {
|
|
||||||
}
|
|
||||||
|
|
||||||
sub collect_result {
|
sub collect_result {
|
||||||
}
|
}
|
||||||
|
@ -58,18 +75,53 @@ sub collect_result {
|
||||||
sub add_test_cmd_for_elf {
|
sub add_test_cmd_for_elf {
|
||||||
my $file = $_;
|
my $file = $_;
|
||||||
return 0 unless ($file =~ /\.elf/);
|
return 0 unless ($file =~ /\.elf/);
|
||||||
return 0 unless ($file =~ /branchdelay/);
|
# Fast test
|
||||||
|
#return 0 unless ($file =~ /branchdelay/);
|
||||||
|
|
||||||
my $dir = $File::Find::dir;
|
my $dir = $File::Find::dir;
|
||||||
print "INFO: found $file in $dir\n";
|
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}->{"EXPECTED"} = $File::Find::name =~ s/\.elf/.expected/r;
|
||||||
$g_test_db->{$File::Find::name}->{"OUT"} = $File::Find::name =~ s/\.elf/.PCSX2.out/r;
|
$g_test_db->{$File::Find::name}->{"OUT"} = $File::Find::name =~ s/\.elf/.PCSX2.out/r;
|
||||||
|
|
||||||
return 1;
|
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 {
|
sub run_elf {
|
||||||
my $elf = shift;
|
my $elf = shift;
|
||||||
my $cfg = shift;
|
my $cfg = shift;
|
||||||
|
@ -79,8 +131,8 @@ sub run_elf {
|
||||||
my $dump = 0;
|
my $dump = 0;
|
||||||
open(my $run, ">$out") or die "Impossible to open $!";
|
open(my $run, ">$out") or die "Impossible to open $!";
|
||||||
|
|
||||||
# FIXME timeout + cfg support
|
# FIXME timeout
|
||||||
my $pid = open(my $log, "$o_exe --elf $elf |") or die "Impossible to pipe $!";
|
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";
|
print "Info: Execute $elf (PID=$pid) with cfg ($cfg)\n";
|
||||||
|
|
||||||
while ($line = <$log>) {
|
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