Skip to content
Snippets Groups Projects
Commit 8973ed12 authored by Federico Felici's avatar Federico Felici
Browse files

Fix unit tests and algo tests on template

parent 274e67f3
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ unit-tests: ...@@ -36,7 +36,7 @@ unit-tests:
variables: variables:
TESTCASE: "unit" TESTCASE: "unit"
template-tests: algo-tests:
extends: .test-template extends: .test-template
variables: variables:
TESTCASE: "template" TESTCASE: "algos"
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -40,7 +40,7 @@ result = sim(SimIn); ...@@ -40,7 +40,7 @@ result = sim(SimIn);
% check output port data % check output port data
tp = algo_template_loadtp; tp = algo_template_loadtp;
output = result.SimOut{1}.Values.SCDsignal_example_3.Value; output = result.SimOut{1}.Values.signal2.Value;
assert(max(output) == 7,'Wrong output!'); assert(max(output) == 7,'Wrong output!');
% check logs which contain a SCDsignal type data % check logs which contain a SCDsignal type data
...@@ -50,9 +50,6 @@ signal = logsout.getElement('SCDsignal type bus').Values.Value; ...@@ -50,9 +50,6 @@ signal = logsout.getElement('SCDsignal type bus').Values.Value;
Quality = logsout.getElement('SCDsignal type bus').Values.QualityTag; Quality = logsout.getElement('SCDsignal type bus').Values.QualityTag;
State = logsout.getElement('SCDsignal type bus').Values.ProductionState; State = logsout.getElement('SCDsignal type bus').Values.ProductionState;
assert(all(signal.Data(:,1) == tp.gain*tsStructData.simple_signal.Data),...
'Logged signal does not match input!');
assert(all(State .Data == ProductionState.RUNNING),'ProductionState must be RUNNING'); assert(all(State .Data == ProductionState.RUNNING),'ProductionState must be RUNNING');
assert(all(Quality.Data == QualityTag.GOOD ),'QualityTag must be RUNNING' ); assert(all(Quality.Data == QualityTag.GOOD ),'QualityTag must be RUNNING' );
end end
% Bus object: SCDalgo_template_inBus % Bus object: SCDalgo_template_inBus
clear elems; clear elems;
elems(1) = Simulink.BusElement; elems(1) = Simulink.BusElement;
elems(1).Name = 'signal1'; elems(1).Name = 'simple_signal';
elems(1).Dimensions = 1; elems(1).Dimensions = 1;
elems(1).DimensionsMode = 'Fixed'; elems(1).DimensionsMode = 'Fixed';
elems(1).DataType = 'single'; elems(1).DataType = 'single';
......
...@@ -14,7 +14,8 @@ import matlab.unittest.constraints.ContainsSubstring; ...@@ -14,7 +14,8 @@ import matlab.unittest.constraints.ContainsSubstring;
import matlab.unittest.selectors.HasName; import matlab.unittest.selectors.HasName;
%% initialize paths %% initialize paths
rtccode_paths scdds_core_paths;
addpath('tests');
%% populate suite %% populate suite
switch lower(test_case) switch lower(test_case)
...@@ -24,12 +25,8 @@ switch lower(test_case) ...@@ -24,12 +25,8 @@ switch lower(test_case)
fprintf('done \n') fprintf('done \n')
case 'unit' case 'unit'
s = HasTag('Unit'); s = HasTag('Unit');
suite = [matlab.unittest.TestSuite.fromFolder('core/tests',s),... suite = [matlab.unittest.TestSuite.fromFolder('tests',s),...
matlab.unittest.TestSuite.fromFolder(fullfile('tbx','tests'),s),... testsuite(fullfile('classes'),'IncludingSubfolders',true)];
testsuite(fullfile('core','classes'),'IncludingSubfolders',true)];
case 'expcodes'
s = HasTag('expcodes');
suite = matlab.unittest.TestSuite.fromFolder('core/tests',s);
otherwise otherwise
error('unknown test_case %s',test_case) error('unknown test_case %s',test_case)
end end
......
fprintf('setting rtccode paths...\n')
vv=ver('matlab');
assert(strcmp(vv.Version,'9.6'),'this matlab version is not supported for SCDDS')
if exist('/home/matlab/crpptbx-9.6.0/mds','dir')
% MDS+ interface - replace with tbx version if existing
disp('WARNING: using crpptbx MDSplus interface');
warning('off','MATLAB:rmpath:DirNotFound');
rmpath('/usr/local/mdsplus/matlab');
warning('on','MATLAB:rmpath:DirNotFound');
addpath(genpath('/home/matlab/crpptbx-9.6.0/mds'));
%addpath(genpath('/usr/local/mdsplus/matlab.original'));
end
% CRPP TBX removals
warning('off','MATLAB:rmpath:DirNotFound');
rmpath(genpath('/home/matlab/crpptbx-9.6.0/genlib'));
rmpath(genpath('/home/matlab/crpptbx-9.6.0/meq'));
rmpath(genpath('/home/matlab/crpptbx-9.6.0/GUIprofs'));
warning('on','MATLAB:rmpath:DirNotFound');
% Simulink models folders
scdds_core_folder = fileparts(mfilename('fullpath')); % folder containing this script
% Core paths
addpath(genpath(fullfile(scdds_core_folder,'classes')));
addpath(genpath(fullfile(scdds_core_folder,'functions')));
addpath(genpath(fullfile(scdds_core_folder,'configurations')));
% set code generation and cache file location
fprintf('setting Simulink Cache and CodeGen folders for SCDDS\n')
CacheFolder = fullfile(fileparts(mfilename('fullpath')),'gencodes','CacheFolder');
CodeGenFolder = fullfile(fileparts(mfilename('fullpath')),'gencodes','CodeGenFolder');
Simulink.fileGenControl('set',...
'CacheFolder',CacheFolder,...
'CodeGenFolder',CodeGenFolder,...
'createdir',true);
% Turn off warning backtraces
warning('off','backtrace')
clear vv
...@@ -17,8 +17,6 @@ fi ...@@ -17,8 +17,6 @@ fi
matlabbin=$1 matlabbin=$1
testargument=$2 testargument=$2
source rtccode_env.sh
matlabcmd="$matlabbin -nodisplay" matlabcmd="$matlabbin -nodisplay"
matlab_call="tests_matlab('$testargument')" matlab_call="tests_matlab('$testargument')"
full_cmd="$matlabcmd -r $matlab_call"; full_cmd="$matlabcmd -r $matlab_call";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment