Testsuite: factorization between MATLAB and Octave
parent
82a2aeaae4
commit
01833b8a76
49
meson.build
49
meson.build
|
@ -1740,42 +1740,23 @@ mod_and_m_tests = [
|
|||
{ 'test' : [ 'riccatiupdate.m' ] },
|
||||
{ 'test' : [ 'contribs.m' ],
|
||||
'extra' : [ 'sandbox.mod',
|
||||
'simulateddata.m' ] }
|
||||
'simulateddata.m' ] },
|
||||
{ 'test' : [ 'run_block_bytecode_tests.m' ],
|
||||
'extra' : [ 'block_bytecode/run_ls2003.m',
|
||||
'block_bytecode/ls2003.mod' ] },
|
||||
{ 'test' : [ 'run_reporting_tests.m' ],
|
||||
'extra' : [ 'reporting/AnnualTable.m',
|
||||
'reporting/CommResidTablePage.m',
|
||||
'reporting/CountryGraphPage.m',
|
||||
'reporting/CountryTablePage.m',
|
||||
'reporting/db_a.csv',
|
||||
'reporting/db_q.csv',
|
||||
'reporting/dc_a.csv',
|
||||
'reporting/dc_q.csv',
|
||||
'reporting/ResidTablePage.m',
|
||||
'reporting/runDynareReport.m' ] }
|
||||
]
|
||||
|
||||
if get_option('build_for') == 'matlab'
|
||||
mod_and_m_tests += [ { 'test' : [ 'run_block_byte_tests_matlab.m' ],
|
||||
'extra' : [ 'block_bytecode/run_ls2003.m',
|
||||
'block_bytecode/ls2003.mod' ] },
|
||||
{ 'test' : [ 'run_reporting_test_matlab.m' ],
|
||||
'extra' : [ 'reporting/AnnualTable.m',
|
||||
'reporting/CommResidTablePage.m',
|
||||
'reporting/CountryGraphPage.m',
|
||||
'reporting/CountryTablePage.m',
|
||||
'reporting/db_a.csv',
|
||||
'reporting/db_q.csv',
|
||||
'reporting/dc_a.csv',
|
||||
'reporting/dc_q.csv',
|
||||
'reporting/ResidTablePage.m',
|
||||
'reporting/runDynareReport.m' ] } ]
|
||||
else
|
||||
mod_and_m_tests += [ { 'test' : [ 'run_block_byte_tests_octave.m' ],
|
||||
'extra' : [ 'block_bytecode/run_ls2003.m',
|
||||
'block_bytecode/ls2003.mod' ] },
|
||||
{ 'test' : [ 'run_reporting_test_octave.m' ],
|
||||
'extra' : [ 'reporting/AnnualTable.m',
|
||||
'reporting/CommResidTablePage.m',
|
||||
'reporting/CountryGraphPage.m',
|
||||
'reporting/CountryTablePage.m',
|
||||
'reporting/db_a.csv',
|
||||
'reporting/db_q.csv',
|
||||
'reporting/dc_a.csv',
|
||||
'reporting/dc_q.csv',
|
||||
'reporting/ResidTablePage.m',
|
||||
'reporting/runDynareReport.m' ] } ]
|
||||
endif
|
||||
|
||||
|
||||
base_test_driver_args = [ get_option('build_for') ]
|
||||
if get_option('build_for') == 'matlab'
|
||||
base_test_driver_args += [ matlab_exe.full_path(), matlab_version, matlab_arch ]
|
||||
|
|
|
@ -1,138 +0,0 @@
|
|||
## Copyright © 2009-2023 Dynare Team
|
||||
##
|
||||
## This file is part of Dynare.
|
||||
##
|
||||
## Dynare is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## Dynare is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
## Implementation notes:
|
||||
##
|
||||
## Before every call to Dynare, the contents of the workspace is saved in
|
||||
## 'wsOct', and reloaded after Dynare has finished (this is necessary since
|
||||
## Dynare does a 'clear -all').
|
||||
## Note that we take care of clearing oo_ before saving the workspace,
|
||||
## otherwise the newly created oo_ will be scratched upon loading,
|
||||
## thus making the path comparison bogus.
|
||||
|
||||
source_dir = getenv('source_root');
|
||||
addpath([source_dir filesep 'tests' filesep 'utils']);
|
||||
addpath([source_dir filesep 'matlab']);
|
||||
|
||||
## Test block_bytecode/ls2003.mod with various combinations of
|
||||
## block/bytecode/solve_algo/stack_solve_algo
|
||||
failedBlock = {};
|
||||
cd block_bytecode
|
||||
tic;
|
||||
for blockFlag = 0:1
|
||||
for storageFlag = 0:2 % 0=M-file, 1=use_dll, 2=bytecode
|
||||
default_solve_algo = 2;
|
||||
default_stack_solve_algo = 0;
|
||||
if !blockFlag && storageFlag != 2
|
||||
solve_algos = [0:4 9];
|
||||
stack_solve_algos = [0 1 6];
|
||||
elseif blockFlag && storageFlag != 2
|
||||
solve_algos = [0:4 6:9];
|
||||
stack_solve_algos = [0:4 6];
|
||||
else
|
||||
solve_algos = 0:9;
|
||||
stack_solve_algos = 0:6;
|
||||
endif
|
||||
|
||||
# Workaround for strange race condition related to the static/dynamic
|
||||
# files (especially when we switch to/from use_dll)
|
||||
if exist('+ls2003_tmp')
|
||||
rmdir('+ls2003_tmp', 's');
|
||||
pause(1)
|
||||
endif
|
||||
|
||||
for i = 1:length(solve_algos)
|
||||
if !blockFlag && storageFlag == 0 && (i == 1)
|
||||
## This is the reference simulation path against which all
|
||||
## other simulations will be tested
|
||||
try
|
||||
old_path = path;
|
||||
save wsOct
|
||||
run_ls2003(blockFlag, storageFlag, solve_algos(i), default_stack_solve_algo)
|
||||
load wsOct
|
||||
path(old_path);
|
||||
y_ref = oo_.endo_simul;
|
||||
save('test.mat','y_ref');
|
||||
catch
|
||||
load wsOct
|
||||
path(old_path);
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
|
||||
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], lasterror);
|
||||
end_try_catch
|
||||
else
|
||||
try
|
||||
old_path = path;
|
||||
clear oo_ # Ensure that oo_.endo_simul won’t be overwritten when loading wsOct
|
||||
save wsOct
|
||||
run_ls2003(blockFlag, storageFlag, solve_algos(i), default_stack_solve_algo)
|
||||
load wsOct
|
||||
path(old_path);
|
||||
## Test against the reference simulation path
|
||||
load('test.mat','y_ref');
|
||||
diff = oo_.endo_simul - y_ref;
|
||||
if max(max(abs(diff))) > options_.dynatol.x
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
|
||||
differr.message = ["ERROR: simulation path differs from the reference path" ];
|
||||
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], differr);
|
||||
endif
|
||||
catch
|
||||
load wsOct
|
||||
path(old_path);
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
|
||||
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], lasterror);
|
||||
end_try_catch
|
||||
endif
|
||||
endfor
|
||||
for i = 1:length(stack_solve_algos)
|
||||
try
|
||||
old_path = path;
|
||||
clear oo_ # Ensure that oo_.endo_simul won’t be overwritten when loading wsOct
|
||||
save wsOct
|
||||
run_ls2003(blockFlag, storageFlag, default_solve_algo, stack_solve_algos(i))
|
||||
load wsOct
|
||||
path(old_path);
|
||||
## Test against the reference simulation path
|
||||
load('test.mat','y_ref');
|
||||
diff = oo_.endo_simul - y_ref;
|
||||
if max(max(abs(diff))) > options_.dynatol.x
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'];
|
||||
differr.message = ["ERROR: simulation path differs from the reference path" ];
|
||||
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], differr);
|
||||
endif
|
||||
catch
|
||||
load wsOct
|
||||
path(old_path);
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'];
|
||||
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], lasterror);
|
||||
end_try_catch
|
||||
endfor
|
||||
endfor
|
||||
endfor
|
||||
|
||||
delete('wsOct');
|
||||
|
||||
if size(failedBlock,2) > 0
|
||||
fprintf('\n*** Failed tests: %s\n', failedBlock{:})
|
||||
end
|
||||
|
||||
fprintf('\n*** Elapsed time (in seconds): %.1f\n\n', toc);
|
||||
|
||||
quit(size(failedBlock,2) > 0)
|
||||
|
||||
## Local variables:
|
||||
## mode: Octave
|
||||
## End:
|
|
@ -35,7 +35,6 @@ addpath([source_dir filesep 'matlab']);
|
|||
% block/bytecode/solve_algo/stack_solve_algo
|
||||
failedBlock = {};
|
||||
cd block_bytecode
|
||||
has_optimization_toolbox = user_has_matlab_license('optimization_toolbox');
|
||||
tic;
|
||||
for blockFlag = 0:1
|
||||
for storageFlag = 0:2 % 0=M-file, 1=use_dll, 2=bytecode
|
||||
|
@ -51,8 +50,15 @@ for blockFlag = 0:1
|
|||
solve_algos = 1:9;
|
||||
stack_solve_algos = 0:6;
|
||||
end
|
||||
if has_optimization_toolbox
|
||||
solve_algos = [ solve_algos 0 ];
|
||||
if isoctave || user_has_matlab_license('optimization_toolbox')
|
||||
solve_algos = [ 0 solve_algos ];
|
||||
end
|
||||
|
||||
% Workaround for strange race condition related to the static/dynamic
|
||||
% files (especially when we switch to/from use_dll)
|
||||
if isoctave && exist('+ls2003_tmp')
|
||||
rmdir('+ls2003_tmp', 's');
|
||||
pause(1)
|
||||
end
|
||||
|
||||
for i = 1:length(solve_algos)
|
||||
|
@ -71,7 +77,7 @@ for blockFlag = 0:1
|
|||
load wsMat
|
||||
path(old_path);
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
|
||||
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
|
||||
printTestError(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
|
||||
clear exception
|
||||
end
|
||||
else
|
||||
|
@ -87,15 +93,19 @@ for blockFlag = 0:1
|
|||
diff = oo_.endo_simul - y_ref;
|
||||
if max(max(abs(diff))) > options_.dynatol.x
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
|
||||
exception = MException('Dynare:simerr', 'ERROR: simulation path differs from the reference path');
|
||||
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
|
||||
if isoctave
|
||||
exception.message = 'ERROR: simulation path differs from the reference path';
|
||||
else
|
||||
exception = MException('Dynare:simerr', 'ERROR: simulation path differs from the reference path');
|
||||
end
|
||||
printTestError(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
|
||||
clear exception
|
||||
end
|
||||
catch exception
|
||||
load wsMat
|
||||
path(old_path);
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
|
||||
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
|
||||
printTestError(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
|
||||
clear exception
|
||||
end
|
||||
end
|
||||
|
@ -113,15 +123,19 @@ for blockFlag = 0:1
|
|||
diff = oo_.endo_simul - y_ref;
|
||||
if max(max(abs(diff))) > options_.dynatol.x
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'];
|
||||
exception = MException('Dynare:simerr', 'ERROR: simulation path difers from the reference path');
|
||||
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], exception);
|
||||
if isoctave
|
||||
exception.message = 'ERROR: simulation path differs from the reference path';
|
||||
else
|
||||
exception = MException('Dynare:simerr', 'ERROR: simulation path difers from the reference path');
|
||||
end
|
||||
printTestError(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], exception);
|
||||
clear exception
|
||||
end
|
||||
catch exception
|
||||
load wsMat
|
||||
path(old_path);
|
||||
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'];
|
||||
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], exception);
|
||||
printTestError(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], exception);
|
||||
clear exception
|
||||
end
|
||||
end
|
|
@ -32,12 +32,8 @@ try
|
|||
dynare(getenv('mod_file'), 'console')
|
||||
testFailed = false;
|
||||
catch exception
|
||||
if isoctave
|
||||
printMakeCheckOctaveErrMsg(getenv('mod_file'), exception);
|
||||
else
|
||||
printMakeCheckMatlabErrMsg(getenv('mod_file'), exception);
|
||||
end
|
||||
testFailed = true;
|
||||
printTestError(getenv('mod_file'), exception);
|
||||
testFailed = true;
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
## Copyright © 2013-2023 Dynare Team
|
||||
##
|
||||
## This file is part of Dynare.
|
||||
##
|
||||
## Dynare is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## Dynare is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
source_dir = getenv('source_root');
|
||||
addpath([source_dir filesep 'tests' filesep 'utils']);
|
||||
addpath([source_dir filesep 'matlab']);
|
||||
|
||||
load_octave_packages
|
||||
|
||||
## To add default directories, empty dseries objects
|
||||
dynare_config();
|
||||
|
||||
printf("\n*** TESTING: run_reporting_test_octave.m ***\n");
|
||||
try
|
||||
cd reporting
|
||||
db_a = dseries('db_a.csv');
|
||||
db_q = dseries('db_q.csv');
|
||||
dc_a = dseries('dc_a.csv');
|
||||
dc_q = dseries('dc_q.csv');
|
||||
runDynareReport(dc_a, dc_q, db_a, db_q);
|
||||
testFailed = false;
|
||||
catch
|
||||
testFailed = true;
|
||||
end
|
||||
|
||||
quit(testFailed)
|
||||
|
||||
## Local variables:
|
||||
## mode: Octave
|
||||
## End:
|
|
@ -17,12 +17,16 @@
|
|||
|
||||
source_dir = getenv('source_root');
|
||||
addpath([source_dir filesep 'matlab']);
|
||||
if isoctave
|
||||
addpath([source_dir filesep 'tests' filesep 'utils']);
|
||||
load_octave_packages
|
||||
end
|
||||
|
||||
% To add default directories, empty dseries objects
|
||||
dynare_config;
|
||||
|
||||
disp('');
|
||||
disp(['*** TESTING: run_reporting_test_matlab.m ***']);
|
||||
disp(['*** TESTING: run_reporting_tests.m ***']);
|
||||
try
|
||||
cd reporting
|
||||
db_a = dseries('db_a.csv');
|
|
@ -1,9 +0,0 @@
|
|||
function printMakeCheckMatlabErrMsg(modfilename, exception)
|
||||
fprintf('\n********************************************\n');
|
||||
disp('*** DYNARE-TEST-MATLAB ERROR ENCOUNTERED ***');
|
||||
disp('********************************************');
|
||||
disp([' WHILE RUNNING MODFILE: ' modfilename]);
|
||||
fprintf('\n');
|
||||
disp(getReport(exception));
|
||||
fprintf('*************************************\n\n\n');
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
function printMakeCheckOctaveErrMsg(modfilename, err)
|
||||
printf("\n");
|
||||
printf("********************************************\n");
|
||||
printf("*** DYNARE-TEST-OCTAVE ERROR ENCOUNTERED ***\n");
|
||||
printf("********************************************\n");
|
||||
printf(" WHILE RUNNING MODFILE: %s\n", modfilename);
|
||||
printf(" MSG: %s\n", err.message);
|
||||
if (isfield(err, 'stack'))
|
||||
printf("\n STACKTRACE:\n");
|
||||
for i=1:size(err.stack, 1)
|
||||
printf(" %s(%s):%d.%d\n", err.stack(i).file, err.stack(i).name,
|
||||
err.stack(i).line, err.stack(i).column);
|
||||
endfor
|
||||
end
|
||||
printf("********************************************\n\n\n");
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
function printTestError(filename, exception)
|
||||
fprintf('\n********************************************\n')
|
||||
fprintf('****** Dynare test error encountered *******\n')
|
||||
fprintf('********************************************\n')
|
||||
fprintf(' While running file: %s\n', filename);
|
||||
if isoctave
|
||||
fprintf(' message: %s\n', exception.message)
|
||||
if (isfield(exception, 'stack'))
|
||||
fprintf('\n Stacktrace:\n')
|
||||
for i=1:size(exception.stack, 1)
|
||||
fprintf(' %s(%s):%d.%d\n', exception.stack(i).file, exception.stack(i).name, ...
|
||||
exception.stack(i).line, exception.stack(i).column);
|
||||
end
|
||||
end
|
||||
else
|
||||
fprintf('\n')
|
||||
disp(getReport(exception))
|
||||
end
|
||||
fprintf('********************************************\n\n\n')
|
||||
end
|
Loading…
Reference in New Issue