test suite parallelization

time-shift
Houtan Bastani 2012-10-05 12:58:34 +02:00
parent fef18460f7
commit 7dbfaebf59
7 changed files with 526 additions and 341 deletions

3
.gitignore vendored
View File

@ -28,6 +28,9 @@ missing
ylwrap
ar-lib
# Make Check Rules
*.trs
# Doc rules
*.pdf
*.aux

View File

@ -1,4 +1,9 @@
MODFILES = \
estimation/fs2000_mc4.mod \
estimation/fs2000_mc4_mf.mod \
estimation/fs2000_mc6.mod \
estimation/fs2000_mc6_mf.mod \
gsa/ls2003.mod \
ramst.mod \
ramst_a.mod \
example1.mod \
@ -96,7 +101,6 @@ MODFILES = \
external_function/example1_no_deriv_functions_provided.mod \
external_function/example1_no_deriv_functions_provided_dll.mod \
seeds.mod \
gsa/ls2003.mod \
identification/kim/kim2.mod \
identification/as2007/as2007.mod \
simul/example1.mod \
@ -142,21 +146,72 @@ MODFILES = \
deterministic_simulations/rbc_det4.mod \
deterministic_simulations/rbc_det5.mod \
fs2000/fs2000_sd.mod \
walsh.mod \
estimation/fs2000_mc4.mod \
estimation/fs2000_mc4_mf.mod \
estimation/fs2000_mc6.mod \
estimation/fs2000_mc6_mf.mod
walsh.mod
# Dependencies
example1_use_dll.m.trs: example1.m.trs
example1_use_dll.o.trs: example1.o.trs
k_order_perturbation/fs2000k_1_m.m.trs: k_order_perturbation/fs2000k2_m.m.trs
k_order_perturbation/fs2000k2_m.m.trs k_order_perturbation/fs2000k3_m.m.trs k_order_perturbation/fs2000k2_use_dll.m.trs k_order_perturbation/fs2000k3_use_dll.m.trs: k_order_perturbation/fs2000k2a.m.trs
k_order_perturbation/fs2000k_1_use_dll.m.trs: k_order_perturbation/fs2000k2_use_dll.m.trs
k_order_perturbation/fs2000k4.m.trs: k_order_perturbation/fs2000k++.m.trs
k_order_perturbation/fs2000k_1_m.o.trs: k_order_perturbation/fs2000k2_m.o.trs
k_order_perturbation/fs2000k2_m.o.trs k_order_perturbation/fs2000k3_m.o.trs k_order_perturbation/fs2000k2_use_dll.o.trs k_order_perturbation/fs2000k3_use_dll.o.trs: k_order_perturbation/fs2000k2a.o.trs
k_order_perturbation/fs2000k_1_use_dll.o.trs: k_order_perturbation/fs2000k2_use_dll.o.trs
k_order_perturbation/fs2000k4.o.trs: k_order_perturbation/fs2000k++.o.trs
kalman_filter_smoother/algo1.m.trs kalman_filter_smoother/algo3.m.trs kalman_filter_smoother/algo4a.m.trs kalman_filter_smoother/algo4b.m.trs kalman_filter_smoother/algoH1.m.trs kalman_filter_smoother/algoH3.m.trs kalman_filter_smoother/fs2000.m.trs kalman_filter_smoother/fs2000_1.m.trs kalman_filter_smoother/fs2000_2.m.trs kalman_filter_smoother/fs2000a.m.trs: kalman_filter_smoother/gen_data.m.trs
kalman_filter_smoother/algo1.o.trs kalman_filter_smoother/algo3.o.trs kalman_filter_smoother/algo4a.o.trs kalman_filter_smoother/algo4b.o.trs kalman_filter_smoother/algoH1.o.trs kalman_filter_smoother/algoH3.o.trs kalman_filter_smoother/fs2000.o.trs kalman_filter_smoother/fs2000_1.o.trs kalman_filter_smoother/fs2000_2.o.trs kalman_filter_smoother/fs2000a.o.trs: kalman_filter_smoother/gen_data.o.trs
kalman_filter_smoother/algo2.m.trs: kalman_filter_smoother/algo1.m.trs
kalman_filter_smoother/algo2.o.trs: kalman_filter_smoother/algo1.o.trs
kalman_filter_smoother/algoH2.m.trs: kalman_filter_smoother/algoH1.m.trs
kalman_filter_smoother/algoH2.o.trs: kalman_filter_smoother/algoH1.o.trs
kalman_filter_smoother/algo4.m.trs: kalman_filter_smoother/algo3.m.trs
kalman_filter_smoother/algo4.o.trs: kalman_filter_smoother/algo3.o.trs
optimal_policy/nk_ramsey_expectation_a.m.trs: optimal_policy/nk_ramsey_expectation.m.trs
optimal_policy/nk_ramsey_expectation_a.o.trs: optimal_policy/nk_ramsey_expectation.o.trs
second_order/ds2.m.trs: second_order/ds1.m.trs
second_order/ds2.o.trs: second_order/ds1.o.trs
AIM/fs2000_b1L1L_AIM.m.trs: AIM/fs2000_b1L1L.m.trs
AIM/fs2000x10L9_L_AIM.m.trs: AIM/fs2000x10L9_L.m.trs
AIM/fs2000x10_L9_L_AIM.m.trs: AIM/fs2000x10_L9_L.m.trs
AIM/ls2003_2L0L_AIM.m.trs: AIM/ls2003_2L0L.m.trs
AIM/ls2003_2L2L_AIM.m.trs: AIM/ls2003_2L2L.m.trs
AIM/fs2000_b1L1L_AIM.o.trs: AIM/fs2000_b1L1L.o.trs
AIM/fs2000x10L9_L_AIM.o.trs: AIM/fs2000x10L9_L.o.trs
AIM/fs2000x10_L9_L_AIM.o.trs: AIM/fs2000x10_L9_L.o.trs
AIM/ls2003_2L0L_AIM.o.trs: AIM/ls2003_2L0L.o.trs
AIM/ls2003_2L2L_AIM.o.trs: AIM/ls2003_2L2L.o.trs
# Matlab TRS Files
MTRSFILES = $(patsubst %.mod, %.m.trs, $(MODFILES))
MTRSFILES += run_block_byte_tests_matlab.m.trs
# Octave TRS Files
OTRSFILES = $(patsubst %.mod, %.o.trs, $(MODFILES))
OTRSFILES += run_block_byte_tests_octave.o.trs
EXTRA_DIST = \
read_trs_files.sh \
run_test_matlab.m \
run_test_octave.m \
$(MODFILES) \
run_block_byte_tests_matlab.m \
run_block_byte_tests_octave.m \
homotopy/common.mod \
block_bytecode/ls2003.mod \
fs2000_ssfile_aux.m \
printMakeCheckMatlabErrMsg.m \
printMakeCheckOctaveErrMsg.m \
ramst_initval_file_data.m \
run_test_matlab.m \
run_test_octave.m \
test.m \
AIM/data_ca1.m \
AIM/fs2000_b1L1L_AIM_steadystate.m \
@ -213,13 +268,44 @@ endif
check-local: $(TARGETS)
check-matlab:
DYNARE_VERSION="$(PACKAGE_VERSION)" MODFILES="$(MODFILES)" $(MATLAB)/bin/matlab -nodesktop -nosplash -r run_test_matlab
if HAVE_OCTAVE
./read_trs_files.sh "$(OTRSFILES)"
endif
check-octave:
DYNARE_VERSION="$(PACKAGE_VERSION)" MODFILES="$(MODFILES)" $(OCTAVE) --no-init-file --silent --no-history run_test_octave.m
if HAVE_CMD_LINE_MATLAB
./read_trs_files.sh "$(MTRSFILES)"
endif
@cat run_test_matlab_output.txt
@cat run_test_octave_output.txt
check-matlab: $(MTRSFILES)
@echo 'Matlab Tests Done'
check-octave: $(OTRSFILES)
@echo 'Octave Tests Done'
%.m.trs %.m.log: %.mod
DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(PWD)" FILESTEM="$*" \
$(MATLAB)/bin/matlab -nosplash -nodisplay -logfile $*.m.log -r run_test_matlab
%.m.trs %.m.log : %.m
DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(PWD)" \
$(MATLAB)/bin/matlab -nosplash -nodisplay -logfile $*.m.log -r $*
%.o.trs %.o.log: %.mod
DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(PWD)" FILESTEM="$*" \
$(OCTAVE) --no-init-file --silent --no-history run_test_octave.m > $*.o.log 2>&1
%.o.trs %.o.log : %.m
DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(PWD)" \
$(OCTAVE) --no-init-file --silent --no-history $< > $*.o.log 2>&1
clean-local:
rm -f $(MTRSFILES) \
$(OTRSFILES) \
$(patsubst %.trs, %.log, $(MTRSFILES)) \
$(patsubst %.trs, %.log, $(OTRSFILES))
rm -f $(patsubst %.mod, %.m, $(MODFILES)) \
$(patsubst %.mod, %_static.*, $(MODFILES)) \
$(patsubst %.mod, %_objective_static.m, $(MODFILES)) \

