diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /unittests/autotestscripts | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'unittests/autotestscripts')
| -rw-r--r-- | unittests/autotestscripts/check_debug_dlls.pl | 25 | ||||
| -rw-r--r-- | unittests/autotestscripts/check_dynamic_shader_compile.pl | 15 | ||||
| -rw-r--r-- | unittests/autotestscripts/datafiles/gwolf.tga | bin | 0 -> 4194348 bytes | |||
| -rw-r--r-- | unittests/autotestscripts/filecompare_tests.cfg | 16 | ||||
| -rw-r--r-- | unittests/autotestscripts/reference_output/file_size_monitor.txt | 6 | ||||
| -rw-r--r-- | unittests/autotestscripts/reference_output/mathlib_test.txt | 3 | ||||
| -rw-r--r-- | unittests/autotestscripts/reference_output/rt_test.txt | 6 | ||||
| -rw-r--r-- | unittests/autotestscripts/reference_output/testprocess.txt | 1 | ||||
| -rw-r--r-- | unittests/autotestscripts/reference_output/vtex.vtf | bin | 0 -> 1398360 bytes | |||
| -rw-r--r-- | unittests/autotestscripts/run_file_comparison_tests.pl | 181 | ||||
| -rw-r--r-- | unittests/autotestscripts/subtests/file_size_monitor.pl | 40 | ||||
| -rw-r--r-- | unittests/autotestscripts/test_error_reporting.pl | 13 | ||||
| -rw-r--r-- | unittests/autotestscripts/test_shader_crcs.pl | 36 | ||||
| -rw-r--r-- | unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl | 69 |
14 files changed, 411 insertions, 0 deletions
diff --git a/unittests/autotestscripts/check_debug_dlls.pl b/unittests/autotestscripts/check_debug_dlls.pl new file mode 100644 index 0000000..7f1e16c --- /dev/null +++ b/unittests/autotestscripts/check_debug_dlls.pl @@ -0,0 +1,25 @@ +#!perl + +use File::Find; +use Win32::API; + +find(\&ProcessFile, "../../../game/bin/" ); + +sub ProcessFile + { + return if (/360/); + return unless( /\.dll$/i ); + my $LoadLibrary = Win32::API->new( "kernel32", "LoadLibrary","P","L" ); + my $GetProcAddress = Win32::API->new( "kernel32", "GetProcAddress","LP","L" ); + my $FreeLibrary = Win32::API->new( "kernel32", "FreeLibrary", "P", "V" ); + my $handle=$LoadLibrary->Call($_); + if ( $handle ) + { + my $proc = $GetProcAddress->Call($handle, "BuiltDebug\0"); + if ( $proc ) + { + print "Error $_ is built debug\n"; + } + $FreeLibrary->Call( $handle ); + } + } diff --git a/unittests/autotestscripts/check_dynamic_shader_compile.pl b/unittests/autotestscripts/check_dynamic_shader_compile.pl new file mode 100644 index 0000000..39e8e3a --- /dev/null +++ b/unittests/autotestscripts/check_dynamic_shader_compile.pl @@ -0,0 +1,15 @@ +#!perl + +open(DLL,"../../../game/bin/shaderapidx9.dll" ) || die "can't open shaderapi"; + +binmode DLL; +my $dllcode = do { local( $/ ) ; <DLL> } ; # slurp comparison output in +close DLL; + +if ( $dllcode =~ /dynamic_shader_compile_is_on/s ) + { + open(ERRORS,">errors.txt") || die "huh - can't write"; + print ERRORS "stdshader_dx9.dll was built with dynamic shader compile!\n"; + close ERRORS; + } + diff --git a/unittests/autotestscripts/datafiles/gwolf.tga b/unittests/autotestscripts/datafiles/gwolf.tga Binary files differnew file mode 100644 index 0000000..c813d8a --- /dev/null +++ b/unittests/autotestscripts/datafiles/gwolf.tga diff --git a/unittests/autotestscripts/filecompare_tests.cfg b/unittests/autotestscripts/filecompare_tests.cfg new file mode 100644 index 0000000..4f4cda6 --- /dev/null +++ b/unittests/autotestscripts/filecompare_tests.cfg @@ -0,0 +1,16 @@ +// this config file defines all unit tests which are run by running a program and comparing its output to reference output +// which is checked in in the directory src/unittests/autotestscripts/reference_output + +// the format of entries is TESTNAME,OUTPUTFILE,COMMAND-LINE-TO-EXECUTE +// if the OUTPUTFILE part is blank, it assumes the test is meant to compare the output of stdio + +file_size_monitor,,perl subtests/file_size_monitor.pl +testprocess,,..\testprocess\testprocess -message "testprocess autotest1" +vtex,gwolf.vtf,vtex -outdir . -nopause -nop4 -crcforce datafiles\gwolf.tga +rt_test,,..\rt_test\rt_test ..\rt_test\gwolf.tga test 1024 1024 +// mathlib_test,,..\mathlib_test\mathlib_test + + + + + diff --git a/unittests/autotestscripts/reference_output/file_size_monitor.txt b/unittests/autotestscripts/reference_output/file_size_monitor.txt new file mode 100644 index 0000000..1f3ef70 --- /dev/null +++ b/unittests/autotestscripts/reference_output/file_size_monitor.txt @@ -0,0 +1,6 @@ +Running file size monitor +PC shader size := 291934326 +PC Game Bin DLL size := 108442741 +360 shader size := 0 +360 Game Bin DLL size := 0 +tf texture size := 1396651036 diff --git a/unittests/autotestscripts/reference_output/mathlib_test.txt b/unittests/autotestscripts/reference_output/mathlib_test.txt new file mode 100644 index 0000000..e581561 --- /dev/null +++ b/unittests/autotestscripts/reference_output/mathlib_test.txt @@ -0,0 +1,3 @@ +right spherical triangle projected percentage=0.1250 +small spherical triangle projected percentage=0.00156 +sum of areas of cubemap cells = 1.00 diff --git a/unittests/autotestscripts/reference_output/rt_test.txt b/unittests/autotestscripts/reference_output/rt_test.txt new file mode 100644 index 0000000..1cee230 --- /dev/null +++ b/unittests/autotestscripts/reference_output/rt_test.txt @@ -0,0 +1,6 @@ +reading src texture +n triangles 1567238 +Creating kd-tree +kd built time := 79 +Rendering +pixels traced and lit per second := 1559694.998968 diff --git a/unittests/autotestscripts/reference_output/testprocess.txt b/unittests/autotestscripts/reference_output/testprocess.txt new file mode 100644 index 0000000..63b55cd --- /dev/null +++ b/unittests/autotestscripts/reference_output/testprocess.txt @@ -0,0 +1 @@ +testprocess autotest1
\ No newline at end of file diff --git a/unittests/autotestscripts/reference_output/vtex.vtf b/unittests/autotestscripts/reference_output/vtex.vtf Binary files differnew file mode 100644 index 0000000..f36a030 --- /dev/null +++ b/unittests/autotestscripts/reference_output/vtex.vtf diff --git a/unittests/autotestscripts/run_file_comparison_tests.pl b/unittests/autotestscripts/run_file_comparison_tests.pl new file mode 100644 index 0000000..7408a56 --- /dev/null +++ b/unittests/autotestscripts/run_file_comparison_tests.pl @@ -0,0 +1,181 @@ +#!perl + +# read stdio_test_list.cfg and perform all tests + +$create_refs=0; +$subset_string=shift; + +@months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); +@weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); +($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); +$year = 1900 + $yearOffset; +$dstamp = "$weekDays[$dayOfWeek] $months[$month] $dayOfMonth $year".sprintf(" %02d:%02d:%02d", $hour,$minute,$second); +$changelist_counter=`p4 counter main_changelist`; # grab value of p4 counter + +$dstamp.=" $changelist_counter"; +$dstamp=~ s/[\n\r]//g; + +$computername=$ENV{'COMPUTERNAME'}; + + +# first, set our priority to high and affinity to 1 to try to get more repeatable benchmark results +#my $pid = $$; + +#my $cmd="datafiles\\process.exe -p $pid High"; +#print STDERR `$cmd`; +#$cmd="datafiles\\process.exe -a $pid 01"; +#print STDERR `$cmd`; + +if ( open(CFGFILE, "filecompare_tests.cfg") ) + { + while(<CFGFILE>) + { + s/[\n\r]//g; + s@//.*$@@; # kill comments + if (/^([^,]*),([^,]*),(.*$)/) + { + $testname=$1; + $testfile=$2; + $testcommand=$3; + + next if ( length($subset_string) && ( ! ( $testname=~/$subset_string/i) ) ); + + $ext=".txt"; + if ( length($testfile ) ) + { + $ext=""; + $ext = $1 if ( $testfile=~/(\..*)$/ ); # copy extension + unlink $testfile if ( -e $testfile); # kill it if it exists + } + + print STDOUT "running $testname : $testcommand ($testfile)\n"; + # suck the reference output in. use binary mode unless stdio + $refname="reference_output/$testname$ext"; + + # run the test + my $stime=time; + $output=`$testcommand`; + $stime=time-$stime; + + if ( open(REF,$refname)) + { + if ( length($testfile )) + { + binmode REF; + } + $ref_output= do { local( $/ ) ; <REF> } ; # slurp comparison output in + close REF; + + if ( length( $testfile ) ) + { + print STDERR $output; + # file case + if ( open(TESTFILE, $testfile )) + { + binmode TESTFILE; + $new_output= do { local( $/ ) ; <TESTFILE> } ; # slurp comparison output in + close TESTFILE; + if ($new_output ne $ref_output ) + { + $errout.="ERROR: test $testname ($testcommand) : test produced file $testfile (length=". + length($new_output).") but it doesn't match the reference (length=".length($ref_output).")\n"; + } + else + { + &UpdateMetrics( $testname, $output, $stime ); + } + } + else + { + $errout.="ERROR: test $testname ($testcommand) : test was supposed to create $testfile, but didn't.\n"; + } + } + else + { + # strip metrics (like timing) for comparison + my $massaged_ref = $ref_output; + my $massaged_output = $output; + $massaged_ref =~ s/:=\s*[0-9\.]+//g; + $massaged_output =~ s/:=\s*[0-9\.]+//g; + if ($massaged_output ne $massaged_ref ) + { +# print STDERR "o=$massaged_output r=$massaged_ref\n"; + $errout.="ERROR: test $testname ($testcommand) : output does not match reference output.\n"; + } + else + { + &UpdateMetrics( $testname, $output, $stime ); + } + } + } + else + { + $errout.="ERROR: Can't open reference $refname for $testname\n"; + if ($create_refs) + { + if ( length($testfile ) ) + { + if ( -e $testfile ) + { + $oname=$refname; + $oname=~s@/@\\@g; + print STDERR "copy $testfile $oname"; + print STDERR `copy $testfile $oname`; + print STDERR `p4 add $oname`; + } + } + else + { + if ( open(REFOUT,">$refname") ) + { + print REFOUT $output; + } + close REFOUT; + print STDERR `p4 add $refname`; + } + } + } + } + } + } +else + { + $errout.="Can't open stdio_test_list.cfg\n"; + } + +if (length($errout)) +{ + print STDERR "There were errors: $errout"; + open(ERRORS,">errors.txt") || die "huh - can't write"; + print ERRORS $errout; + close ERRORS; +} + + + + +sub UpdateMetrics + { + return unless length($computername); + local( $tname, $output, $runtime) = @_; + $output .= "\ntest runtime := $runtime\n"; + foreach $_ ( split(/\n/,$output)) + { + if (/^(.+):=(.*$)/) + { + my $varname=$1; + my $etime=$2; + $varname=~s@^\s*@@g; + $varname=~s@\s*$@@g; + mkdir "\\\\fileserver\\user\\perf\\$computername"; + mkdir "\\\\fileserver\\user\\perf\\$computername\\$tname"; + if ( open(COUT,">>\\\\fileserver\\user\\perf\\$computername\\$tname\\$varname.csv") ) + { + print COUT "\"$dstamp\",$etime\n"; + close COUT; + } + + } + } + + } diff --git a/unittests/autotestscripts/subtests/file_size_monitor.pl b/unittests/autotestscripts/subtests/file_size_monitor.pl new file mode 100644 index 0000000..fa834d3 --- /dev/null +++ b/unittests/autotestscripts/subtests/file_size_monitor.pl @@ -0,0 +1,40 @@ +#!perl + +use File::Find; + +# customize here +print "Running file size monitor\n"; + +LogDirectorySize("PC shader size", "../../../game/hl2/shaders","\.vcs","\.360\.vcs"); +LogDirectorySize("PC Game Bin DLL size", "../../../game/bin/","\.dll","_360\.dll"); +LogDirectorySize("360 shader size", "../../../game/hl2/shaders","\.360\.vcs"); +LogDirectorySize("360 Game Bin DLL size", "../../../game/bin/","_360\.dll"); +LogDirectorySize("tf texture size","../../../game/tf/materials/","\.vtf"); + + + + + + + +sub LogDirectorySize + { + my ($label, $basedir, $filepattern, $excludepattern ) = @_; + undef @FileList; + find(\&ProcessFile, $basedir); + my $total_size = 0; + foreach $_ (@FileList) + { + next if ( length($excludepattern) && ( /$excludepattern/i ) ); + if (/$filepattern/i) + { + $total_size += (-s $_ ); + } + } + print "$label := $total_size\n"; + } + +sub ProcessFile + { + push @FileList, $File::Find::name; + } diff --git a/unittests/autotestscripts/test_error_reporting.pl b/unittests/autotestscripts/test_error_reporting.pl new file mode 100644 index 0000000..f705f9c --- /dev/null +++ b/unittests/autotestscripts/test_error_reporting.pl @@ -0,0 +1,13 @@ +#! perl +$errfname="//fileserver/user/cgreen/force_an_error.txt"; + +if (-e $errfname ) + { + unlink $errfname; + open(ERROUT,">errors.txt") || die "huh - can't write"; + { + print ERROUT "This is not an error - its just a test of the error script system.\n"; + close ERROUT; + } + + } diff --git a/unittests/autotestscripts/test_shader_crcs.pl b/unittests/autotestscripts/test_shader_crcs.pl new file mode 100644 index 0000000..517aa02 --- /dev/null +++ b/unittests/autotestscripts/test_shader_crcs.pl @@ -0,0 +1,36 @@ +use Cwd; + +my $dir = getcwd; + +chdir "../../materialsystem/stdshaders"; + +@output = `perl ..\\..\\devtools\\bin\\checkshaderchecksums.pl stdshader_dx9_20b.txt`; +foreach $_ (@output) +{ + $output.=$_ unless(/appchooser360/i); +} + +@output = `perl ..\\..\\devtools\\bin\\checkshaderchecksums.pl stdshader_dx9_30.txt`; +foreach $_ (@output) +{ + $output.=$_ unless(/appchooser360/i); +} + +my $errors; + +foreach $_ (@output ) +{ + $errors.=$_ unless (/appchooser360movie/); +} + +chdir $dir; + +print $errors; + +if( length( $errors ) > 0 ) +{ + print "writing errors.txt\n"; + open FP, ">errors.txt"; + print FP "$errors"; + close FP; +} diff --git a/unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl b/unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl new file mode 100644 index 0000000..bce70ba --- /dev/null +++ b/unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl @@ -0,0 +1,69 @@ +#! perl + + +use File::Find; +use Cwd; +use File::Basename; + +# find(\&Visitfile,"../../../content/tf"); + +foreach $_ ( @sheetfiles ) + { + $dest_sheet_name=$_; + $dest_sheet_name =~ s/\.mks/.sht/i; + $dest_sheet_name =~ s@/content/([^/]+)/materialsrc/@/game/\1/materials/@gi; + print "**Checking $_\n"; + if (! -e $dest_sheet_name ) + { + push @errors,"sheet $_ exists but not $dest_sheet_name"; + } + else + { + # buid it and make sure they match + $cmd="cd ".dirname($_)." & mksheet ".basename($_)." test.sht"; + $cmd=~tr/\//\\/; + $cmdout=`$cmd`; + if ( open(NEWFILE, dirname($_)."/test.sht") ) + { + binmode NEWFILE; + open(OLDFILE, $dest_sheet_name ) || die "strange error - cant find $dest_sheet_name"; + binmode OLDFILE; + { + local( $/, *FH ) ; + $old_data=<OLDFILE>; + $new_data=<NEWFILE>; + if ( $new_data ne $old_data ) + { + push @errors,"Sheet source file $_ does not compile to the same output as the checked in $dest_sheet_name"; + } + close OLDFILE; + close NEWFILE; + unlink dirname($_)."/test.sht"; + } + } + else + { + push @errors, "Couldn't compile sheet $_ by running $cmd : \n$cmdout"; + } + } + } + +$errout=join("\n", @errors); +print $errout; +if (length($errout)) + { + open(ERRFILE,">errors.txt") || die "can't write errors.txt"; + print ERRFILE $errout; + close ERRFILE; + } + + +sub Visitfile + { + local($_)= $File::Find::name; + s@\\@\/@g; + if (m@content/(\S+)/.*\.mks$@i) + { + push @sheetfiles, $_; + } + } |