1 % Automatic
test procedure - based on EQuUs v4.8
2 % Copyright (C) 2015 Peter Rakyta, Ph.D.
4 % This program is free software: you can redistribute it and/or modify
5 % it under the terms of the GNU General Public License as published by
6 % the Free Software Foundation, either version 3 of the License, or
7 % (at your option) any later version.
9 % This program is distributed in the hope that it will be useful,
10 % but WITHOUT ANY WARRANTY; without even the implied warranty of
11 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 % GNU General Public License
for more details.
14 % You should have received a copy of the GNU General Public License
15 % along with
this program. If not, see http:
18 %> @brief Launches the automatic
test procedure. First, source code functionalities are checked by processing the unit tests in directory
'UnitTests' and then larger computational tasks are performed via examples in directory
'Examples' 20 %> EQuUs v4.9 or later
22 %> @brief Launches the automatic
test procedure. First, source code functionalities are checked by processing the unit tests in directory
'UnitTests' and then larger computational tasks are performed via examples in directory
'Examples' 25 filename = mfilename(
'fullpath');
26 root = fileparts( filename );
29 %% code functionality checking
30 fncnames_unitTests = {
'test_Keldysh' ...
32 'test_TMDC_Monolayer' ...
35 % removing previous debug files
36 if exist( [root, filesep,
'UnitTests', filesep,
'debug.txt'],
'file' )
37 delete( [root, filesep, 'UnitTests', filesep, 'debug.txt'] );
40 % change directory to the unit tests
41 cd( [root, filesep, 'UnitTests']);
42 for jdx = 1:length(fncnames_unitTests)
43 fncname = fncnames_unitTests{jdx};
47 % change directory to EQuUs root
51 %% performing larger computational tasks
54 fncnames = {
'magnetic_ribbon', ...
55 'MinimalConductivity', ...
56 'Graphene_Conductivity', ...
57 'magnetic_barrier', ...
58 'Differential_conductance', ...
59 'Graphene_QAD_eig', ...
60 'Graphene_antidot_transport', ...
61 'JosephsonCurrent', ...
62 'SpectralDensity', ...
63 'Self_Consistent_Spectrum', ...
64 'Self_Consistent_Transport', ...
65 'Coulomb_Diamonds', ...
66 'TMDC_Monolayer_Spectrum', ...
71 Dirs = {
'magnetic_ribbon', ... 1
72 'Graphene_Minimal_Conductivity', ... 2
73 'Graphene_Conductivity', ... 3
74 'magnetic_barrier_0B0', ... 4
75 'Differential_conductance', ... 5
76 'Graphene_antidot_eigenstate', ... 6
77 'Graphene_antidot_transport', ... 7
78 'SNS_Josephson', ... 8
79 'SpectralDensity', ... 9
80 'Self_Consistent_Spectrum', ... 10
81 'Self_Consistent_Transport', ... 11
82 'Coulomb_Diamonds', ... 12
83 'TMDC_Monolayer_Spectrum', ... 13
84 'SSH_transport', ... 14
85 'SSH_Josephson' ... 15
88 % These tests are skipped during the
test procedure
91 % the filename of the output to be exported in
92 output_file =
'automatic_test_results.txt';
96 % removing previous debug files
97 delete( [root, filesep,
'Examples', filesep,
'*', filesep,
'debug.txt'] );
99 test_results =
false(size(fncnames));
101 for jdx = 1:length(fncnames)
103 if ~isempty( find(jdx == skip_tests, 1) )
107 test_results(jdx) =
runTest( fncnames{jdx}, Dirs{jdx});
110 fid = fopen(output_file,
'a');
111 fprintf(fid, [
'Test ', fncnames{jdx},
' finished succesfully. Check the results.\n']);
114 fid = fopen(output_file,
'a');
115 fprintf(fid, [
'Test ', fncnames{jdx},
' failed due to coding error.\n']);
123 if norm(
true(size(test_results)) - test_results ) <= 1e-6
124 disp(
'*************************');
125 disp(
'*************************');
126 disp(
'All tests passed.')
127 disp('*************************');
129 for jdx = 1:length(fncnames)
130 if test_results( jdx )
133 failed_fncname = fncnames{ jdx };
134 failed_Dir = Dirs{jdx};
135 disp([
'Test ', fullfile(root,
'Examples', failed_Dir, failed_fncname),
' failed.']);
143 %> @brief Runs the
test for a specific example
144 %> @
param fncname The name of the exmaple to be started.
145 %> @
param directory The absolut path to the directory containing the
test case.
146 function ret =
runTest( fncname, directory)
148 disp(
'**************************************' )
149 disp( ['starting
test: ', fncname] )
150 disp( '**************************************' )
152 directory = fullfile( root, 'Examples', directory);
155 feval( fncname, filenum );
167 %> @brief Determines the up-comming 'filenum' input.
168 %> @
param directory The absolut path to the directory containing the
test case.
169 %> @return Returns with the next filenum value to run the
test case.
173 numerics = {
'1' '2' '3' '4' '5' '6' '7' '8' '9' '0'};
179 list = dir( fullfile( directory,
'results',
'*.mat') );
191 for kdx = 1:length(list)
192 filename_tmp = list(kdx).name;
193 for idx = 1:length(filename_tmp)
194 character = filename_tmp(idx);
195 comp = find(strcmp( character, numerics ));
198 if isempty( start_idx )
202 if isempty( end_idx ) && ~isempty( start_idx )
208 if ~isempty( start_idx ) && ~isempty(end_idx )
209 number_tmp = str2double( filename_tmp(start_idx:end_idx-1) );
function test(arg1, arg2)
Brief description of the function.
Fortran compatible complex type.
function runTest(fncname, directory)
Runs the test for a specific example.
Structure param contains data structures describing the physical parameters of the scattering center ...
function getFilenum(directory)
Determines the up-comming 'filenum' input.
function automatic_test()
Launches the automatic test procedure. First, source code functionalities are checked by processing t...