50
tests/read_trs_files.sh Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
declare -i total=0;
declare -i failed=0;
declare -a failed_tests=("");
# Parse TRS Files
for file in $1 ; do
# Find number of tests run in trs file
((total += `grep number-tests $file | cut -d: -f3`))
# Find number of tests failed in trs file
numfailed=`grep number-failed-tests $file | cut -d: -f3`
if [ $numfailed -ne 0 ] ; then
((failed += $numfailed))
for failedfile in `grep list-of-failed-tests $file | cut -d: -f3` ; do
failed_tests=("${failed_tests[@]}" "$failedfile");
done
fi
done
((passed=$total-$failed));
# Determine if we are parsing Matlab or Octave trs files
if [ `grep -c '.m.trs' <<< $1` -eq 0 ]; then
prg='OCTAVE';
outfile='run_test_octave_output.txt'
else
prg='MATLAB';
outfile='run_test_matlab_output.txt'
fi
# Print Output
echo '================================' > $outfile
echo 'DYNARE MAKE CHECK '$prg' RESULTS' >> $outfile
echo '================================' >> $outfile
echo '| TOTAL: '$total >> $outfile
echo '| PASS: '$passed >> $outfile
echo '| FAIL: '$failed >> $outfile
if [ $failed -gt 0 ] ; then
echo '| LIST OF FAILED TESTS:' >> $outfile
for file in ${failed_tests[@]} ; do
if [ "$prg" == "MATLAB" ]; then
modfile=`sed 's/\.m\.trs/\.mod/g' <<< $file` >> $outfile
else
modfile=`sed 's/\.o\.trs/\.mod/g' <<< $file` >> $outfile
fi
echo '| * '$modfile >> $outfile
done
fi
echo >> $outfile

