dynare/tests/run_test_octave.m

188 lines
7.6 KiB
Matlab
Raw Normal View History

2011-03-28 18:46:53 +02:00
## Copyright (C) 2009-2011 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 <http://www.gnu.org/licenses/>.
2011-03-28 18:46:53 +02:00
## Test Dynare Version
if !strcmp(dynare_version(), dynver)
error("Incorrect version of Dynare is being tested")
endif
## List of files to be tested
name = filesToTest();
## Ask gnuplot to create graphics in text mode
## Note that setenv() was introduced in Octave 3.0.2, for compatibility
## with MATLAB
putenv("GNUTERM", "dumb")
2011-03-28 18:46:53 +02:00
## BASE TESTS
2011-04-06 16:06:18 +02:00
failedBase = {};
2011-04-05 16:48:11 +02:00
top_test_dir = pwd;
addpath(top_test_dir);
2011-03-28 18:46:53 +02:00
for i=1:size(name,2)
try
2011-04-05 16:48:11 +02:00
[directory, testfile, ext] = fileparts([top_test_dir '/' name{i}]);
2011-03-28 18:46:53 +02:00
cd(directory);
printf("*** TESTING: %s ***\n", name{i});
dynare([testfile ext], 'noclearall')
catch
2011-04-06 16:06:18 +02:00
failedBase{size(failedBase,2)+1} = name{i};
printMakeCheckOctaveErrMsg(name{i}, lasterror);
2011-03-28 18:46:53 +02:00
end_try_catch
2011-04-05 16:48:11 +02:00
cd(top_test_dir);
save('makeCheckOctaveBase.mat', 'name', 'failedBase', 'i', 'top_test_dir');
2011-04-05 16:48:11 +02:00
clear -all;
load('makeCheckOctaveBase.mat');
2011-04-05 16:48:11 +02:00
end
2011-03-28 18:46:53 +02:00
## BLOCK TEST
2011-04-06 16:06:18 +02:00
clear i name;
failedBlock = {};
2011-03-28 18:46:53 +02:00
num_block_tests = 0;
2011-04-06 16:06:18 +02:00
cd([top_test_dir '/block_bytecode']);
save('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-04-14 11:23:03 +02:00
for blockFlag = 0:1
for bytecodeFlag = 0:1
2011-03-28 18:46:53 +02:00
## Recall that solve_algo=7 and stack_solve_algo=2 are not supported
## under Octave
default_solve_algo = 2;
default_stack_solve_algo = 0;
2011-04-14 11:23:03 +02:00
if !blockFlag && !bytecodeFlag
2011-03-28 18:46:53 +02:00
solve_algos = 0:4;
stack_solve_algos = 0;
2011-04-14 11:23:03 +02:00
elseif blockFlag && !bytecodeFlag
2011-03-28 18:46:53 +02:00
solve_algos = [0:4 6 8];
stack_solve_algos = [0 1 3 4];
else
solve_algos = [0:6 8];
stack_solve_algos = [0 1 3:5];
endif
for i = 1:length(solve_algos)
2011-04-05 16:48:11 +02:00
num_block_tests = num_block_tests + 1;
save wsOct
2011-04-14 11:23:03 +02:00
if !blockFlag && !bytecodeFlag && (i == 1)
2011-03-28 18:46:53 +02:00
try
2011-04-14 11:23:03 +02:00
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
2011-03-28 18:46:53 +02:00
y_ref = oo_.endo_simul;
save('test.mat','y_ref');
catch
load wsOct
load('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-04-06 16:06:18 +02:00
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
save('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-03-28 18:46:53 +02:00
end_try_catch
else
try
2011-04-14 11:23:03 +02:00
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
2011-03-28 18:46:53 +02:00
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
2011-04-06 16:06:18 +02:00
if(abs(diff) > options_.dynatol)
load wsOct
load('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-04-06 16:06:18 +02:00
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
differr.message = ["makecheck found error: if (abs(diff) <= options_.dynatol) FAILS." ];
differr.stack(1).file = "run_test_octave.m";
differr.stack(1).name = "run_test_octave.m";
differr.stack(1).line = 96;
2011-04-06 16:06:18 +02:00
differr.stack(1).column = 1;
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], differr);
save('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-04-06 16:06:18 +02:00
endif
2011-03-28 18:46:53 +02:00
catch
load wsOct
load('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-04-06 16:06:18 +02:00
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
save('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-03-28 18:46:53 +02:00
end_try_catch
endif
load wsOct
2011-03-28 18:46:53 +02:00
endfor
for i = 1:length(stack_solve_algos)
2011-04-05 16:48:11 +02:00
num_block_tests = num_block_tests + 1;
save wsOct
2011-03-28 18:46:53 +02:00
try
2011-04-14 11:23:03 +02:00
run_ls2003(blockFlag, bytecodeFlag, default_solve_algo, stack_solve_algos(i))
2011-03-28 18:46:53 +02:00
catch
load wsOct
load('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-04-06 16:06:18 +02:00
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], lasterror);
save('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir');
2011-03-28 18:46:53 +02:00
end_try_catch
load wsOct
2011-03-28 18:46:53 +02:00
endfor
endfor
endfor
load('makeCheckOctaveBlockByte.mat');
save('makeCheckOctaveBlockByte.mat', 'failedBlock', 'top_test_dir', 'num_block_tests');
delete('wsOct');
2011-04-06 16:06:18 +02:00
clear -all;
load('makeCheckOctaveBlockByte.mat');
delete('makeCheckOctaveBlockByte.mat');
2011-04-05 16:48:11 +02:00
2011-04-06 16:06:18 +02:00
cd(top_test_dir);
load('makeCheckOctaveBase.mat');
delete('makeCheckOctaveBase.mat');
2011-04-05 16:48:11 +02:00
2011-03-28 18:46:53 +02:00
total_tests = size(name,2)+num_block_tests;
2011-04-05 16:48:11 +02:00
2011-08-19 18:10:18 +02:00
% print output to screen and to file
fid = fopen("run_test_octave_output.txt", "w");
2011-03-28 18:46:53 +02:00
printf("\n\n\n");
2011-08-19 18:10:18 +02:00
fprintf(fid,'\n\n\n');
2011-03-28 18:46:53 +02:00
printf("***************************************\n");
2011-08-19 18:10:18 +02:00
fprintf(fid,"***************************************\n");
2011-03-28 18:46:53 +02:00
printf("* DYNARE TEST RESULTS *\n");
2011-08-19 18:10:18 +02:00
fprintf(fid,"* DYNARE TEST RESULTS *\n");
printf("* for make check-octave *\n");
2011-08-19 18:10:18 +02:00
fprintf(fid,"* for make check-octave *\n");
2011-03-28 18:46:53 +02:00
printf("***************************************\n");
2011-08-19 18:10:18 +02:00
fprintf(fid,"***************************************\n");
2011-04-05 16:48:11 +02:00
printf(" %d tests PASSED out of %d tests run\n", total_tests-size(failedBase,2)-size(failedBlock,2), total_tests);
2011-08-19 18:10:18 +02:00
fprintf(fid," %d tests PASSED out of %d tests run\n", total_tests-size(failedBase,2)-size(failedBlock,2), total_tests);
2011-03-28 18:46:53 +02:00
printf("***************************************\n");
2011-08-19 18:10:18 +02:00
fprintf(fid,"***************************************\n");
2011-04-05 16:48:11 +02:00
if size(failedBase,2) > 0 || size(failedBlock,2) > 0
printf("List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2));
2011-08-19 18:10:18 +02:00
fprintf(fid,"List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2));
2011-04-05 16:48:11 +02:00
for i=1:size(failedBase,2)
printf(" * %s\n",failedBase{i});
2011-08-19 18:10:18 +02:00
fprintf(fid," * %s\n", failedBase{i});
2011-04-05 16:48:11 +02:00
end
for i=1:size(failedBlock,2)
printf(" * %s\n",failedBlock{i});
2011-08-19 18:10:18 +02:00
fprintf(fid," * %s\n", failedBlock{i});
2011-03-28 18:46:53 +02:00
end
printf("***************************************\n\n");
2011-08-19 18:10:18 +02:00
fprintf(fid,"***************************************\n\n");
2011-04-05 16:48:11 +02:00
clear -all
error("make check-octave FAILED");
2011-03-28 18:46:53 +02:00
end
2011-08-19 18:10:18 +02:00
fclose(fid);
2011-04-05 16:48:11 +02:00
clear -all
## Local variables:
## mode: Octave
## End: