@@ -7,8 +7,11 @@ rem The script will use the FPC, MP and MADS version from there as reference.
77rem
88rem The script compiles "Test-0.pas" with FPC vs. the new MP.
99rem The script compiles a set of reference examples with the released and the new MP an validates that there are no differences in the binary output.
10+ rem The optional first argument to the scrip is "FAST" to only compile the first test.
1011
1112setlocal
13+ set TEST_MODE = %1
14+
1215set PATH = %WUDSN_TOOLS_FOLDER% \PAS\FPC.jac;%WUDSN_TOOLS_FOLDER% \ASM\MADS\bin\windows_x86_64;%PATH%
1316set MP_FOLDER = %~dp0 ..
1417set MP_SRC_FOLDER = %MP_FOLDER% \src
@@ -64,48 +67,79 @@ goto :eof
6467 set TEST_MP = %3
6568
6669 set MP_INPUT_PAS = %TEST_MP% .pas
67- set MP_OUTPUT_ASM = %TEST_MP% .a65
70+
71+ set MP_OUTPUT_ASM_REF = %TEST_MP% -Reference.a65
6872 set MADS_OUTPUT_XEX_REF = %TEST_MP% -Reference.xex
69- echo %MADS_OUTPUT_XEX_REF%
73+
7074 if %MP% == %WUDSN_MP_EXE% (
75+ set MP_OUTPUT_ASM = %MP_OUTPUT_ASM_REF%
7176 set MADS_OUTPUT_XEX = %MADS_OUTPUT_XEX_REF%
7277 ) else (
78+ set MP_OUTPUT_ASM = %TEST_MP% .a65
7379 set MADS_OUTPUT_XEX = %TEST_MP% .xex
7480 )
7581 pushd %TEST_FOLDER%
76- echo INFO: Compiling " %MP_INPUT_PAS% " in " %TEST_FOLDER% " with " %MP% " .
82+ echo INFO: Compiling " %MP_INPUT_PAS% " in " %TEST_FOLDER% " with " %MP% " to " %MP_OUTPUT_ASM% " and " %MADS_OUTPUT_XEX% " .
7783 if exist %MP_OUTPUT_ASM% del %MP_OUTPUT_ASM%
78- %MP% -ipath:%MP_FOLDER% \lib %MP_INPUT_PAS%
84+ %MP% -ipath:%MP_FOLDER% \lib %MP_INPUT_PAS% -o: %MP_OUTPUT_ASM%
7985 if errorlevel 1 goto :mp_error
8086 if exist %MP_OUTPUT_ASM% (
8187 if exist %MADS_OUTPUT_XEX% del %MADS_OUTPUT_XEX%
8288 mads %MP_OUTPUT_ASM% -x -i:%MP_FOLDER% \base -o:%MADS_OUTPUT_XEX%
8389 if exist %MADS_OUTPUT_XEX% (
8490 echo Starting test program " %MADS_OUTPUT_XEX% " .
85- rem %MADS_OUTPUT_XEX%
91+ %MADS_OUTPUT_XEX%
8692 ) else (
8793 echo ERROR: MADS output file %MADS_OUTPUT_XEX% not created.
8894 pause
8995 )
9096 ) else (
9197 echo ERROR: MP output file %MP_OUTPUT_ASM% not created.
98+ dir *.a65
9299 pause
93100 )
94101
95- REM TODO Compare file if both files reference exists
96- if not " %MADS_OUTPUT_XEX% " == " %MADS_OUTPUT_XEX_REF% " (
97- if exist %MADS_OUTPUT_XEX% (
102+ REM Compare file if both files reference exists
103+ call :compare_files %MP_OUTPUT_ASM% %MP_OUTPUT_ASM_REF% TEXT
104+ call :compare_files %MADS_OUTPUT_XEX% %MADS_OUTPUT_XEX_REF% BINARY
105+ popd
106+ goto :eof
107+
108+ rem Compare file if both files and reference file exist
109+ rem call :compare_files actual_file reference_file mode (TEXT or BINARY)
110+ :compare_files
111+ set COMPARE_CURRENT_FILE = %1
112+ set COMPARE_REFERENCE_FILE = %2
113+ set COMPARE_MODE = %3
114+ if not " %COMPARE_CURRENT_FILE% " == " %COMPARE_REFERENCE_FILE% " (
115+ if exist %COMPARE_CURRENT_FILE% (
98116
99- if exist %MADS_OUTPUT_XEX_REF% (
100- fc /b %MADS_OUTPUT_XEX% %MADS_OUTPUT_XEX_REF%
101- if errorlevel 1 goto :fc_error
117+ if exist %COMPARE_CURRENT_FILE% (
118+ rem echo INFO: Comparing "%COMPARE_CURRENT_FILE%" with "%COMPARE_REFERENCE_FILE%" in mode %COMPARE_MODE%.
119+ if " %COMPARE_MODE% " == " TEXT" (
120+ rem Strip the compiler version difference.
121+ more +2 " %COMPARE_CURRENT_FILE% " > " %COMPARE_CURRENT_FILE% .tmp"
122+ more +2 " %COMPARE_REFERENCE_FILE% " > " %COMPARE_REFERENCE_FILE% .tmp"
123+ fc /L %COMPARE_CURRENT_FILE% .tmp %COMPARE_REFERENCE_FILE% .tmp
124+ if errorlevel 1 (
125+ echo ERROR: " %COMPARE_CURRENT_FILE% " and " %COMPARE_REFERENCE_FILE% " are different.
126+ pause
127+ )
128+ del %COMPARE_CURRENT_FILE% .tmp %COMPARE_REFERENCE_FILE% .tmp
129+ ) else (
130+ fc /B %COMPARE_CURRENT_FILE% %COMPARE_REFERENCE_FILE%
131+ if errorlevel 1 (
132+ echo ERROR: " %COMPARE_CURRENT_FILE% " and " %COMPARE_REFERENCE_FILE% " are binary different.
133+ pause
134+ )
135+ )
102136 ) else (
103- echo WARNING: Reference file " %MADS_OUTPUT_XEX_REF % " does not exist, no comparsion possible.
137+ echo WARNING: Reference file " %COMPARE_REFERENCE_FILE % " does not exist, no comparsion possible.
104138 )
105139 )
106140 )
107- popd
108- goto : eof
141+ goto : eof
142+
109143
110144:mp_error
111145 popd
@@ -114,22 +148,18 @@ goto :eof
114148 goto :eof
115149
116150
117- :fc_error
118- popd
119- echo ERROR: %MADS_OUTPUT_XEX% and %MADS_OUTPUT_XEX_REF% are binary different.
120- pause
121- goto :eof
122-
123- rem Run all tests with a given mp.exe.
124- rem IN: Path to mp.exe
125- rem
151+ rem Run all tests with a given mp.exe.
152+ rem IN: Path to mp.exe
153+ rem
126154:run_tests
127- rem call :run_mp % %MP_SRC_FOLDER% Test-MPP
128- rem call :run_mp %1=%MP_FOLDER%\samples\a8\games\PacMad pacmadd
129- call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform fedorahat
130- call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform cannabis
131- call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform snowflake
132- call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform spline
133- call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform fern
134- goto :eof
155+ call :run_mp %1 %MP_SRC_FOLDER% Test-MP
156+ if " %TEST_MODE% " == " FAST" goto :eof
157+ call :run_mp %1 %MP_FOLDER% \samples\a8\games\PacMad pacmad
158+ call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform fedorahat
159+ call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform cannabis
160+ call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform snowflake
161+ call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform snowflake_float16
162+ call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform spline
163+ call :run_mp %1 %MP_FOLDER% \samples\a8\graph_crossplatform fern
164+ goto :eof
135165
0 commit comments