View File

@ -0,0 +1,152 @@
% Copyright (C) 2011-2012 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/>.
% Implementation notes:
%
% Before every call to Dynare, the contents of the workspace is saved in
% 'wsMat.mat', and reloaded after Dynare has finished (this is necessary since
% Dynare does a 'clear -all'). Also note that we take care of clearing the
% 'exception' variable in all 'catch' block, because otherwise the next 'load
% wsMat' within a 'catch' block will overwrite the last exception.
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath([top_test_dir filesep '..' filesep 'matlab']);
% Test Dynare Version
if ~strcmp(dynare_version(), getenv('DYNARE_VERSION'))
error('Incorrect version of Dynare is being tested')
end
% Test block_bytecode/ls2003.mod with various combinations of
% block/bytecode/solve_algo/stack_solve_algo
failedBlock = {};
num_block_tests = 0;
cd([top_test_dir filesep 'block_bytecode']);
has_optimization_toolbox = user_has_matlab_license('optimization_toolbox');
for blockFlag = 0:1
for bytecodeFlag = 0:1
default_solve_algo = 2;
default_stack_solve_algo = 0;
if ~blockFlag && ~bytecodeFlag
solve_algos = 1:4;
stack_solve_algos = [0 6];
elseif blockFlag && ~bytecodeFlag
solve_algos = [1:4 6:8];
stack_solve_algos = 0:4;
else
solve_algos = 1:8;
stack_solve_algos = 0:5;
end
if has_optimization_toolbox
solve_algos = [ solve_algos 0 ];
end
for i = 1:length(solve_algos)
num_block_tests = num_block_tests + 1;
if ~blockFlag && ~bytecodeFlag && (i == 1)
% This is the reference simulation path against which all
% other simulations will be tested
try
old_path = path;
save wsMat
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsMat
path(old_path);
y_ref = oo_.endo_simul;
save('test.mat','y_ref');
catch exception
load wsMat
path(old_path);
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
clear exception
end
else
try
old_path = path;
save wsMat
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsMat
path(old_path);
% Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
exception = MException('ERROR: simulation path differs from the reference path');
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' 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(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
clear exception
end
end
end
for i = 1:length(stack_solve_algos)
num_block_tests = num_block_tests + 1;
try
old_path = path;
save wsMat
run_ls2003(blockFlag, bytecodeFlag, default_solve_algo, stack_solve_algos(i))
load wsMat
path(old_path);
% Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'];
exception = MException('ERROR: simulation path difers from the reference path');
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' 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(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
clear exception
end
end
end
end
delete('wsMat.mat')
cd(getenv('TOP_TEST_DIR'));
fid = fopen('run_block_byte_tests_matlab.m.trs', 'w+');
if size(failedBlock,2) > 0
fprintf(fid,':test-result: FAIL\n');
fprintf(fid,':number-tests: %d\n', num_block_tests);
fprintf(fid,':number-failed-tests: %d\n', size(failedBlock,2));
fprintf(fid,':list-of-failed-tests: %s\n', failedBlock{:});
fprintf(fid,':copy-in-global-log: yes\n');
fprintf(fid,':recheck: yes\n');
fprintf(fid,':test-global-result: FAIL\n');
else
fprintf(fid,':test-result: PASS\n');
fprintf(fid,':number-tests: %d\n', num_block_tests);
fprintf(fid,':number-failed-tests: 0\n');
fprintf(fid,':list-of-failed-tests: \n');
fprintf(fid,':copy-in-global-log: no\n');
fprintf(fid,':recheck: no\n');
fprintf(fid,':test-global-result: PASS\n');
end
fclose(fid);
exit;

