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' ...
33 'test_Graphene_SOC' ...
34 'test_skew_coupling' ...
37 % removing previous debug files
38 if exist( [root, filesep,
'UnitTests', filesep,
'debug.txt'],
'file' )
39 delete( [root, filesep, 'UnitTests', filesep, 'debug.txt'] );
42 % change directory to the unit tests
43 cd( [root, filesep, 'UnitTests']);
44 for jdx = 1:length(fncnames_unitTests)
45 fncname = fncnames_unitTests{jdx};
49 % change directory to EQuUs root
53 %% performing larger computational tasks
56 fncnames = {
'magnetic_ribbon', ...
57 'MinimalConductivity', ...
58 'Graphene_Conductivity', ...
59 'magnetic_barrier', ...
60 'Differential_conductance', ...
61 'Graphene_QAD_eig', ...
62 'Graphene_antidot_transport', ...
63 'JosephsonCurrent', ...
64 'SpectralDensity', ...
65 'Self_Consistent_Spectrum', ...
66 'Self_Consistent_Transport', ...
67 'Coulomb_Diamonds', ...
68 'TMDC_Monolayer_Spectrum', ...
70 'Graphene_SOC_pnp_transport_q', ...
75 Dirs = {
'magnetic_ribbon', ... 1
76 'Graphene_Minimal_Conductivity', ... 2
77 'Graphene_Conductivity', ... 3
78 'magnetic_barrier_0B0', ... 4
79 'Differential_conductance', ... 5
80 'Graphene_antidot_eigenstate', ... 6
81 'Graphene_antidot_transport', ... 7
82 'SNS_Josephson', ... 8
83 'SpectralDensity', ... 9
84 'Self_Consistent_Spectrum', ... 10
85 'Self_Consistent_Transport', ... 11
86 'Coulomb_Diamonds', ... 12
87 'TMDC_Monolayer_Spectrum', ... 13
89 'Graphene_SOC_pnp_transport_q', ... 15
90 'SSH_transport', ... 16
91 'SSH_Josephson' ... 17
94 % These tests are skipped during the
test procedure
97 % the filename of the output to be exported in
98 output_file =
'automatic_test_results.txt';
102 % removing previous debug files
103 delete( [root, filesep,
'Examples', filesep,
'*', filesep,
'debug.txt'] );
105 test_results =
false(size(fncnames));
107 for jdx = 1:length(fncnames)
109 if ~isempty( find(jdx == skip_tests, 1) )
113 test_results(jdx) =
runTest( fncnames{jdx}, Dirs{jdx});
116 fid = fopen(output_file,
'a');
117 fprintf(fid, [
'Test ', fncnames{jdx},
' finished succesfully. Check the results.\n']);
120 fid = fopen(output_file,
'a');
121 fprintf(fid, [
'Test ', fncnames{jdx},
' failed due to coding error.\n']);
129 if norm(
true(size(test_results)) - test_results ) <= 1e-6
130 disp(
'*************************');
131 disp(
'*************************');
132 disp(
'All tests passed.')
133 disp('*************************');
135 for jdx = 1:length(fncnames)
136 if test_results( jdx )
139 failed_fncname = fncnames{ jdx };
140 failed_Dir = Dirs{jdx};
141 disp([
'Test ', fullfile(root,
'Examples', failed_Dir, failed_fncname),
' failed.']);
149 %> @brief Runs the
test for a specific example
150 %> @
param fncname The name of the exmaple to be started.
151 %> @
param directory The absolut path to the directory containing the
test case.
152 function ret =
runTest( fncname, directory)
154 disp(
'**************************************' )
155 disp( ['starting
test: ', fncname] )
156 disp( '**************************************' )
158 directory = fullfile( root, 'Examples', directory);
161 feval( fncname, filenum );
173 %> @brief Determines the up-comming 'filenum' input.
174 %> @
param directory The absolut path to the directory containing the
test case.
175 %> @return Returns with the next filenum value to run the
test case.
179 numerics = {
'1' '2' '3' '4' '5' '6' '7' '8' '9' '0'};
185 list = dir( fullfile( directory,
'results',
'*.mat') );
197 for kdx = 1:length(list)
198 filename_tmp = list(kdx).name;
199 for idx = 1:length(filename_tmp)
200 character = filename_tmp(idx);
201 comp = find(strcmp( character, numerics ));
204 if isempty( start_idx )
208 if isempty( end_idx ) && ~isempty( start_idx )
214 if ~isempty( start_idx ) && ~isempty(end_idx )
215 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...