Skip to content
Snippets Groups Projects
test_expcodes.m 3.02 KiB
Newer Older
classdef test_expcodes < matlab.unittest.TestCase
  
  properties
    expcode_obj;
    SCDexps;
  properties(ClassSetupParameter)
    expcode = {'1','1005','1007','1008','1010'};        % list of expcodes to test
    shote   = {'68915','68915','70127','68915','68915'}; % different shot per exp code
  methods(TestClassSetup,ParameterCombination='sequential')
    function setup_environment(testCase)
      testCase.addTeardown(@cd,pwd);
      testCase.addTeardown(@path,path);
      testCase.addTeardown(@() SCDclass_expcode.close_all(0))
      
      basePath = fullfile(fileparts(mfilename('fullpath')),'..');
      run(fullfile(basePath,'rtccode_paths'));

      % clear base workspace
      evalin('base','clear');
      
      % get SCD experimental code object container
      testCase.SCDexps = SCDconf_createexpcodes;
      
      SCDconf_setSIMconf; % set ConfigurationSettings for Simulation
    function setup_expcode(testCase,expcode,shote)
      % get this expcode object from expcode object container
      fprintf('\n=== Testing expcode %s ===\n',expcode);
      testCase.expcode_obj = getbymaincode(testCase.SCDexps,str2double(expcode));
      testCase.shot = str2double(shote);
  methods(Test,TestTags={'expcodes'})
Federico Felici's avatar
Federico Felici committed
    function test_expcode_printinfo(testCase)
      testCase.expcode_obj.printinfo
    function test_expcode_init(testCase)
        fprintf('\n=== Testing init for expcode %d: %s === \n',...
        testCase.expcode_obj.maincode,...
        testCase.expcode_obj.name);
      
        testCase.expcode_obj.init; % initialize
    function test_expcode_setup(testCase)    
      fprintf('\n=== Testing setup for expcode %d: %s === \n',...
      testCase.expcode_obj.maincode,...
      testCase.expcode_obj.name);
      testCase.expcode_obj.setup; % run setup this exp code
    function test_expcode_compile_nodes(testCase)
      % compile each node separately first
      nodes = testCase.expcode_obj.getnodes;
      for inode = 1:numel(nodes)
        node = nodes(inode);
        if node.active
          fprintf('\n === Testing Simulink compilation for node %02d of expcode %d: %s === \n',...
            inode,testCase.expcode_obj.maincode,testCase.expcode_obj.name);
          testCase.expcode_obj.compile(inode); % compile single node
        else
          fprintf('skipping compilation for node %d since not active\n',inode)
        end
      end
    end
    
    function test_actualize(testCase)
      testCase.expcode_obj.actualize(testCase.shot);
    end
    
    function test_expcode_sim(testCase)
      testCase.assumeFail('Skipping all simulations tests temporarily to save time')
Federico Felici's avatar
Federico Felici committed
      fprintf('\n === Testing Simulink simulation of tcv.slx for expcode %d: === \n',testCase.expcode_obj.maincode)
      testCase.expcode_obj.sim; % simulate whole tcv.slx with this expcode
    function test_build(testCase)
      testCase.assumeFail('Skipping all build tests temporarily')
      testCase.expcode_obj.build;