View File

@ -0,0 +1,153 @@
## Copyright (C) 2009-2012 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/>.
## 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').
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath([top_test_dir filesep '..' filesep 'matlab']);
## Test Dynare Version
if !strcmp(dynare_version(), getenv("DYNARE_VERSION"))
error("Incorrect version of Dynare is being tested")
endif
## 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")
## Test block_bytecode/ls2003.mod with various combinations of
## block/bytecode/solve_algo/stack_solve_algo
failedBlock = {};
num_block_tests = 0;
cd([top_test_dir filesep 'block_bytecode']);
for blockFlag = 0:1
for bytecodeFlag = 0:1
## Recall that solve_algo=7 and stack_solve_algo=2 are not supported
## under Octave
default_solve_algo = 2;
default_stack_solve_algo = 0;
if !blockFlag && !bytecodeFlag
solve_algos = 0:4;
stack_solve_algos = [0 6];
elseif blockFlag && !bytecodeFlag
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
sleep(1) # Workaround for strange race condition related to the _static.m file
for i = 1:length(solve_algos)
num_block_tests = num_block_tests + 1;
if !blockFlag && !bytecodeFlag && (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, bytecodeFlag, 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(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
else
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, 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(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' 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(bytecodeFlag) ',' 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(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
endif
endfor
for i = 1:length(stack_solve_algos)
num_block_tests = num_block_tests + 1;
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, 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(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' 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(bytecodeFlag) ',' 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(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(bytecodeFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], lasterror);
end_try_catch
endfor
endfor
endfor
delete('wsOct');
cd(getenv('TOP_TEST_DIR'));
fid = fopen('run_block_byte_tests_octave.o.trs', 'w+');
if size(failedBlock,2) > 0
fprintf(fid,':test-result: FAIL\n');
fprintf(fid,':number-tests: %d\n', num_block_tests);
fprintf(fid,':number-failed-tests: %d\n', size(failedBlock,2));
fprintf(fid,':list-of-failed-tests: %s\n', failedBlock{:});
fprintf(fid,':copy-in-global-log: yes\n');
fprintf(fid,':recheck: yes\n');
fprintf(fid,':test-global-result: FAIL\n');
else
fprintf(fid,':test-result: PASS\n');
fprintf(fid,':number-tests: %d\n', num_block_tests);
fprintf(fid,':number-failed-tests: 0\n');
fprintf(fid,':list-of-failed-tests: \n');
fprintf(fid,':copy-in-global-log: no\n');
fprintf(fid,':recheck: no\n');
fprintf(fid,':test-global-result: PASS\n');
end
fclose(fid);
## Local variables:
## mode: Octave
## End:

View File

@ -15,17 +15,9 @@
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% Implementation notes:
%
% Before every call to Dynare, the contents of the workspace is saved in
% 'wsMat.mat', and reloaded after Dynare has finished (this is necessary since
% Dynare does a 'clear -all'). Also note that we take care of clearing the
% 'exception' variable in all 'catch' block, because otherwise the next 'load
% wsMat' within a 'catch' block will overwrite the last exception.
top_test_dir = pwd;
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath([top_test_dir '/../matlab']);
addpath([top_test_dir filesep '..' filesep 'matlab']);
% Test Dynare Version
if ~strcmp(dynare_version(), getenv('DYNARE_VERSION'))
@ -33,171 +25,44 @@ if ~strcmp(dynare_version(), getenv('DYNARE_VERSION'))
end
% Test MOD files listed in Makefile.am
name=getenv('MODFILES');
num_modfiles = 0;
[modfile, name] = strtok(getenv('FILESTEM'));
[directory, testfile, ext] = fileparts([top_test_dir '/' modfile]);
cd(directory);
failedBase = {};
while ~isempty(name)
[modfile, name] = strtok(name);
num_modfiles = num_modfiles + 1;
[directory, testfile, ext] = fileparts([top_test_dir '/' modfile]);
cd(directory);
disp('');
disp(['*** TESTING: ' modfile ' ***']);
try
old_path = path;
save wsMat
dynare([testfile ext],'console')
clear -all
load wsMat
path(old_path);
catch exception
clear -all
load wsMat
path(old_path);
failedBase{size(failedBase,2)+1} = modfile;
printMakeCheckMatlabErrMsg(modfile, exception);
clear exception
end
close all
delete('wsMat.mat')
cd(top_test_dir);
disp('');
disp(['*** TESTING: ' modfile ' ***']);
try
dynare([testfile ext], 'console')
testFailed = false;
catch exception
printMakeCheckMatlabErrMsg(strtok(getenv('FILESTEM')), exception);
testFailed = true;
end
% Test block_bytecode/ls2003.mod with various combinations of
% block/bytecode/solve_algo/stack_solve_algo
failedBlock = {};
num_block_tests = 0;
cd([top_test_dir '/block_bytecode']);
has_optimization_toolbox = user_has_matlab_license('optimization_toolbox');
for blockFlag = 0:1
for bytecodeFlag = 0:1
default_solve_algo = 2;
default_stack_solve_algo = 0;
if ~blockFlag && ~bytecodeFlag
solve_algos = 1:4;
stack_solve_algos = [0 6];
elseif blockFlag && ~bytecodeFlag
solve_algos = [1:4 6:8];
stack_solve_algos = 0:4;
else
solve_algos = 1:8;
stack_solve_algos = 0:5;
end
if has_optimization_toolbox
solve_algos = [ solve_algos 0 ];
end
for i = 1:length(solve_algos)
num_block_tests = num_block_tests + 1;
if ~blockFlag && ~bytecodeFlag && (i == 1)
% This is the reference simulation path against which all
% other simulations will be tested
try
old_path = path;
save wsMat
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsMat
path(old_path);
y_ref = oo_.endo_simul;
save('test.mat','y_ref');
catch exception
load wsMat
path(old_path);
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], exception);
clear exception
end
else
try
old_path = path;
save wsMat
run_ls2003(blockFlag, bytecodeFlag, solve_algos(i), default_stack_solve_algo)
load wsMat
path(old_path);
% Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
exception = MException('ERROR: simulation path differs from the reference path');
printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' 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/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], exception);
clear exception
end
end
end
for i = 1:length(stack_solve_algos)
num_block_tests = num_block_tests + 1;
try
old_path = path;
save wsMat
run_ls2003(blockFlag, bytecodeFlag, default_solve_algo, stack_solve_algos(i))
load wsMat
path(old_path);
% Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'];
exception = MException('ERROR: simulation path difers from the reference path');
printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' 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/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'];
printMakeCheckMatlabErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], exception);
clear exception
end
end
end
cd(getenv('TOP_TEST_DIR'));
name = strtok(getenv('FILESTEM'));
fid = fopen([name '.m.trs'], 'w');
if fid < 0
wd = pwd
filestep = getenv('FILESTEM')
error(['ERROR: problem opening file ' name '.m.trs for writing....']);
end
delete('wsMat.mat')
cd(top_test_dir);
total_tests = num_modfiles+num_block_tests;
% print output to screen and to file
fid = fopen('run_test_matlab_output.txt', 'w');
fprintf('\n\n\n');
fprintf(fid,'\n\n\n');
disp('***************************************');
fprintf(fid,'***************************************\n');
disp('* DYNARE TEST RESULTS *');
fprintf(fid,'* DYNARE TEST RESULTS *\n');
disp('* for make check-matlab *');
fprintf(fid,'* for make check-matlab *\n');
disp('***************************************');
fprintf(fid,'***************************************\n');
disp([' ' num2str(total_tests-size(failedBase,2)-size(failedBlock,2)) ' tests PASSED out of ' num2str(total_tests) ' tests run']);
fprintf(fid,' %d tests PASSED out of %d tests run\n', total_tests-size(failedBase,2)-size(failedBlock,2), total_tests);
disp('***************************************');
fprintf(fid,'***************************************\n');
if size(failedBase,2) > 0 || size(failedBlock,2) > 0
disp(['List of ' num2str(size(failedBase,2)+size(failedBlock,2)) ' tests FAILED:']);
fprintf(fid,'List of %d tests FAILED:\n', size(failedBase,2)+size(failedBlock,2));
for i=1:size(failedBase,2)
disp([' * ' failedBase{i}]);
fprintf(fid,' * %s\n', failedBase{i});
end
for i=1:size(failedBlock,2)
disp([' * ' failedBlock{i}]);
fprintf(fid,' * %s\n', failedBlock{i});
end
fprintf('***************************************\n\n');
fprintf(fid,'***************************************\n\n');
if testFailed
fprintf(fid,':test-result: FAIL\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 1\n');
fprintf(fid,':list-of-failed-tests: %s\n', [name '.mod']);
fprintf(fid,':copy-in-global-log: yes\n');
fprintf(fid,':recheck: yes\n');
fprintf(fid,':test-global-result: FAIL\n');
else
fprintf(fid,':test-result: PASS\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 0\n');
fprintf(fid,':list-of-failed-tests: \n');
fprintf(fid,':copy-in-global-log: no\n');
fprintf(fid,':recheck: no\n');
fprintf(fid,':test-global-result: PASS\n');
end
fclose(fid);
exit;

