Aerospace Blockset for Xcos  

Aerospace Blockset for Xcos Commit Details

Date:2014-09-12 18:36:28 (3 years 10 months ago)
Author:Paweł Zagórski
Branch:master
Commit:c528cf6b907d1a05ab93ffd8401aa7739a08e99c
Parents: c1e3f4621b4d38550a85a6b982d21e150ef84590
Message:Added unit test to check integrity of demos

Changes:
Atests/unit_tests/demos_test.dia.ref (full)
Atests/unit_tests/demos_test.tst (full)

File differences

tests/unit_tests/demos_test.dia.ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// This file is released under the 3-clause BSD license. See COPYING-BSD.
//=================================
// Test flags
//<-- XCOS TEST -->
//<-- NO CHECK ERROR OUTPUT -->
//<-- TEST WITH GRAPHIC -->
//<-- NO CHECK REF -->
s = filesep();
[macros,base_path] = libraryinfo('xcos_aerolib');
demos_path = base_path + '..'+ s + 'demos';
// Define number of demos\
demos_count = 8;
// Locate demo files
demo_files = findfiles(demos_path, '*.zcos');
number_of_files = size(demo_files, 1);
[flag,errmsg] = assert_checktrue(number_of_files==demos_count);
if(~flag)
assert_generror("Number of demo diagrams is equal to " + string(number_of_files) + " instead of " + string(demos_count))
end
demo_files = gsort(demo_files);
for i=1:demos_count
// Check if demos can be imported
result = importXcosDiagram(demos_path + s + demo_files(i));
if(~result)
assert_generror("Failed to load demo: " + demo_files(i))
else
try
scicos_simulate(scs_m);
catch
assert_generror("Demo " + demo_files(i) + " failed")
end
end
end
// Locate macro files
macro_files = findfiles(demos_path, '*.sce');
number_of_macro = size(macro_files,1);
[flag,errmsg] = assert_checktrue(number_of_macro==demos_count+1);
if(~flag)
assert_generror("Number of demo launcher scripts is equal to " + string(number_of_launchers) + " instead of " + string(demos_count))
end
macro_files = gsort(macro_files);
// create list of launcher files
launcher_files = [];
for i =1:number_of_macro
if(strcmp(macro_files(i), "aerospace_blockset.dem.gateway.sce"));
launcher_files= [launcher_files; macro_files(i)];
end
end
number_of_launchers = size(launcher_files, 1);
assert_checktrue(number_of_launchers==demos_count)
ans =
T
// Check if all of the demos have proper launchers
demo_files = strsubst(demo_files,'.zcos','');
launcher_files = strsubst(launcher_files,'.sce','');
assert_checktrue(and(demo_files == launcher_files));
tests/unit_tests/demos_test.tst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// This file is released under the 3-clause BSD license. See COPYING-BSD.
//=================================
// Test flags
//<-- XCOS TEST -->
//<-- NO CHECK ERROR OUTPUT -->
//<-- TEST WITH GRAPHIC -->
//<-- NO CHECK REF -->
s = filesep();
[macros,base_path] = libraryinfo('xcos_aerolib');
demos_path = base_path + '..'+ s + 'demos';
// Define number of demos\
demos_count = 8;
// Locate demo files
demo_files = findfiles(demos_path, '*.zcos');
number_of_files = size(demo_files, 1);
[flag,errmsg] = assert_checktrue(number_of_files==demos_count);
if(~flag)
assert_generror("Number of demo diagrams is equal to " + string(number_of_files) + " instead of " + string(demos_count))
end
demo_files = gsort(demo_files);
for i=1:demos_count
// Check if demos can be imported
result = importXcosDiagram(demos_path + s + demo_files(i));
if(~result)
assert_generror("Failed to load demo: " + demo_files(i))
else
try
scicos_simulate(scs_m);
catch
assert_generror("Demo " + demo_files(i) + " failed")
end
end
end
// Locate macro files
macro_files = findfiles(demos_path, '*.sce');
number_of_macro = size(macro_files,1);
[flag,errmsg] = assert_checktrue(number_of_macro==demos_count+1);
if(~flag)
assert_generror("Number of demo launcher scripts is equal to " + string(number_of_launchers) + " instead of " + string(demos_count))
end
macro_files = gsort(macro_files);
// create list of launcher files
launcher_files = [];
for i =1:number_of_macro
if(strcmp(macro_files(i), "aerospace_blockset.dem.gateway.sce"));
launcher_files= [launcher_files; macro_files(i)];
end
end
number_of_launchers = size(launcher_files, 1);
assert_checktrue(number_of_launchers==demos_count)
// Check if all of the demos have proper launchers
demo_files = strsubst(demo_files,'.zcos','');
launcher_files = strsubst(launcher_files,'.sce','');
assert_checktrue(and(demo_files == launcher_files));

Archive Download the corresponding diff file

Branches