View File

@ -1,4 +1,4 @@
## Copyright (C) 2009-2011 Dynare Team
## Copyright (C) 2009-2012 Dynare Team
##
## This file is part of Dynare.
##
@ -21,9 +21,9 @@
## 'wsOct', and reloaded after Dynare has finished (this is necessary since
## Dynare does a 'clear -all').
top_test_dir = pwd;
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath([top_test_dir '/../matlab']);
addpath([top_test_dir filesep '..' filesep 'matlab']);
## Test Dynare Version
if !strcmp(dynare_version(), getenv("DYNARE_VERSION"))
@ -36,165 +36,41 @@ endif
putenv("GNUTERM", "dumb")
## Test MOD files listed in Makefile.am
name = strsplit(getenv("MODFILES"), " ");
name = getenv("FILESTEM");
[directory, testfile, ext] = fileparts([top_test_dir '/' name]);
cd(directory);
printf("\n*** TESTING: %s ***\n", name);
failedBase = {};
for i=1:size(name,2)
[directory, testfile, ext] = fileparts([top_test_dir '/' name{i}]);
cd(directory);
printf("\n*** TESTING: %s ***\n", name{i});
try
old_path = path;
save wsOct
dynare([testfile ext])
clear -all
load wsOct
path(old_path);
catch
clear -all
load wsOct
path(old_path);
failedBase{size(failedBase,2)+1} = name{i};
printMakeCheckOctaveErrMsg(name{i}, lasterror);
end_try_catch
delete('wsOct');
cd(top_test_dir);
end
## Test block_bytecode/ls2003.mod with various combinations of
## block/bytecode/solve_algo/stack_solve_algo
failedBlock = {};
num_block_tests = 0;
cd([top_test_dir '/block_bytecode']);
for blockFlag = 0:1
for bytecodeFlag = 0:1
## Recall that solve_algo=7 and stack_solve_algo=2 are not supported
## under Octave
default_solve_algo = 2;
default_stack_solve_algo = 0;
if !blockFlag && !bytecodeFlag
solve_algos = 0:4;
stack_solve_algos = [0 6];
elseif blockFlag && !bytecodeFlag
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
sleep(1) # Workaround for strange race condition related to the _static.m file
for i = 1:length(solve_algos)
num_block_tests = num_block_tests + 1;
if !blockFlag && !bytecodeFlag && (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, bytecodeFlag, 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/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);
end_try_catch
else
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, 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(abs(diff) > options_.dynatol.x)
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 = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(solve_algos(i)) ', ' num2str(default_stack_solve_algo) ')'], differr);
endif
catch
load wsOct
path(old_path);
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);
end_try_catch
endif
endfor
for i = 1:length(stack_solve_algos)
num_block_tests = num_block_tests + 1;
try
old_path = path;
save wsOct
run_ls2003(blockFlag, bytecodeFlag, 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(abs(diff) > options_.dynatol.x)
failedBlock{size(failedBlock,2)+1} = ['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'];
differr.message = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode/run_ls2003.m(' num2str(blockFlag) ', ' num2str(bytecodeFlag) ', ' num2str(default_solve_algo) ', ' num2str(stack_solve_algos(i)) ')'], differr);
endif
catch
load wsOct
path(old_path);
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);
end_try_catch
endfor
endfor
endfor
delete('wsOct');
try
dynare([testfile ext])
testFailed = false;
catch
printMakeCheckOctaveErrMsg(getenv("FILESTEM"), lasterror);
testFailed = true;
end_try_catch
top_test_dir = getenv('TOP_TEST_DIR');
cd(top_test_dir);
total_tests = size(name,2)+num_block_tests;
% print output to screen and to file
fid = fopen("run_test_octave_output.txt", "w");
printf("\n\n\n");
fprintf(fid,'\n\n\n');
printf("***************************************\n");
fprintf(fid,"***************************************\n");
printf("* DYNARE TEST RESULTS *\n");
fprintf(fid,"* DYNARE TEST RESULTS *\n");
printf("* for make check-octave *\n");
fprintf(fid,"* for make check-octave *\n");
printf("***************************************\n");
fprintf(fid,"***************************************\n");
printf(" %d tests PASSED out of %d tests run\n", total_tests-size(failedBase,2)-size(failedBlock,2), total_tests);
fprintf(fid," %d tests PASSED out of %d tests run\n", total_tests-size(failedBase,2)-size(failedBlock,2), total_tests);
printf("***************************************\n");
fprintf(fid,"***************************************\n");
if size(failedBase,2) > 0 || size(failedBlock,2) > 0
printf("List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2));
fprintf(fid,"List of %d tests FAILED:\n", size(failedBase,2)+size(failedBlock,2));
for i=1:size(failedBase,2)
printf(" * %s\n",failedBase{i});
fprintf(fid," * %s\n", failedBase{i});
end
for i=1:size(failedBlock,2)
printf(" * %s\n",failedBlock{i});
fprintf(fid," * %s\n", failedBlock{i});
end
printf("***************************************\n\n");
fprintf(fid,"***************************************\n\n");
fclose(fid);
error("make check-octave FAILED");
name = getenv("FILESTEM");
fid = fopen([name '.o.trs'], 'w+');
if testFailed
fprintf(fid,':test-result: FAIL\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 1\n');
fprintf(fid,':list-of-failed-tests: %s\n', [name '.mod']);
fprintf(fid,':copy-in-global-log: yes\n');
fprintf(fid,':recheck: yes\n');
fprintf(fid,':test-global-result: FAIL\n');
else
fclose(fid);
endif
fprintf(fid,':test-result: PASS\n');
fprintf(fid,':number-tests: 1\n');
fprintf(fid,':number-failed-tests: 0\n');
fprintf(fid,':list-of-failed-tests: \n');
fprintf(fid,':copy-in-global-log: no\n');
fprintf(fid,':recheck: no\n');
fprintf(fid,':test-global-result: PASS\n');
end
fclose(fid);
## Local variables:
## mode: Octave