summaryrefslogtreecommitdiff
path: root/modules/development_tools/macros
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/development_tools/macros
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/development_tools/macros')
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkalmostequal.binbin0 -> 26148 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkalmostequal.sci191
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkequal.binbin0 -> 20172 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkequal.sci164
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkerror.binbin0 -> 18912 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkerror.sci157
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkfalse.binbin0 -> 4052 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkfalse.sci43
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkfilesequal.binbin0 -> 17868 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checkfilesequal.sci144
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checktrue.binbin0 -> 4020 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_checktrue.sci43
-rwxr-xr-xmodules/development_tools/macros/assert/assert_comparecomplex.binbin0 -> 17316 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_comparecomplex.sci146
-rwxr-xr-xmodules/development_tools/macros/assert/assert_computedigits.binbin0 -> 15640 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_computedigits.sci108
-rwxr-xr-xmodules/development_tools/macros/assert/assert_cond2reltol.binbin0 -> 20876 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_cond2reltol.sci147
-rwxr-xr-xmodules/development_tools/macros/assert/assert_cond2reqdigits.binbin0 -> 24800 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_cond2reqdigits.sci167
-rwxr-xr-xmodules/development_tools/macros/assert/assert_generror.binbin0 -> 6116 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/assert_generror.sci48
-rwxr-xr-xmodules/development_tools/macros/assert/buildmacros.bat11
-rwxr-xr-xmodules/development_tools/macros/assert/buildmacros.sce11
-rwxr-xr-xmodules/development_tools/macros/assert/cleanmacros.bat14
-rwxr-xr-xmodules/development_tools/macros/assert/cleanmacros.sce16
-rwxr-xr-xmodules/development_tools/macros/assert/libbin0 -> 596 bytes
-rwxr-xr-xmodules/development_tools/macros/assert/names11
-rwxr-xr-xmodules/development_tools/macros/bench_run.binbin0 -> 36316 bytes
-rwxr-xr-xmodules/development_tools/macros/bench_run.sci372
-rwxr-xr-xmodules/development_tools/macros/buildmacros.bat11
-rwxr-xr-xmodules/development_tools/macros/buildmacros.sce18
-rwxr-xr-xmodules/development_tools/macros/cleanmacros.bat13
-rwxr-xr-xmodules/development_tools/macros/devtools_run_builder.binbin0 -> 964 bytes
-rwxr-xr-xmodules/development_tools/macros/devtools_run_builder.sci23
-rwxr-xr-xmodules/development_tools/macros/example_run.binbin0 -> 20008 bytes
-rwxr-xr-xmodules/development_tools/macros/example_run.sci169
-rwxr-xr-xmodules/development_tools/macros/launchtest.binbin0 -> 3448 bytes
-rwxr-xr-xmodules/development_tools/macros/launchtest.sci42
-rwxr-xr-xmodules/development_tools/macros/libbin0 -> 568 bytes
-rwxr-xr-xmodules/development_tools/macros/names11
-rwxr-xr-xmodules/development_tools/macros/nonreg_test_run.binbin0 -> 2248 bytes
-rwxr-xr-xmodules/development_tools/macros/nonreg_test_run.sci39
-rwxr-xr-xmodules/development_tools/macros/scitest.binbin0 -> 21060 bytes
-rwxr-xr-xmodules/development_tools/macros/scitest.sci173
-rwxr-xr-xmodules/development_tools/macros/test_clean.binbin0 -> 20992 bytes
-rwxr-xr-xmodules/development_tools/macros/test_clean.sci223
-rwxr-xr-xmodules/development_tools/macros/test_run.binbin0 -> 163300 bytes
-rwxr-xr-xmodules/development_tools/macros/test_run.sci1301
-rwxr-xr-xmodules/development_tools/macros/test_run_level.binbin0 -> 3732 bytes
-rwxr-xr-xmodules/development_tools/macros/test_run_level.sci37
-rwxr-xr-xmodules/development_tools/macros/testexamples.binbin0 -> 42052 bytes
-rwxr-xr-xmodules/development_tools/macros/testexamples.sci268
-rwxr-xr-xmodules/development_tools/macros/unit_test_run.binbin0 -> 2216 bytes
-rwxr-xr-xmodules/development_tools/macros/unit_test_run.sci39
55 files changed, 4160 insertions, 0 deletions
diff --git a/modules/development_tools/macros/assert/assert_checkalmostequal.bin b/modules/development_tools/macros/assert/assert_checkalmostequal.bin
new file mode 100755
index 000000000..163207296
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkalmostequal.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_checkalmostequal.sci b/modules/development_tools/macros/assert/assert_checkalmostequal.sci
new file mode 100755
index 000000000..fdab30309
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkalmostequal.sci
@@ -0,0 +1,191 @@
+// Copyright (C) 2008 - 2009 - INRIA - Michael Baudin
+// Copyright (C) 2009 - 2011 - DIGITEO - Michael Baudin
+// Copyright (C) 2012 - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [flag,errmsg] = assert_checkalmostequal ( varargin )
+ // Check that computed and expected are numerically close.
+
+ [lhs,rhs]=argn()
+ if ( and(rhs <> [2 3 4 5] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d to %d expected.") , "assert_checkalmostequal" , 2 , 5 )
+ error(errmsg)
+ end
+ //
+ // Get arguments
+ computed = varargin(1)
+ expected = varargin(2)
+ reltol = argindefault ( rhs , varargin , 3 , sqrt(%eps) )
+ abstol = argindefault ( rhs , varargin , 4 , 0 )
+ comptype = argindefault ( rhs , varargin , 5 , "element" )
+ //
+ // Check types of variables
+ if ( and(typeof(computed) <> ["constant" "sparse" "hypermat"]) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_checkalmostequal" , 1 )
+ error(errmsg)
+ end
+ if ( and(typeof(expected) <> ["constant" "sparse" "hypermat"]) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_checkalmostequal" , 2 )
+ error(errmsg)
+ end
+ if ( typeof(reltol) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_checkalmostequal" , 3 )
+ error(errmsg)
+ end
+ if ( typeof(abstol) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_checkalmostequal" , 4 )
+ error(errmsg)
+ end
+ if ( typeof(comptype) <> "string" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix of strings expected.\n") , "assert_checkalmostequal" , 5 )
+ error(errmsg)
+ end
+ //
+ // Check sizes of variables
+ if ( size(reltol,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_checkalmostequal" , 3 , 1 , 1 )
+ error(errmsg)
+ end
+ if ( size(abstol,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_checkalmostequal" , 4 , 1 , 1 )
+ error(errmsg)
+ end
+ if ( size(comptype,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_checkalmostequal" , 5 , 1 , 1 )
+ error(errmsg)
+ end
+ //
+ // Check values of variables
+ if ( reltol < 0 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Must be > %d.\n") , "assert_checkalmostequal" , 3 , 0 )
+ error(errmsg)
+ end
+ if ( abstol < 0 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Must be > %d.\n") , "assert_checkalmostequal" , 4 , 0 )
+ error(errmsg)
+ end
+ if ( and ( comptype <> ["matrix" "element"] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Must be in the set {%s}.\n") , "assert_checkalmostequal" , 5 , """matrix"",""element""" )
+ error(errmsg)
+ end
+ //
+ // Proceed...
+ ncom = size(computed)
+ nexp = size(expected)
+ if ( or(ncom <> nexp) ) then
+ errmsg = sprintf ( gettext ( "%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n" ) , "assert_checkalmostequal" , 1 , 2 )
+ error(errmsg)
+ end
+ //
+ areequal_re = assert_arealmostequal ( real(computed) , real(expected) , reltol , abstol , comptype )
+ if ( areequal_re ) then
+ areequal = assert_arealmostequal ( imag(computed) , imag(expected) , reltol , abstol , comptype )
+ else
+ areequal = %f
+ end
+ //
+ if ( areequal ) then
+ flag = %t
+ errmsg = ""
+ else
+ flag = %f
+ // Change the message if the matrix contains more than one value
+ if ( size(expected,"*") == 1 ) then
+ estr = string(expected)
+ else
+ estr = "[" + string(expected(1)) + " ...]"
+ end
+ if ( size(computed,"*") == 1 ) then
+ cstr = string(computed)
+ else
+ cstr = "[" + string(computed(1)) + " ...]"
+ end
+ relstr = string(reltol)
+ absstr = string(abstol)
+ errmsg = msprintf(gettext("%s: Assertion failed: expected = %s while computed = %s"),"assert_checkalmostequal",estr,cstr)
+ if ( lhs < 2 ) then
+ // If no output variable is given, generate an error
+ assert_generror ( errmsg )
+ end
+ end
+endfunction
+
+// Returns the indices where
+// * kpinf : x(kpinf) == +%inf,
+// * kninf : x(kninf) == -%inf,
+// * knan : x(knan) is a %nan
+// * kreg : x(kreg) is not an infinity, not a nan
+// * xreg = x(kreg)
+// These 4 sets of indices have no intersection.
+//
+// Example :
+// x = [1 2 3 -%inf %inf %nan %inf %nan -%inf 4 5 6]
+// [kpinf , kninf , knan , kreg , xreg] = infnanindices ( x )
+// xreg = [1 2 3 4 5 6]
+// kreg = [1 2 3 10 11 12]
+// knan = [6 8]
+// kninf = [4 9]
+// kpinf = [5 7]
+function [kpinf , kninf , knan , kreg , xreg] = infnanindices ( x )
+ kpinf = find(x==%inf)
+ kninf = find(x==-%inf)
+ knan = find(isnan(x))
+ kreg = find(abs(x)<>%inf & ~isnan(x))
+ xreg = x(kreg)
+endfunction
+
+
+function areequal = assert_arealmostequal ( computed , expected , reltol , abstol , comptype )
+ //
+ // Decompose the expected value into nan indices, inf indices and regular indices
+ // This allows to solve the following issue:
+ // if computed is %inf and expected is %inf, the difference is %nan,
+ // which makes the computations fail.
+ if ( computed == [] & expected == []) then
+ areequal = %t
+ return
+ end
+ [kcpinf , kcninf , kcnan , kcreg , creg] = infnanindices ( computed )
+ [kepinf , keninf , kenan , kereg , ereg] = infnanindices ( expected )
+ //
+ if ( comptype == "matrix" ) then
+ areclose = ( norm ( creg - ereg ) <= reltol * max(norm(ereg),norm(creg) ) + abstol )
+ else
+ if (creg==[]&ereg==[]) then
+ areclose=%t
+ elseif (creg<>[]&ereg==[]) then
+ areclose=%f
+ elseif (creg==[]&ereg<>[]) then
+ areclose=%f
+ else
+ entries = ( abs(creg-ereg) <= reltol * max(abs(ereg),abs(creg)) + abstol )
+ // Compute the global condition from the entries conditions
+ areclose = and(entries)
+ end
+ end
+ // The regular values must be almost equal and
+ // * the +%inf must be at the same place,
+ // * the -%inf must be at the same place,
+ // * the %nan must be at the same place.
+ areequal = ( areclose & and(kcpinf == kepinf) & and(kcninf == keninf) & and(kcnan == kenan) )
+endfunction
+function argin = argindefault ( rhs , vararglist , ivar , default )
+ // Returns the value of the input argument #ivar.
+ // If this argument was not provided, or was equal to the
+ // empty matrix, returns the default value.
+ if ( rhs < ivar ) then
+ argin = default
+ else
+ if ( vararglist(ivar) <> [] ) then
+ argin = vararglist(ivar)
+ else
+ argin = default
+ end
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_checkequal.bin b/modules/development_tools/macros/assert/assert_checkequal.bin
new file mode 100755
index 000000000..d2c973849
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkequal.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_checkequal.sci b/modules/development_tools/macros/assert/assert_checkequal.sci
new file mode 100755
index 000000000..444980cbd
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkequal.sci
@@ -0,0 +1,164 @@
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [flag,errmsg] = assert_checkequal ( computed , expected )
+ // Check that computed and expected are equal.
+
+ function flag = comparedoubles ( computed , expected )
+ [cnonan , cnumb] = mythrownan(computed)
+ [enonan , enumb] = mythrownan(expected)
+ if ( and(enonan == cnonan) & and(enumb == cnumb) ) then
+ flag = %t
+ else
+ flag = %f
+ end
+ endfunction
+
+ function [nonan,numb] = mythrownan(x)
+ //
+ //
+ // Copyright (C) 2000 - INRIA - Carlos Klimann
+ // Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+ //This function returns in vector nonan the values
+ //(ignoring the NANs) of a vector or matrix x and in the
+ //corresponding places of vector numb the indexes of the
+ //value.
+ //
+ //For a vector or matrix x, [nonan,numb]=thrownan(x)
+ //considers x, whatever his dimensions are, like a linear
+ //vector (columns first).
+ //
+ //
+ [lhs,rhs]=argn(0)
+ if ( rhs<>1 ) then
+ error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"thrownan",1))
+ end
+ numb=find(bool2s(~isnan(x)))
+ nonan=x(~isnan(x))
+ endfunction
+
+ [lhs,rhs]=argn()
+ if ( rhs <> 2 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d expected.\n") , "assert_checkequal" , 2 )
+ error(errmsg)
+ end
+
+ // Check types of variables
+ if ( typeof(computed) <> typeof(expected) ) then
+ errmsg = sprintf ( gettext ( "%s: Incompatible input arguments #%d and #%d: Same types expected.\n" ) , "assert_checkequal" , 1 , 2 )
+ error(errmsg)
+ end
+
+ // Check hypermat type
+ if (typeof(computed) == "hypermat") then
+ // Check on first element type
+ if (typeof(computed(1)) <> typeof(expected(1))) then
+ errmsg = sprintf ( gettext ( "%s: Incompatible input arguments #%d and #%d: Same types expected.\n" ) , "assert_checkequal" , 1 , 2 )
+ error(errmsg)
+ end
+ end
+
+
+ //
+ // Check sizes of variables
+ if ( or(type(computed)==[16 17]) ) then
+ ncom = length(computed)
+ else
+ ncom = size(computed)
+ end
+ if ( or(type(expected)==[16 17]) ) then
+ nexp = length(expected)
+ else
+ nexp = size(expected)
+ end
+ if ( or(ncom <> nexp) ) then
+ errmsg = sprintf ( gettext ( "%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n") , "assert_checkequal" , 1 , 2 )
+ error(errmsg)
+ end
+ //
+ if ( type(computed) == 1 & type(expected) == 1 ) then
+ // These are two matrices of doubles
+ cisreal = isreal(computed)
+ eisreal = isreal(expected)
+ if ( cisreal & ~eisreal ) then
+ errmsg = sprintf ( gettext ( "%s: Computed is real, but expected is complex.") , "assert_checkequal" )
+ error(errmsg)
+ end
+ if ( ~cisreal & eisreal ) then
+ errmsg = sprintf ( gettext ( "%s: Computed is complex, but expected is real.") , "assert_checkequal" )
+ error(errmsg)
+ end
+ if ( cisreal & eisreal ) then
+ flag = comparedoubles ( computed , expected )
+ else
+ flagreal = comparedoubles ( real(computed) , real(expected) )
+ if ( flagreal ) then
+ flagimag = comparedoubles ( imag(computed) , imag(expected) )
+ flag = flagimag
+ else
+ flag = %f
+ end
+ end
+ else
+ if ( and ( computed == expected ) ) then
+ flag = %t
+ else
+ flag = %f
+ end
+ end
+
+ if ( flag == %t ) then
+
+ errmsg = ""
+ else
+ // Change the message if the matrix contains more than one value
+ if ( size(expected,"*") == 1 ) then
+ if ( or(typeof(expected) == ["sparse", "boolean sparse"])) then
+ val = full(expected)
+ else
+ val = expected
+ end
+ estr = string(val)
+ else
+ if ( or(typeof(expected) == ["sparse", "boolean sparse"])) then
+ val = full(expected(1))
+ else
+ val = expected(1)
+ end
+ estr = "[" + string(val) + " ...]"
+ end
+ if ( size(computed,"*") == 1 ) then
+ if ( or(typeof(computed) == ["sparse", "boolean sparse"])) then
+ val = full(computed)
+ else
+ val = computed
+ end
+ cstr = string(val)
+ else
+ if ( or(typeof(computed) == ["sparse", "boolean sparse"])) then
+ val = full(computed(1))
+ else
+ val = computed(1)
+ end
+ cstr = "[" + string(val) + " ...]"
+ end
+ ierr = execstr("mdiff = string(mean(computed - expected))", "errcatch");
+ if ( ierr == 0 ) then
+ errmsg = msprintf(gettext("%s: Assertion failed: expected = %s while computed = %s (mean diff = %s)"),"assert_checkequal",estr,cstr,mdiff)
+ else
+ errmsg = msprintf(gettext("%s: Assertion failed: expected = %s while computed = %s"),"assert_checkequal",estr,cstr)
+ end
+ if ( lhs < 2 ) then
+ // If no output variable is given, generate an error
+ assert_generror ( errmsg )
+ end
+ end
+endfunction
+
+
diff --git a/modules/development_tools/macros/assert/assert_checkerror.bin b/modules/development_tools/macros/assert/assert_checkerror.bin
new file mode 100755
index 000000000..1812e3be4
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkerror.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_checkerror.sci b/modules/development_tools/macros/assert/assert_checkerror.sci
new file mode 100755
index 000000000..83ee7d29c
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkerror.sci
@@ -0,0 +1,157 @@
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [flag,errmsg] = assert_checkerror ( varargin )
+ // Check that an instruction produces the expected error.
+
+ [lhs,rhs]=argn()
+ if ( rhs < 2 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input argument: At least %d expected.\n") , "assert_checkerror" , 2 )
+ error(errmsg)
+ end
+ //
+ // Get arguments
+ instr = varargin(1);
+ expectedmsg = varargin(2);
+ expectederrnb = argindefault ( rhs , varargin , 3 , [] );
+ //
+ // Check types of variables
+ if ( typeof(instr) <> "string" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix of strings expected.\n") , "assert_checkerror" , 1 )
+ error(errmsg)
+ end
+ if (expectedmsg<>[]) then
+ if ( typeof(expectedmsg) <> "string" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix of strings expected.\n") , "assert_checkerror" , 2 )
+ error(errmsg)
+ end
+ end
+ if ( typeof(expectederrnb) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_checkerror" , 3 )
+ error(errmsg)
+ end
+ //
+ // Check sizes of variables
+ if ( size(instr,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_checkerror" , 1 , 1 , 1 )
+ error(errmsg)
+ end
+ if (expectedmsg<>[]) then
+ if ((size(expectedmsg, "r") > 1) & (size(expectedmsg, "c") > 1))
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: A string vector expected.\n") , "assert_checkerror" , 2 );
+ error(errmsg)
+ end
+ end
+ if ( expectederrnb <> [] ) then
+ if ( size(expectederrnb,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_checkerror" , 3 , 1 , 1 )
+ error(errmsg)
+ end
+ end
+ //
+ // Check values of variables
+ if (expectedmsg<>[]) then
+ if ( expectederrnb <> [] ) then
+ if ( expectederrnb < 0 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Non-negative integers expected.\n" ) , "assert_checkerror" , 3 )
+ error(errmsg)
+ end
+ end
+ else
+ // If the message is empty (arg #2), check that the error
+ // number is not empty (arg #3).
+ if ( expectederrnb == [] ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: Non-empty matrix expected.\n" ) , "assert_checkerror" , 3 )
+ error(errmsg)
+ end
+ end
+ //
+ // Proceed...
+ compierr = execstr(instr,"errcatch")
+ //
+ // Check that an error is produced
+ if ( compierr == 0 ) then
+ localstr = gettext ( "%s: No error was produced while evaluating ""%s"".")
+ errmsg = sprintf ( localstr , "assert_checkerror" , instr )
+ error(errmsg)
+ end
+ //
+ // Get the error
+ compmsg = lasterror();
+ //
+ // Initialize output arguments
+ flag = %t
+ errmsg = ""
+ //
+ // Localize the message, if necessary.
+ if ( rhs >= 4 ) then
+ localmsg = gettext(expectedmsg)
+ instr = "expectedmsg = msprintf(localmsg, varargin(4:$))"
+ ierr = execstr(instr,"errcatch")
+ if ( ierr <> 0 ) then
+ fmterrmsg = lasterror();
+ localstr = gettext ( "%s: Error while formatting the error message: ""%s""")
+ errmsg = sprintf ( localstr , "assert_checkerror" , fmterrmsg )
+ error(errmsg)
+ end
+ end
+ //
+ // Check the error message
+ if (expectedmsg <> []) then
+ isdifferentmsg = or(expectedmsg <> compmsg);
+
+ if (isdifferentmsg) then
+ flag = %f
+ if size(compmsg, "*") <> 1 then
+ compmsg = sci2exp(compmsg);
+ end
+ if size(expectedmsg, "*") <> 1 then
+ expectedmsg = sci2exp(expectedmsg);
+ end
+ localstr = gettext("%s: Assertion failed: expected error message = ""%s"" while computed error message = ""%s"".")
+ errmsg = msprintf(localstr,"assert_checkerror", expectedmsg, compmsg)
+ if ( lhs < 2 ) then
+ // If no output variable is given, generate an error
+ error ( errmsg )
+ else
+ return
+ end
+ end
+ end
+ if ( expectederrnb <> [] ) then
+ //
+ // Check the error number
+ if ( expectederrnb <> compierr ) then
+ flag = %f
+ localstr = gettext("%s: Assertion failed: expected error number = %d while computed error number = %d.")
+ errmsg = msprintf(localstr,"assert_checkerror",expectederrnb,compierr)
+ if ( lhs < 2 ) then
+ // If no output variable is given, generate an error
+ error ( errmsg )
+ else
+ return
+ end
+ end
+ end
+endfunction
+function argin = argindefault ( rhs , vararglist , ivar , default )
+ // Returns the value of the input argument #ivar.
+ // If this argument was not provided, or was equal to the
+ // empty matrix, returns the default value.
+ if ( rhs < ivar ) then
+ argin = default
+ else
+ if ( vararglist(ivar) <> [] ) then
+ argin = vararglist(ivar)
+ else
+ argin = default
+ end
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_checkfalse.bin b/modules/development_tools/macros/assert/assert_checkfalse.bin
new file mode 100755
index 000000000..28224c995
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkfalse.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_checkfalse.sci b/modules/development_tools/macros/assert/assert_checkfalse.sci
new file mode 100755
index 000000000..c66097089
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkfalse.sci
@@ -0,0 +1,43 @@
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [flag,errmsg] = assert_checkfalse ( condition )
+ // Check that condition is false.
+
+ [lhs,rhs]=argn()
+ if ( rhs <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d expected.\n") , "assert_checkfalse" , 1 )
+ error(errmsg)
+ end
+ //
+ // Check types of variables
+ if ( typeof(condition) <> "boolean" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Boolean matrix expected.\n") , "assert_checkfalse" , 1 )
+ error(errmsg)
+ end
+ //
+ if ( and(~condition) ) then
+ flag = %t
+ errmsg = ""
+ else
+ flag = %f
+ if ( size(condition,"*") == 1 ) then
+ cstr = string(condition)
+ else
+ cstr = "[" + string(condition(1)) + " ...]"
+ end
+ errmsg = msprintf(gettext("%s: Assertion failed: found false entry in condition = %s"), ..
+ "assert_checkfalse",cstr)
+ if ( lhs < 2 ) then
+ // If no output variable is given, generate an error
+ assert_generror ( errmsg )
+ end
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_checkfilesequal.bin b/modules/development_tools/macros/assert/assert_checkfilesequal.bin
new file mode 100755
index 000000000..162d153e6
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkfilesequal.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_checkfilesequal.sci b/modules/development_tools/macros/assert/assert_checkfilesequal.sci
new file mode 100755
index 000000000..8f3435637
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checkfilesequal.sci
@@ -0,0 +1,144 @@
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [flag,errmsg] = assert_checkfilesequal ( varargin )
+ // Check two files are equal.
+
+ [lhs,rhs]=argn()
+ if ( and ( rhs <> [ 2 3 ] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d to %d expected.") , "assert_checkfilesequal" , 2 , 3 )
+ error(errmsg)
+ end
+ //
+ // Get input arguments
+ filecomp = varargin(1)
+ fileref = varargin(2)
+ if ( rhs <= 2 ) then
+ compfun = []
+ else
+ compfun = varargin(3)
+ end
+ //
+ // Check types of variables
+ if ( typeof(filecomp) <> "string" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix of strings expected.\n") , "assert_checkfilesequal" , 1 )
+ error(errmsg)
+ end
+ if ( typeof(fileref) <> "string" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix of strings expected.\n") , "assert_checkfilesequal" , 2 )
+ error(errmsg)
+ end
+ if ( compfun <> [] ) then
+ if ( and ( typeof(compfun) <> [ "function" "list" ] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Expected type ""%s"" or ""%s"" for input argument %s #%d, but got %s instead.") , "assert_checkfilesequal" , "function" , "list" , "compfun" , 3 , typeof(compfun) )
+ error(errmsg)
+ end
+ end
+ //
+ // Check sizes of variables
+ if ( size(filecomp,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_checkfilesequal" , 1 , 1 , 1 )
+ error(errmsg)
+ end
+ if ( size(fileref,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_checkfilesequal" , 2 , 1 , 1 )
+ error(errmsg)
+ end
+ //
+ // Test if both files exist on disk
+ if ( fileinfo(filecomp) == [] ) then
+ flag = %f
+ errmsg = sprintf ( gettext ( "%s: The file %s does not exist.\n") , "assert_checkfilesequal" , filecomp )
+ if ( lhs < 2 ) then
+ assert_generror ( errmsg )
+ else
+ return
+ end
+ end
+ if ( fileinfo(fileref) == [] ) then
+ flag = %f
+ errmsg = sprintf ( gettext ( "%s: The file %s does not exist.\n") , "assert_checkfilesequal" , fileref )
+ if ( lhs < 2 ) then
+ assert_generror ( errmsg )
+ else
+ return
+ end
+ end
+ //
+ // Open files
+ [fdc,err] = mopen(filecomp,"r")
+ if ( err <> 0 ) then
+ flag = %f
+ errmsg = sprintf ( gettext ( "%s: Cannot open file %s.\n") , "assert_checkfilesequal" , filecomp )
+ if ( lhs < 2 ) then
+ assert_generror ( errmsg )
+ else
+ return
+ end
+ end
+ [fdr,err] = mopen(fileref,"r")
+ if ( err <> 0 ) then
+ flag = %f
+ errmsg = sprintf ( gettext ( "%s: Cannot open file %s.\n") , "assert_checkfilesequal" , fileref )
+ if ( lhs < 2 ) then
+ assert_generror ( errmsg )
+ else
+ return
+ end
+ end
+ //
+ // Get contents
+ txtcomp = mgetl(fdc)
+ txtref = mgetl(fdr)
+ //
+ // Compare contents
+ if ( compfun <> [] ) then
+ if ( typeof(compfun) == "function" ) then
+ areeq = compfun ( txtcomp , txtref )
+ else
+ // compfun is a list
+ cf = compfun(1)
+ areeq = cf ( txtcomp , txtref , compfun(2:$) )
+ end
+ else
+ areeq = ( txtcomp == txtref )
+ end
+ if ( areeq ) then
+ flag = %t
+ errmsg = ""
+ else
+ flag = %f
+ errmsg = msprintf(gettext("%s: The content of computed file ""%s"" is different from the content of reference file ""%s""."), ..
+ "assert_checkfilesequal",filecomp,fileref)
+ // Do not generate the error now: let us close the files before!
+ end
+ //
+ // Close the files
+ err=mclose(fdc)
+ if ( err <> 0 ) then
+ flag = %f
+ errmsg = sprintf ( gettext ( "%s: Cannot close file %s.\n") , "assert_checkfilesequal" , filecomp )
+ // It may happen that we overwrite the content of the errmsg varaiable.
+ // For example, we are there, while the file contents were different.
+ // We consider that that not being able to close the file is a bigger issue,
+ end
+ err=mclose(fdr)
+ if ( err <> 0 ) then
+ errmsg = sprintf ( gettext ( "%s: Cannot close file %s.\n") , "assert_checkfilesequal" , fileref )
+ // It may happen that we overwrite the content of the errmsg varaiable.
+ // For example, we are there, while the file contents were different.
+ // We consider that that not being able to close the file is a bigger issue,
+ end
+
+ if ( ~flag & lhs < 2 ) then
+ // If no output variable is given, generate an error
+ assert_generror ( errmsg )
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_checktrue.bin b/modules/development_tools/macros/assert/assert_checktrue.bin
new file mode 100755
index 000000000..ed25c49ce
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checktrue.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_checktrue.sci b/modules/development_tools/macros/assert/assert_checktrue.sci
new file mode 100755
index 000000000..2cb49c47d
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_checktrue.sci
@@ -0,0 +1,43 @@
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [flag,errmsg] = assert_checktrue ( condition )
+ // Check that condition is true.
+
+ [lhs,rhs]=argn()
+ if ( rhs <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d expected.\n") , "assert_checktrue" , 1 )
+ error(errmsg)
+ end
+ //
+ // Check types of variables
+ if ( typeof(condition) <> "boolean" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Boolean matrix expected.\n" ) , "assert_checktrue" , 1 )
+ error(errmsg)
+ end
+ //
+ if ( and(condition) ) then
+ flag = %t
+ errmsg = ""
+ else
+ flag = %f
+ if ( size(condition,"*") == 1 ) then
+ cstr = string(condition)
+ else
+ cstr = "[" + string(condition(1)) + " ...]"
+ end
+ errmsg = msprintf(gettext("%s: Assertion failed: found false entry in condition = %s"), ..
+ "assert_checktrue",cstr)
+ if ( lhs < 2 ) then
+ // If no output variable is given, generate an error
+ assert_generror ( errmsg )
+ end
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_comparecomplex.bin b/modules/development_tools/macros/assert/assert_comparecomplex.bin
new file mode 100755
index 000000000..7f4734981
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_comparecomplex.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_comparecomplex.sci b/modules/development_tools/macros/assert/assert_comparecomplex.sci
new file mode 100755
index 000000000..64b0f0871
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_comparecomplex.sci
@@ -0,0 +1,146 @@
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function order = assert_comparecomplex ( varargin )
+ // Compare complex numbers with a tolerance.
+
+ [lhs,rhs]=argn()
+ if ( and(rhs <> [2 3 4] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d to %d expected.") , "assert_comparecomplex" , 2 , 4 )
+ error(errmsg)
+ end
+ //
+ // Get arguments
+ a = varargin(1)
+ b = varargin(2)
+ reltol = argindefault ( rhs , varargin , 3 , sqrt(%eps) )
+ abstol = argindefault ( rhs , varargin , 4 , 0 )
+ //
+ // Check types of variables
+ if ( typeof(a) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_comparecomplex" , 1 )
+ error(errmsg)
+ end
+ if ( typeof(a) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_comparecomplex" , 2 )
+ error(errmsg)
+ end
+ if ( typeof(reltol) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_comparecomplex" , 3 )
+ error(errmsg)
+ end
+ if ( typeof(abstol) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_comparecomplex" , 4 )
+ error(errmsg)
+ end
+ //
+ // Check sizes of variables
+ if ( size(a,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_comparecomplex" , 1 , 1 , 1 )
+ error(errmsg)
+ end
+ if ( size(b,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_comparecomplex" , 2 , 1 , 1 )
+ error(errmsg)
+ end
+ if ( size(reltol,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_comparecomplex" , 3 , 1 , 1 )
+ error(errmsg)
+ end
+ if ( size(abstol,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_comparecomplex" , 4 , 1 , 1 )
+ error(errmsg)
+ end
+ //
+ // Check values of variables
+ if ( reltol < 0 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Must be > %d.\n") , "assert_comparecomplex" , 3 , 0 )
+ error(errmsg)
+ end
+ if ( abstol < 0 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Must be > %d.\n") , "assert_comparecomplex" , 4 , 0 )
+ error(errmsg)
+ end
+ //
+ ord_re = assert_compdata ( real(a) , real(b) , reltol , abstol )
+ if ( ord_re == 0 ) then
+ // Tie on the real part: compare imaginary parts
+ ord_im = assert_compdata ( imag(a) , imag(b) , reltol , abstol )
+ if ( ord_im == 0 ) then
+ // Tie on imaginary parts too: two numbers are "equal"
+ order = 0
+ elseif ( ord_im == -1 ) then
+ order = -1
+ else
+ order = 1
+ end
+ elseif ( ord_re == -1 ) then
+ order = -1
+ else
+ order = 1
+ end
+endfunction
+
+function order = assert_compdata ( a , b , reltol , abstol )
+ if ( a == %inf ) then
+ if ( isnan(b) ) then
+ order = -1
+ elseif ( b == %inf ) then
+ order = 0
+ else
+ order = 1
+ end
+ elseif ( a == -%inf ) then
+ if ( b == -%inf ) then
+ order = 0
+ else
+ order = -1
+ end
+ elseif ( isnan(a) ) then
+ if ( isnan(b) ) then
+ order = 0
+ else
+ order = 1
+ end
+ else
+ if ( isnan(b) ) then
+ order = -1
+ elseif ( b == -%inf ) then
+ order = 1
+ elseif ( b == %inf ) then
+ order = -1
+ else
+ areequal = abs ( a - b ) <= reltol * max ( abs(a) , abs(b) ) + abstol
+ if ( areequal ) then
+ order = 0
+ elseif ( a < b ) then
+ order = -1
+ else
+ order = 1
+ end
+ end
+ end
+endfunction
+
+
+function argin = argindefault ( rhs , vararglist , ivar , default )
+ // Returns the value of the input argument #ivar.
+ // If this argument was not provided, or was equal to the
+ // empty matrix, returns the default value.
+ if ( rhs < ivar ) then
+ argin = default
+ else
+ if ( vararglist(ivar) <> [] ) then
+ argin = vararglist(ivar)
+ else
+ argin = default
+ end
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_computedigits.bin b/modules/development_tools/macros/assert/assert_computedigits.bin
new file mode 100755
index 000000000..36f7927b2
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_computedigits.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_computedigits.sci b/modules/development_tools/macros/assert/assert_computedigits.sci
new file mode 100755
index 000000000..36c5c6efe
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_computedigits.sci
@@ -0,0 +1,108 @@
+// Copyright (C) 2008-2009 - INRIA - Michael Baudin
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function d = assert_computedigits ( varargin )
+ // Returns the number of significant digits in computed result.
+
+ [lhs,rhs]=argn()
+ if ( and ( rhs <> [2 3] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d to %d expected.\n") , "assert_computedigits" , 2 , 3 )
+ error(errmsg)
+ end
+ computed = varargin ( 1 )
+ expected = varargin ( 2 )
+ basis = argindefault ( rhs , varargin , 3 , 10 )
+ //
+ // Check types of variables
+ if ( typeof(computed) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_computedigits" , 1 )
+ error(errmsg)
+ end
+ if ( typeof(expected) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_computedigits" , 2 )
+ error(errmsg)
+ end
+ //
+ // Check sizes of variables
+ if ( size(expected) <> size(computed) ) then
+ errmsg = sprintf ( gettext ( "%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n") , "assert_computedigits" , 1 , 2 )
+ error(errmsg)
+ end
+ if ( size(basis,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_computedigits" , 3 , 1 , 1 )
+ error(errmsg)
+ end
+ //
+ nre = size(expected,"r")
+ nce = size(expected,"c")
+ // Update shape
+ expected = expected (:)
+ computed = computed (:)
+ //
+ d = zeros(expected)
+ //
+ dre = computedigits_data ( real(expected) , real(computed) , basis );
+ dim = computedigits_data ( imag(expected) , imag(computed) , basis );
+ d = min(dre,dim)
+ //
+ // Reshape
+ d = matrix(d,nre,nce)
+endfunction
+
+function argin = argindefault ( rhs , vararglist , ivar , default )
+ // Returns the value of the input argument #ivar.
+ // If this argument was not provided, or was equal to the
+ // empty matrix, returns the default value.
+ if ( rhs < ivar ) then
+ argin = default
+ else
+ if ( vararglist(ivar) <> [] ) then
+ argin = vararglist(ivar)
+ else
+ argin = default
+ end
+ end
+endfunction
+
+function d = computedigits_data ( expected , computed , basis )
+ //
+ dmin = 0
+ dmax = -log(2^(-53))/log(basis)
+ d = ones(expected)*%inf;
+ d( isnan(expected) & isnan(computed) ) = dmax;
+ d( isnan(expected) & ~isnan(computed) ) = dmin;
+ d( ~isnan(expected) & isnan(computed) ) = dmin;
+ // From now, both expected and computed are non-nan
+ k = ~isnan(expected) & ~isnan(computed);
+ d( k & expected == 0 & computed == 0 ) = dmax;
+ d( k & expected == 0 & computed <> 0 ) = dmin;
+ // From now, expected is non-zero
+ k = k & expected <> 0;
+ d( k & expected == computed ) = dmax;
+ // From now, expected and computed are different
+ k = k & expected <> computed;
+ d( k & expected == %inf & computed <> %inf ) = dmin;
+ d( k & expected == -%inf & computed <> -%inf ) = dmin;
+ // From now, neither of computed, nor expected is infinity
+ kdinf=find(d==%inf);
+ if ( kdinf <> [] ) then
+ relerr = ones(expected)*%nan;
+ relerr(kdinf) = abs(computed(kdinf)-expected(kdinf)) ./ abs(expected(kdinf));
+ k = find( relerr >= 1 );
+ if ( k<> [] ) then
+ d(k) = dmin;
+ end
+ k = find( d==%inf & relerr < 1 );
+ if ( k<> [] ) then
+ sigdig(k) = -log ( 2*relerr(k) ) ./ log(basis);
+ d(k) = max ( sigdig(k) , dmin );
+ end
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_cond2reltol.bin b/modules/development_tools/macros/assert/assert_cond2reltol.bin
new file mode 100755
index 000000000..4bb772cff
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_cond2reltol.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_cond2reltol.sci b/modules/development_tools/macros/assert/assert_cond2reltol.sci
new file mode 100755
index 000000000..4316dff95
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_cond2reltol.sci
@@ -0,0 +1,147 @@
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function rtol = assert_cond2reltol ( varargin )
+ // Suggests a relative error, computed from the condition number.
+
+ function varargout = assert_expandvar ( varargin )
+ // Expand variables so that they all have the same shape.
+ //
+ // Calling Sequence
+ // ovar1 = assert_expandvar ( ivar1 )
+ // [ ovar1 , ovar2 ] = assert_expandvar ( ivar1 , ivar2 )
+ // [ ovar1 , ovar2 , ovar3 ] = assert_expandvar ( ivar1 , ivar2 , ivar3 )
+ // [ ovar1 , ovar2 , ovar3 , ovar4 ] = assert_expandvar ( ivar1 , ivar2 , ivar3 , ivar4 )
+ //
+ // Parameters
+ // ivar1 : input variable #1
+ // ovar1 : output variable #1
+ //
+ // Description
+ // This function allows to expand input arguments of
+ // computationnal functions.
+ // If scalars are input, expand it to the size of other other variables.
+ //
+ // If matrices are input, all must have the same shape: if not, an error is generated.
+ //
+ // Examples
+ // // Expand ovar1 to [1 1 1]
+ // [ ovar1 , ovar2 ] = assert_expandvar ( 1 , [2 3 4] )
+ //
+ // // Expand ovar2 to [4 4 4]
+ // [ ovar1 , ovar2 ] = assert_expandvar ( [1 2 3] , 4 )
+ //
+ // // Expand ovar2 to [4 4 4]'
+ // [ ovar1 , ovar2 ] = assert_expandvar ( [1 2 3]' , 4 )
+ //
+ // Authors
+ // Michael Baudin - 2009-2010 - DIGITEO
+
+ [lhs,rhs]=argn()
+ if ( rhs <> lhs ) then
+ errmsg = sprintf ( gettext ( "%s: The number of output arguments %d do not match the number of input arguments %d.") , "assert_expandvar" , lhs , rhs )
+ error(errmsg)
+ end
+
+ //
+ // Check if there is one argument which is a matrix.
+ // imat is the index of the input argument which is a matrix.
+ istherematrix = %f
+ imat = 0
+ for ivar = 1 : rhs
+ if ( size ( varargin(ivar) , "*" ) <> 1 ) then
+ istherematrix = %t
+ imat = ivar
+ break
+ end
+ end
+ // If there is no matrix, returns the output arguments as is.
+ if ( ~istherematrix ) then
+ for ovar = 1 : lhs
+ varargout ( ovar ) = varargin ( ovar )
+ end
+ return
+ end
+ // If there is one matrix, get its size.
+ nbrows = size ( varargin ( imat ) , "r" )
+ nbcols = size ( varargin ( imat ) , "c" )
+ // Check that all matrices have the same shape.
+ for ivar = 1 : rhs
+ nbi = size ( varargin ( ivar ) , "*" )
+ if ( nbi <> 1 ) then
+ nbrowsi = size ( varargin ( ivar ) , "r" )
+ nbcolsi = size ( varargin ( ivar ) , "c" )
+ if ( nbrowsi <> nbrows | nbcolsi <> nbcols ) then
+ errmsg = msprintf(gettext("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), "assert_expandvar" , ivar , nbrows , nbcols );
+ error(errmsg)
+ end
+ end
+ end
+ // Expand all input arguments which are scalar up to this shape.
+ for ivar = 1 : rhs
+ if ( size ( varargin(ivar) , "*" ) == 1 ) then
+ varargin ( ivar ) = varargin ( ivar ) * ones ( nbrows , nbcols )
+ end
+ end
+ // Set all output variables
+ for ovar = 1 : lhs
+ varargout ( ovar ) = varargin ( ovar )
+ end
+ endfunction
+
+ function argin = argindefault ( rhs , vararglist , ivar , default )
+ // Returns the value of the input argument #ivar.
+ // If this argument was not provided, or was equal to the
+ // empty matrix, returns the default value.
+ if ( rhs < ivar ) then
+ argin = default
+ else
+ if ( vararglist(ivar) <> [] ) then
+ argin = vararglist(ivar)
+ else
+ argin = default
+ end
+ end
+ endfunction
+
+
+ [lhs,rhs]=argn()
+ if ( and ( rhs <> [1 2] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d to %d expected.") , "assert_cond2reltol" , 1 , 2 )
+ error(errmsg)
+ end
+ //
+ // Get arguments
+ condition = varargin ( 1 )
+ offset = argindefault ( rhs , varargin , 2 , 0 )
+ //
+ // Check types of variables
+ if ( typeof(condition) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_cond2reltol" , 1 )
+ error(errmsg)
+ end
+ if ( typeof(offset) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_cond2reltol" , 2 )
+ error(errmsg)
+ end
+ //
+ // Check size of variables
+ // Let the user and assert_expandvar manage this.
+ //
+ // Check content of variables
+ if ( or ( condition < 0 ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Must be > %d.\n") , "assert_cond2reltol" , 1 , 0 )
+ error(errmsg)
+ end
+ //
+ [condition,offset] = assert_expandvar (condition,offset)
+ //
+ d = assert_cond2reqdigits ( condition , offset , 10 )
+ rtol = 10^-d
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_cond2reqdigits.bin b/modules/development_tools/macros/assert/assert_cond2reqdigits.bin
new file mode 100755
index 000000000..ed8684999
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_cond2reqdigits.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_cond2reqdigits.sci b/modules/development_tools/macros/assert/assert_cond2reqdigits.sci
new file mode 100755
index 000000000..e21503203
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_cond2reqdigits.sci
@@ -0,0 +1,167 @@
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function d = assert_cond2reqdigits ( varargin )
+ // Suggests the number of required digits, given the condition number.
+
+
+ function varargout = assert_expandvar ( varargin )
+ // Expand variables so that they all have the same shape.
+ //
+ // Calling Sequence
+ // ovar1 = assert_expandvar ( ivar1 )
+ // [ ovar1 , ovar2 ] = assert_expandvar ( ivar1 , ivar2 )
+ // [ ovar1 , ovar2 , ovar3 ] = assert_expandvar ( ivar1 , ivar2 , ivar3 )
+ // [ ovar1 , ovar2 , ovar3 , ovar4 ] = assert_expandvar ( ivar1 , ivar2 , ivar3 , ivar4 )
+ //
+ // Parameters
+ // ivar1 : input variable #1
+ // ovar1 : output variable #1
+ //
+ // Description
+ // This function allows to expand input arguments of
+ // computationnal functions.
+ // If scalars are input, expand it to the size of other other variables.
+ //
+ // If matrices are input, all must have the same shape: if not, an error is generated.
+ //
+ // Examples
+ // // Expand ovar1 to [1 1 1]
+ // [ ovar1 , ovar2 ] = assert_expandvar ( 1 , [2 3 4] )
+ //
+ // // Expand ovar2 to [4 4 4]
+ // [ ovar1 , ovar2 ] = assert_expandvar ( [1 2 3] , 4 )
+ //
+ // // Expand ovar2 to [4 4 4]'
+ // [ ovar1 , ovar2 ] = assert_expandvar ( [1 2 3]' , 4 )
+ //
+ // Authors
+ // Michael Baudin - 2009-2010 - DIGITEO
+
+ [lhs,rhs]=argn()
+ if ( rhs <> lhs ) then
+ errmsg = sprintf ( gettext ( "%s: The number of output arguments %d do not match the number of input arguments %d.") , "assert_expandvar" , lhs , rhs )
+ error(errmsg)
+ end
+
+ //
+ // Check if there is one argument which is a matrix.
+ // imat is the index of the input argument which is a matrix.
+ istherematrix = %f
+ imat = 0
+ for ivar = 1 : rhs
+ if ( size ( varargin(ivar) , "*" ) <> 1 ) then
+ istherematrix = %t
+ imat = ivar
+ break
+ end
+ end
+ // If there is no matrix, returns the output arguments as is.
+ if ( ~istherematrix ) then
+ for ovar = 1 : lhs
+ varargout ( ovar ) = varargin ( ovar )
+ end
+ return
+ end
+ // If there is one matrix, get its size.
+ nbrows = size ( varargin ( imat ) , "r" )
+ nbcols = size ( varargin ( imat ) , "c" )
+ // Check that all matrices have the same shape.
+ for ivar = 1 : rhs
+ nbi = size ( varargin ( ivar ) , "*" )
+ if ( nbi <> 1 ) then
+ nbrowsi = size ( varargin ( ivar ) , "r" )
+ nbcolsi = size ( varargin ( ivar ) , "c" )
+ if ( nbrowsi <> nbrows ) then
+ errmsg = msprintf(gettext("%s: Expected %d rows in input argument #%d, but found %d rows instead."), "assert_expandvar" , nbrows , ivar , nbrowsi );
+ error(errmsg)
+ end
+ if ( nbcolsi <> nbcols ) then
+ errmsg = msprintf(gettext("%s: Expected %d columns in input argument #%d, but found %d columns instead."), "assert_expandvar" , nbcols , ivar , nbcolsi );
+ error(errmsg)
+ end
+ end
+ end
+ // Expand all input arguments which are scalar up to this shape.
+ for ivar = 1 : rhs
+ if ( size ( varargin(ivar) , "*" ) == 1 ) then
+ varargin ( ivar ) = varargin ( ivar ) * ones ( nbrows , nbcols )
+ end
+ end
+ // Set all output variables
+ for ovar = 1 : lhs
+ varargout ( ovar ) = varargin ( ovar )
+ end
+ endfunction
+
+ function argin = argindefault ( rhs , vararglist , ivar , default )
+ // Returns the value of the input argument #ivar.
+ // If this argument was not provided, or was equal to the
+ // empty matrix, returns the default value.
+ if ( rhs < ivar ) then
+ argin = default
+ else
+ if ( vararglist(ivar) <> [] ) then
+ argin = vararglist(ivar)
+ else
+ argin = default
+ end
+ end
+ endfunction
+
+
+ [lhs,rhs]=argn()
+ if ( and ( rhs <> [1 2 3] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d to %d expected.") , "assert_cond2reqdigits" , 1 , 3 )
+ error(errmsg)
+ end
+ //
+ // Get arguments
+ condition = varargin ( 1 )
+ offset = argindefault ( rhs , varargin , 2 , 0 )
+ b = argindefault ( rhs , varargin , 3 , 10 )
+ //
+ // Check types of variables
+ if ( typeof(condition) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_cond2reqdigits" , 1 )
+ error(errmsg)
+ end
+ if ( typeof(offset) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_cond2reqdigits" , 2 )
+ error(errmsg)
+ end
+ if ( typeof(b) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_cond2reqdigits" , 3 )
+ error(errmsg)
+ end
+ //
+ // Check size of variables
+ // Let the user and assert_expandvar manage this.
+ //
+ // Check content of variables
+ if ( or ( condition < 0 ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Must be > %d.\n") , "assert_cond2reqdigits" , 1 , 0 )
+ error(errmsg)
+ end
+ if ( or ( b < 2 ) ) then
+ errmsg = sprintf ( gettext ("%s: Wrong value for input argument #%d: Must be > %d.\n") , "assert_cond2reqdigits" , 3 , 2 )
+ error(errmsg)
+ end
+ //
+ [condition,offset] = assert_expandvar (condition,offset)
+ //
+ backIEEE=ieee()
+ ieee(2)
+ //
+ dmax = -log(2^(-53))/log(b)
+ lost = min(max(log(condition)/log(b)-offset,0),dmax)
+ d = dmax - lost
+ //
+ ieee(backIEEE)
+endfunction
+
diff --git a/modules/development_tools/macros/assert/assert_generror.bin b/modules/development_tools/macros/assert/assert_generror.bin
new file mode 100755
index 000000000..b63846605
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_generror.bin
Binary files differ
diff --git a/modules/development_tools/macros/assert/assert_generror.sci b/modules/development_tools/macros/assert/assert_generror.sci
new file mode 100755
index 000000000..3bbe19d0c
--- /dev/null
+++ b/modules/development_tools/macros/assert/assert_generror.sci
@@ -0,0 +1,48 @@
+// Copyright (C) 2010 - 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function assert_generror ( varargin )
+ // Generates an error.
+
+ [lhs,rhs]=argn()
+ if ( and(rhs <> [1 2] ) ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong number of input arguments: %d to %d expected.") , "assert_generror" , 1 , 2 )
+ error(errmsg)
+ end
+ errormsg = varargin(1)
+ //
+ // Check types of variables
+ if ( typeof(errormsg) <> "string" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix of strings expected.\n") , "assert_generror" , 1 )
+ error(errmsg)
+ end
+ if ( size(errormsg,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_generror" , 1 , 1 , 1 )
+ error(errmsg)
+ end
+ //
+ if ( rhs == 1 ) then
+ error ( errormsg )
+ else
+ errornb = varargin(2)
+ if ( size(errornb,"*") <> 1 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n") , "assert_generror" , 2 , 1 , 1 )
+ error(errmsg)
+ end
+ if ( typeof(errornb) <> "constant" ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong type for input argument #%d: Matrix expected.\n") , "assert_generror" , 2 )
+ error(errmsg)
+ end
+ if ( errornb < 0 ) then
+ errmsg = sprintf ( gettext ( "%s: Wrong value for input argument #%d: Non-negative integers expected.\n" ) , "assert_generror" , 2 )
+ error(errmsg)
+ end
+ error ( errormsg , errornb )
+ end
+endfunction
+
diff --git a/modules/development_tools/macros/assert/buildmacros.bat b/modules/development_tools/macros/assert/buildmacros.bat
new file mode 100755
index 000000000..be117fb7c
--- /dev/null
+++ b/modules/development_tools/macros/assert/buildmacros.bat
@@ -0,0 +1,11 @@
+
+rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+rem Copyright (C) 2008 - INRIA
+rem
+rem This file must be used under the terms of the CeCILL.
+rem This source file is licensed as described in the file COPYING, which
+rem you should have received as part of this distribution. The terms
+rem are also available at
+rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+@scilex -nwni -e exec('buildmacros.sce');quit;
diff --git a/modules/development_tools/macros/assert/buildmacros.sce b/modules/development_tools/macros/assert/buildmacros.sce
new file mode 100755
index 000000000..c4170b973
--- /dev/null
+++ b/modules/development_tools/macros/assert/buildmacros.sce
@@ -0,0 +1,11 @@
+// Copyright (C) 2010 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+tbx_build_macros("assert", get_absolute_file_path("buildmacros.sce"));
+
+clear tbx_build_macros;
diff --git a/modules/development_tools/macros/assert/cleanmacros.bat b/modules/development_tools/macros/assert/cleanmacros.bat
new file mode 100755
index 000000000..6d53f30d0
--- /dev/null
+++ b/modules/development_tools/macros/assert/cleanmacros.bat
@@ -0,0 +1,14 @@
+
+rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+rem Copyright (C) 2008 - INRIA
+rem
+rem This file must be used under the terms of the CeCILL.
+rem This source file is licensed as described in the file COPYING, which
+rem you should have received as part of this distribution. The terms
+rem are also available at
+rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+@rm *.bin
+@rm lib
+@rm names
+
diff --git a/modules/development_tools/macros/assert/cleanmacros.sce b/modules/development_tools/macros/assert/cleanmacros.sce
new file mode 100755
index 000000000..a6c629ca9
--- /dev/null
+++ b/modules/development_tools/macros/assert/cleanmacros.sce
@@ -0,0 +1,16 @@
+// ====================================================================
+// Allan CORNET
+// DIGITEO 2009
+// This file is released into the public domain
+// ====================================================================
+libpath = get_absolute_file_path("cleanmacros.sce");
+
+binfiles = ls(libpath+"/*.bin");
+for i = 1:size(binfiles,"*")
+ mdelete(binfiles(i));
+end
+
+mdelete(libpath+"/names");
+mdelete(libpath+"/lib");
+
+// ====================================================================
diff --git a/modules/development_tools/macros/assert/lib b/modules/development_tools/macros/assert/lib
new file mode 100755
index 000000000..4fe2adf34
--- /dev/null
+++ b/modules/development_tools/macros/assert/lib
Binary files differ
diff --git a/modules/development_tools/macros/assert/names b/modules/development_tools/macros/assert/names
new file mode 100755
index 000000000..614b8ba0c
--- /dev/null
+++ b/modules/development_tools/macros/assert/names
@@ -0,0 +1,11 @@
+assert_checkalmostequal
+assert_checkequal
+assert_checkerror
+assert_checkfalse
+assert_checkfilesequal
+assert_checktrue
+assert_comparecomplex
+assert_computedigits
+assert_cond2reltol
+assert_cond2reqdigits
+assert_generror
diff --git a/modules/development_tools/macros/bench_run.bin b/modules/development_tools/macros/bench_run.bin
new file mode 100755
index 000000000..724275b25
--- /dev/null
+++ b/modules/development_tools/macros/bench_run.bin
Binary files differ
diff --git a/modules/development_tools/macros/bench_run.sci b/modules/development_tools/macros/bench_run.sci
new file mode 100755
index 000000000..22787a532
--- /dev/null
+++ b/modules/development_tools/macros/bench_run.sci
@@ -0,0 +1,372 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
+// Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+//-----------------------------------------------------------------------------
+// Launch benchmarks
+//-----------------------------------------------------------------------------
+
+function bench_run(varargin)
+
+ lhs = argn(1);
+ rhs = argn(2);
+
+ global test_list;
+ global test_count;
+ global boucle_for_time;
+
+ test_list = [];
+ test_count = 0;
+ boucle_for_time = 0;
+
+ just_list_tests = %F;
+ print_help = %F;
+ nb_run = "10000";
+
+ xml_str = "";
+
+ // =======================================================
+ // Gestion des tests à lancer
+ // =======================================================
+
+ if (rhs == 0) ..
+ | ((rhs == 1) & (varargin(1)==[])) ..
+ | (((rhs == 2)|(rhs == 3)) & (varargin(1)==[]) & (varargin(2)==[])) then
+
+ // No input argument
+ // bench_run()
+ // bench_run([])
+ // => Launch each test of each module
+
+ module_list = getmodules();
+ module_list = gsort(module_list,"lr","i");
+ for k=1:size(module_list,"*")
+ bench_add_module(module_list(k));
+ end
+
+ elseif (rhs == 1) ..
+ | ((rhs == 2) & (varargin(2)==[])) ..
+ | ((rhs == 3) & (varargin(2)==[])) then
+
+ // One input argument
+ // bench_run(<module_name>)
+ // bench_run([<module_name_1>,<module_name_2>])
+
+ // varargin(1) = [<module_name_1>,<module_name_2>]
+
+ module_mat = varargin(1);
+
+ [nl,nc] = size(module_mat);
+
+ // bench_run([<module_name_1>,<module_name_2>])
+
+ for i=1:nl
+ for j=1:nc
+ if( with_module(module_mat(i,j)) ) then
+ bench_add_module(module_mat(i,j));
+ else
+ error(sprintf(gettext("%s is not an installed module"),module_mat(i,j)));
+ end
+ end
+ end
+
+ elseif (rhs == 2) | (rhs == 3) then
+
+ // Two input arguments
+ // bench_run(<module_name>,<test_name>)
+ // bench_run(<module_name>,[<test_name_1>,<test_name_2>] )
+
+ // varargin(1) = <module_name> ==> string 1x1
+ // varargin(2) = <test_name_1> ==> mat nl x nc
+
+ module = varargin(1);
+ test_mat = varargin(2);
+
+ if ((or(size(module) <> [1,1])) & (test_mat <> [])) then
+ example = bench_examples();
+ err = ["" ; gettext("error : Input argument sizes are not valid") ; "" ; example ];
+ printf("%s\n",err);
+ return;
+ end
+
+ [nl,nc] = size(test_mat);
+
+ for i=1:nl
+ for j=1:nc
+
+ if (fileinfo(SCI+"/modules/"+module+"/tests/benchmarks/"+test_mat(i,j)+".tst")<>[]) then
+ bench_add_onebench(module,test_mat(i,j));
+ else
+ error(sprintf(gettext("The test ""%s"" is not available from the ""%s"" module"),test_mat(i,j),module));
+ end
+
+ end
+ end
+ else
+ error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "bench_run", 0, 3));
+ end
+
+ // =======================================================
+ // Gestion des options
+ // =======================================================
+
+ if rhs == 3 then
+
+ option_mat = varargin(3);
+
+ if grep(option_mat,"list") <> [] then
+ just_list_tests = %T;
+ end
+
+ if grep(option_mat,"help") <> [] then
+ print_help = %T;
+ end
+
+ if grep(option_mat,"nb_run=") <> [] then
+ nb_run_line = grep(option_mat,"nb_run=");
+ nb_run = strsubst(option_mat(nb_run_line),"nb_run=","");
+ end
+
+ end
+
+ if print_help then
+
+ // =======================================================
+ // Display help
+ // =======================================================
+
+ example = bench_examples();
+ printf("%s\n",example);
+ return;
+
+ elseif just_list_tests then
+
+ // =======================================================
+ // Just list tests
+ // =======================================================
+
+ printf("\n");
+
+ for i=1:test_count
+ printf(" %03d - ",i);
+ printf("[%s] %s\n",test_list(i,1),test_list(i,2));
+ end
+
+ else
+
+ // =======================================================
+ // Test launch
+ // =======================================================
+
+ printf("\n");
+
+ xml_str = [ xml_str ; "<benchmarks>" ];
+
+ // Calcul de la durée de la boucle for en µs
+
+ tic();
+ for i = 1:1000000
+ end
+ timing = toc();
+ boucle_for_time = timing * 1000;
+
+ printf(" For Loop (as reference) ........................... %4.2f ms [ 1000000 x]\n\n",boucle_for_time);
+
+ for i=1:test_count
+
+ // Display
+ printf(" %03d/%03d - ",i,test_count);
+ printf("[%s] %s ",test_list(i,1),test_list(i,2));
+ for j = length(test_list(i,2) + test_list(i,1)):45
+ printf(".");
+ end
+ printf(" ");
+
+ // Bench process
+ [returned_time,nb_run_done] = bench_run_onebench(test_list(i,1),test_list(i,2),nb_run);
+
+ // Display
+ returned_time_str = sprintf("%4.2f ms",returned_time);
+ for j = length(returned_time_str):13
+ printf(" ");
+ end
+ printf("%s [",returned_time_str);
+ for j = length(nb_run_done):7
+ printf(" ");
+ end
+ printf("%s x]\n",nb_run_done);
+
+ // XML print
+ xml_str = [ xml_str ; ..
+ " <bench>"; ..
+ " <module>"+test_list(i,1)+"</module>"; ..
+ " <id>"+test_list(i,2)+"</id>"; ..
+ " <duration>"+strsubst(returned_time_str," ms","")+"</duration>"; ..
+ " <nb_run>"+nb_run_done+"</nb_run>"; ..
+ " </bench>" ];
+
+ end
+
+ end
+
+ // XML management
+ xml_str = [ xml_str ; "</benchmarks>" ];
+ xml_file_name = SCI+"/bench_"+getversion()+"_"+date()+".xml";
+ ierr = execstr("fd_xml = mopen(xml_file_name,''wt'');","errcatch");
+ if ierr == 999 then
+ xml_file_name = SCIHOME + "/bench_" + getversion() + "_" + date() +".xml";
+ ierr = execstr("fd_xml = mopen(xml_file_name,''wt'');","errcatch");
+ end
+
+ if ierr == 0 then
+ mputl(xml_str, fd_xml);
+ mclose(fd_xml);
+ end
+
+ clearglobal test_list;
+ clearglobal test_count;
+ clearglobal boucle_for_time;
+
+endfunction
+
+//-----------------------------------------------------------------------------
+// Pierre MARECHAL
+// Scilab team
+// Date : 28 oct. 2007
+//
+// => List all test files in the module <module_mat>
+// => Add them to the test_mat matrix
+//-----------------------------------------------------------------------------
+
+function bench_add_module(module_mat,test_type)
+
+ module_test_dir = SCI+"/modules/"+module_mat+"/tests/benchmarks";
+ test_mat = gsort(basename(listfiles(module_test_dir+"/*.tst")),"lr","i");
+
+ nl = size(test_mat,"*");
+ for i=1:nl
+ bench_add_onebench(module_mat,test_mat(i));
+ end
+
+endfunction
+
+//-----------------------------------------------------------------------------
+// Pierre MARECHAL
+// Scilab team
+// Date : 28 oct. 2007
+//
+// => Add the test <test> to the test_mat matrix
+//-----------------------------------------------------------------------------
+
+function bench_add_onebench(module,test)
+
+ global test_list;
+ global test_count;
+
+ test_count = test_count + 1;
+
+ test_list( test_count , 1 ) = module;
+ test_list( test_count , 2 ) = test;
+
+endfunction
+
+//-----------------------------------------------------------------------------
+// Pierre MARECHAL
+// Scilab team
+// Date : 28 oct. 2007
+//
+// => Run one test
+//-----------------------------------------------------------------------------
+
+function [returned_time,nb_run_done] = bench_run_onebench(module,test,nb_run)
+
+ returned_time = 0;
+
+ fullPath = SCI+"/modules/"+module+"/tests/benchmarks/"+test;
+
+ tstfile = pathconvert(fullPath+".tst",%f,%f);
+ scefile = pathconvert(TMPDIR+"/"+test+".sce",%f,%f);
+
+ // Get the tst file
+ txt = mgetl(tstfile);
+
+ // Check if the nb run is defined in the test
+
+ check_nb_run_line = grep(txt,"<-- BENCH NB RUN :");
+
+ nb_run_done = nb_run;
+
+ if check_nb_run_line <> [] then
+ nb_run_line = txt(check_nb_run_line);
+ nb_run_start = strindex(nb_run_line,"<-- BENCH NB RUN :") + length("<-- BENCH NB RUN :");
+ nb_run_end = strindex(nb_run_line,"-->") - 1;
+ nb_run = stripblanks(part(nb_run_line,[nb_run_start:nb_run_end]));
+ nb_run_done = nb_run;
+ end
+
+ // get the <-- BENCH START --> and <-- BENCH END --> tags
+ line_start = grep(txt,"<-- BENCH START -->");
+ line_end = grep(txt,"<-- BENCH END -->");
+
+ // Get the context and the bench
+ context = txt([1:line_start-1]);
+ bench = txt([line_start+1:line_end-1]);
+
+ // Remove blank lines
+ context(find(context == "" )) = [];
+ bench (find(bench == "" )) = [];
+
+ tst_str = [ context ;
+ "nb_run = "+nb_run+";";
+ "tic();";
+ "for i = 1:nb_run";
+ bench;
+ "end";
+ "timing = toc();";
+ "returned_time = timing * 1000;"]
+
+ mputl(tst_str,scefile);
+ exec(scefile);
+ returned_time = returned_time - (boucle_for_time * nb_run / 1d6)
+ return;
+
+endfunction
+
+//-----------------------------------------------------------------------------
+// Pierre MARECHAL
+// Scilab team
+// Date : 28 oct. 2007
+//
+// => Check ref or generate ref
+//-----------------------------------------------------------------------------
+
+function example = bench_examples()
+
+ example = [ sprintf("Examples :\n\n") ];
+
+ example = [ example ; sprintf("// Launch all tests\n") ];
+ example = [ example ; sprintf("bench_run();\n") ];
+ example = [ example ; sprintf("bench_run([]);\n") ];
+ example = [ example ; sprintf("bench_run([],[]);\n") ];
+ example = [ example ; "" ];
+ example = [ example ; sprintf("// Test one or several module\n") ];
+ example = [ example ; sprintf("bench_run(''core'');\n") ];
+ example = [ example ; sprintf("bench_run(''core'',[]);\n") ];
+ example = [ example ; sprintf("bench_run([''core'',''string'']);\n") ];
+ example = [ example ; "" ];
+ example = [ example ; sprintf("// Launch one or several test in a specified module\n") ];
+ example = [ example ; sprintf("bench_run(''core'',[''trycatch'',''opcode'']);\n") ];
+ example = [ example ; "" ];
+ example = [ example ; sprintf("// With options\n") ];
+ example = [ example ; sprintf("bench_run([],[],''list'');\n") ];
+ example = [ example ; sprintf("bench_run([],[],''help'');\n") ];
+ example = [ example ; sprintf("bench_run([],[],''nb_run=2000'');\n") ];
+ example = [ example ; "" ];
+
+endfunction
diff --git a/modules/development_tools/macros/buildmacros.bat b/modules/development_tools/macros/buildmacros.bat
new file mode 100755
index 000000000..a73ca67f8
--- /dev/null
+++ b/modules/development_tools/macros/buildmacros.bat
@@ -0,0 +1,11 @@
+
+rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+rem Copyright (C) 2008 - INRIA
+rem
+rem This file must be used under the terms of the CeCILL.
+rem This source file is licensed as described in the file COPYING, which
+rem you should have received as part of this distribution. The terms
+rem are also available at
+rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit;
diff --git a/modules/development_tools/macros/buildmacros.sce b/modules/development_tools/macros/buildmacros.sce
new file mode 100755
index 000000000..79a0ca847
--- /dev/null
+++ b/modules/development_tools/macros/buildmacros.sce
@@ -0,0 +1,18 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2006-2008 - INRIA - Allan CORNET <allan.cornet@inria.fr>
+// Copyright (C) 2011 - DIGITEO - Michael Baudin
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+if (isdef("genlib") == %f) then
+ exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce");
+end
+
+genlib("development_toolslib","SCI/modules/development_tools/macros",%f,%t);
+genlib("assertlib","SCI/modules/development_tools/macros/assert",%f,%t);
+
diff --git a/modules/development_tools/macros/cleanmacros.bat b/modules/development_tools/macros/cleanmacros.bat
new file mode 100755
index 000000000..4ad1bbae2
--- /dev/null
+++ b/modules/development_tools/macros/cleanmacros.bat
@@ -0,0 +1,13 @@
+
+rem Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+rem Copyright (C) 2008 - INRIA
+rem
+rem This file must be used under the terms of the CeCILL.
+rem This source file is licensed as described in the file COPYING, which
+rem you should have received as part of this distribution. The terms
+rem are also available at
+rem http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+@del *.bin 2>NUL
+@del lib 2>NUL
+@del names 2>NUL
diff --git a/modules/development_tools/macros/devtools_run_builder.bin b/modules/development_tools/macros/devtools_run_builder.bin
new file mode 100755
index 000000000..e6bd6c07d
--- /dev/null
+++ b/modules/development_tools/macros/devtools_run_builder.bin
Binary files differ
diff --git a/modules/development_tools/macros/devtools_run_builder.sci b/modules/development_tools/macros/devtools_run_builder.sci
new file mode 100755
index 000000000..7c9223015
--- /dev/null
+++ b/modules/development_tools/macros/devtools_run_builder.sci
@@ -0,0 +1,23 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Simon LIPP <simon.lipp@scilab.org>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Run the path/subdir/builder script, changing its working directory
+// to path/subdir
+function devtools_run_builder(path, subdir, builder)
+ oldpath = pwd();
+
+ chdir(path);
+
+ if(isdir(subdir)) then
+ chdir(subdir);
+ exec(builder, -1);
+ end
+
+ chdir(oldpath);
+endfunction
diff --git a/modules/development_tools/macros/example_run.bin b/modules/development_tools/macros/example_run.bin
new file mode 100755
index 000000000..197d13008
--- /dev/null
+++ b/modules/development_tools/macros/example_run.bin
Binary files differ
diff --git a/modules/development_tools/macros/example_run.sci b/modules/development_tools/macros/example_run.sci
new file mode 100755
index 000000000..910a5b455
--- /dev/null
+++ b/modules/development_tools/macros/example_run.sci
@@ -0,0 +1,169 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Michael Baudin
+// Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function boolStatus = example_run(modulesName, functionsName, helpLanguage, varargin)
+
+ rhs = argn(2);
+
+ if rhs < 1 then
+ modulesName = getmodules();
+ end
+ if rhs < 2 then
+ functionsName = [];
+ end
+ if rhs < 3 then
+ helpLanguage = "en_US";
+ end
+
+ if typeof(modulesName)<>"string" then
+ error(msprintf(gettext("%s: Wrong type for input argument #%d: A row array of strings expected.\n"), "example_run", 1));
+ end
+ if size(modulesName, 2)<>1 then
+ error(msprintf(gettext("%s: Wrong size for input argument #%d: A row array of strings expected.\n"), "example_run", 1));
+ end
+
+ if (typeof(functionsName)=="constant" & ~isempty(functionsName)) & typeof(functionsName)<>"string" then
+ error(msprintf(gettext("%s: Wrong type for input argument #%d: A row array of strings or empty matrix expected.\n"), "example_run", 2));
+ end
+ if ~isempty(functionsName) & size(functionsName, 2)<>1 then
+ error(msprintf(gettext("%s: Wrong size for input argument #%d: A row array of strings or empty matrix expected.\n"), "example_run", 2));
+ end
+
+ if typeof(helpLanguage)<>"string" then
+ error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "example_run", 3));
+ end
+ if size(helpLanguage, "*")<>1 then
+ error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "example_run", 3));
+ end
+
+ for kMod = 1:size(modulesName, "*")
+
+ moduleName = modulesName(kMod);
+
+ if (isdir(moduleName)) then
+ moduleDir = fullfile(moduleName,"help");
+ else
+ moduleDir = fullfile(SCI,"modules",moduleName,"help");
+ if ~isdir(moduleDir) then
+ error(msprintf(gettext("%s: Wrong value for input argument #%d: A Scilab module name expected.\n"), "example_run", 1));
+ return
+ end
+ end
+
+ moduleDir = fullfile(moduleDir,helpLanguage);
+ if ~isdir(moduleDir) then
+ error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid language expected.\n"), "example_run", 3));
+ return
+ end
+
+ tempModuleName = basename(moduleName) + "_help";
+
+ workDir = fullfile(TMPDIR,tempModuleName,"tests","unit_tests");
+ if isdir(workDir) then
+ rmdir(workDir, "s");
+ end
+
+ if isempty(functionsName) then
+ xmlFiles = findHelpFiles(moduleDir, []);
+
+ for kFile = 1:size(xmlFiles, "*")
+ xmlFile = xmlFiles(kFile);
+ createTestsFromHelp(moduleDir, workDir, xmlFile)
+ end
+ else
+ for kFunction = 1:size(functionsName, "*")
+ xmlFiles = findHelpFiles(moduleDir, functionsName(kFunction));
+ if isempty(xmlFiles) then // The user wants to test a specific file
+ error(msprintf(gettext("%s: Wrong value for input argument #%d: A ''%s'' module function name expected.\n"), "example_run", 2, moduleName));
+ return
+ end
+
+ for kFile = 1:size(xmlFiles, "*")
+ xmlFile = xmlFiles(kFile);
+ createTestsFromHelp(moduleDir, workDir, xmlFile)
+ end
+ end
+ end
+
+ testDir=fullfile(TMPDIR,tempModuleName)
+ if rhs > 3 then
+ boolStatus = test_run(testDir, [], varargin(:))
+ else
+ boolStatus = test_run(testDir, [])
+ end
+ end
+
+endfunction
+
+function createTestsFromHelp(baseDirectory, outputDirectory, helpFile)
+
+ mkdir(outputDirectory);
+
+ helpFileDoc = xmlRead(helpFile);
+
+ // Find all programlisting tag in the file
+ exampleTags = xmlXPath(helpFileDoc, "//scilabhelpfile:programlisting", ["scilabhelpfile" "http://docbook.org/ns/docbook"]);
+
+ for kExample = 1:size(exampleTags, "*")
+
+ programListing = [];
+
+ if exampleTags(kExample).attributes.role == "interactive-example" then
+ programListing = ["// <-- INTERACTIVE TEST -->" ; programListing];
+ end
+
+ ignoredRoles = ["no-scilab-exec"];
+ ignoreExample = or(exampleTags(kExample).attributes.role==ignoredRoles) | isempty(exampleTags(kExample).attributes.role);
+
+ programListing = ["// <-- NO CHECK REF -->" ; programListing; exampleTags(kExample).content];
+
+ if ~ignoreExample then
+ functionName = fileparts(helpFile, "fname");
+ relPath = dirname(getrelativefilename(baseDirectory, helpFile));
+
+ mkdir(fullfile(outputDirectory,relPath))
+
+ if size(exampleTags, "*")>1 then
+ filebase=functionName + "_" + string(kExample) + ".tst"
+ destfile=fullfile(outputDirectory,relPath,filebase);
+ mputl(programListing,destfile);
+ else
+ filebase=functionName + ".tst"
+ destfile=fullfile(outputDirectory,relPath,filebase)
+ mputl(programListing,destfile);
+ end
+ end
+ end
+
+endfunction
+
+function xmlFilenames = findHelpFiles(directory, functionName)
+
+ xmlFilenames = [];
+
+ allFiles = ls(directory);
+
+ for kFile = 1:size(allFiles, "*")
+ if isfile(allFiles(kFile)) then
+ if fileparts(allFiles(kFile), "extension")==".xml" then
+ if isempty(functionName) then
+ xmlFilenames($+1) = allFiles(kFile);
+ elseif fileparts(allFiles(kFile), "fname")==functionName then
+ xmlFilenames($+1) = allFiles(kFile);
+ end
+ end
+ else // Directory
+ subDir=fullfile(directory,allFiles(kFile))
+ subxmlfiles=findHelpFiles(subDir, functionName)
+ xmlFilenames = [xmlFilenames;subxmlfiles]
+ end
+ end
+
+endfunction
diff --git a/modules/development_tools/macros/launchtest.bin b/modules/development_tools/macros/launchtest.bin
new file mode 100755
index 000000000..42e16d2c2
--- /dev/null
+++ b/modules/development_tools/macros/launchtest.bin
Binary files differ
diff --git a/modules/development_tools/macros/launchtest.sci b/modules/development_tools/macros/launchtest.sci
new file mode 100755
index 000000000..2d9763099
--- /dev/null
+++ b/modules/development_tools/macros/launchtest.sci
@@ -0,0 +1,42 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2006-2008 - INRIA - Sylvestre LEDRU <sylvestre.ledru@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Purpose : this file provides functions to test scilab for each modules
+// Under Linux/Unix it is called by the command "make check"
+// Which will call the target check-local in the file Makefile.incl.am
+
+function launchtest(myPath,myTests)
+ chdir(myPath)
+ maketests(myTests,"clean")
+ maketests(myTests,"test")
+endfunction
+
+function maketests(myTests,job)
+ lines(0) // to disable line control
+ if argn(2)<1 then job="tests",end
+ if job=="clean" then //remove .dia files
+ cleantests(myTests)
+ else
+ for k1=1:size(myTests,"*") // loop on .tst files
+ scitest(myTests(k1))
+ end
+ end
+endfunction
+
+function cleantests(myTests)
+ if getos() == "Windows" then
+ path=SCI+"\tests\basic_tests"
+ file_to_clean=path+strsubst(myTests,".tst",".dia")
+ unix_s("del "+""""+strcat(file_to_clean,""" """)+"""")
+ else
+ path="./"
+ file_to_clean=path+strsubst(myTests,".tst",".dia")
+ unix_s("rm -f "+strcat(file_to_clean," "))
+ end
+endfunction
diff --git a/modules/development_tools/macros/lib b/modules/development_tools/macros/lib
new file mode 100755
index 000000000..1e7a22c7c
--- /dev/null
+++ b/modules/development_tools/macros/lib
Binary files differ
diff --git a/modules/development_tools/macros/names b/modules/development_tools/macros/names
new file mode 100755
index 000000000..dac806a04
--- /dev/null
+++ b/modules/development_tools/macros/names
@@ -0,0 +1,11 @@
+bench_run
+devtools_run_builder
+example_run
+launchtest
+nonreg_test_run
+scitest
+test_clean
+test_run
+test_run_level
+testexamples
+unit_test_run
diff --git a/modules/development_tools/macros/nonreg_test_run.bin b/modules/development_tools/macros/nonreg_test_run.bin
new file mode 100755
index 000000000..9a8fdf1ba
--- /dev/null
+++ b/modules/development_tools/macros/nonreg_test_run.bin
Binary files differ
diff --git a/modules/development_tools/macros/nonreg_test_run.sci b/modules/development_tools/macros/nonreg_test_run.sci
new file mode 100755
index 000000000..42b4618e7
--- /dev/null
+++ b/modules/development_tools/macros/nonreg_test_run.sci
@@ -0,0 +1,39 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// =============================================================================
+// Launch Non-Regression tests
+// =============================================================================
+
+function nonreg_test_run(varargin)
+
+ lhs = argn(1);
+ rhs = argn(2);
+
+ if (rhs == 0) then
+ test_run([],[],["nonreg_tests"]);
+
+ elseif rhs == 1 then
+ argument_1 = varargin(1);
+ test_run(argument_1,[],["nonreg_tests"]);
+
+ elseif rhs == 2 then
+ argument_1 = varargin(1);
+ argument_2 = varargin(2);
+ test_run(argument_1,argument_2,["nonreg_tests"]);
+
+ elseif rhs == 3 then
+ argument_1 = varargin(1);
+ argument_2 = varargin(2);
+ argument_3 = varargin(3);
+ test_run(argument_1,argument_2,[argument_3,"nonreg_tests"]);
+
+ end
+
+endfunction
diff --git a/modules/development_tools/macros/scitest.bin b/modules/development_tools/macros/scitest.bin
new file mode 100755
index 000000000..511971d63
--- /dev/null
+++ b/modules/development_tools/macros/scitest.bin
Binary files differ
diff --git a/modules/development_tools/macros/scitest.sci b/modules/development_tools/macros/scitest.sci
new file mode 100755
index 000000000..d175ff6f0
--- /dev/null
+++ b/modules/development_tools/macros/scitest.sci
@@ -0,0 +1,173 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function scitest(tstfile,force,error_check,keep_prompt,postscript_graphics)
+
+ // if error_check is %t then execution errors are reported
+ // if error_check is %f then only test checked error are detected
+ // (see examples in tests directory)
+ // if keep_prompt is %t the prompt is kept in the dia file
+ // this can be useful for producing demos
+
+ [lhs,rhs]=argn(0);
+
+ if exists("force","local") ==0 then force = %f ; end
+ if exists("error_check","local") ==0 then error_check = %f ; end
+ if exists("keep_prompt","local") ==0 then keep_prompt = %f ; end
+ if exists("postscript_graphics","local")==0 then postscript_graphics = %f ; end
+
+ ind = strindex(tstfile,".");
+
+ if ind==[] then
+ diafile = tstfile+".tst";
+ else
+ suf = part(tstfile,ind($):length(tstfile));
+ if suf == ".dia" then
+ error(msprintf(gettext("%s: Wrong first input argument: File with .dia suffix expected."),"scitest"));
+ return
+ end
+ diafile=strsubst(tstfile,suf,".dia");
+ end
+
+ if newest(tstfile,diafile)==2 & force == %f then return,end
+
+ mydisp("------------------- File "+tstfile+" --------------------");
+
+ //Reset standard globals
+ rand("seed",0);rand("uniform");
+
+ if getos() == "Windows" then
+ tmpfiles=strsubst(TMPDIR,"/","\")+"\tmp.";
+ else
+ tmpfiles=TMPDIR+"/tmp.";
+ end
+
+ // Do some modification in tst file
+ // ---------------------------------
+ txt = mgetl(tstfile);
+ txt = strsubst(txt,"pause,end","bugmes();quit;end");
+ txt = strsubst(txt,"-->","@#>");
+ //to avoid suppression of input --> with prompts
+ txt=strsubst(txt,"halt()","");
+
+ if postscript_graphics then
+ pg1="driver(''Pos'');xinit(''"+tmpfiles+"gr"+"'');";
+ pg2="xend();";
+ else
+ pg1="";
+ pg2="";
+ end
+
+ head="mode(3);clear;lines(28,72);lines(0);"..
+ +"deff(''[]=bugmes()'',''write(%io(2),''''error on test'''')'');"..
+ +"predef(''all'');"..
+ +"tmpdirToPrint = msprintf(''TMPDIR1=''''%s''''\n'',TMPDIR);"..
+ +"diary(''"+tmpfiles+"dia"+"'');"..
+ +"write(%io(2),tmpdirToPrint);"..
+ +pg1;
+
+ tail = "diary(0);"+pg2+"exit;";
+
+ txt = [head;
+ txt;
+ tail];
+
+ // and save it in a temporary file
+ mputl(txt,tmpfiles+"tst");
+
+ myexec()
+
+ // Do some modification in dia file
+ // ----------------------------------
+ dia=mgetl(tmpfiles+"dia")
+ dia(grep(dia,"exec("))=[];
+ TMP=dia(1);
+ dia(1)=[];
+ dia(grep(dia,"diary(0)"))=[];
+
+ execstr(TMP)
+
+ dia = strsubst(dia,TMPDIR,"TMPDIR");
+ dia = strsubst(dia,TMPDIR1,"TMPDIR");
+ dia = strsubst(dia,TMPDIR1,"TMPDIR");
+ dia = strsubst(dia,SCI,"SCI");
+
+ //suppress the prompts
+ if keep_prompt == %f then
+ dia=strsubst(dia,"-->","");
+ end
+
+ dia = strsubst(dia,"@#>","-->");
+ dia = strsubst(dia,"-1->","");
+
+ //standardise number display
+ dia=strsubst(strsubst(strsubst(strsubst(dia," .","0."),..
+ "E+","D+"),"E-","D-"),"-.","-0.");
+
+ //not to change the ref files
+ dia=strsubst(dia,"bugmes();return","bugmes();quit");
+
+ // write down the resulting dia file
+ mputl(dia,diafile)
+
+ //Check for execution errors
+ // -------------------------
+
+ if error_check == %t then
+ if grep(dia,"!--error")<>[] then
+ mydisp(msprintf(gettext("Test failed ERROR DETECTED while executing %s"),tstfile));
+ return;
+ end
+ end
+
+ if grep(dia,"error on test")<>[] then
+ mydisp(msprintf(gettext("Test failed ERROR DETECTED while executing %s"),tstfile));
+ return;
+ end
+
+ //Check for diff with the .ref file
+ // --------------------------------
+ [u,ierr]=mopen(diafile+".ref","r")
+ if ierr== 0 then //ref file exists
+ ref=mgetl(u);mclose(u)
+ // suppress blank (diff -nw)
+ dia=strsubst(dia," ","")
+ ref=strsubst(ref," ","")
+
+ if or(ref<>dia) then
+ if getos() == "Windows" then
+ mydisp(msprintf(gettext("Test Failed. See : fc /L /N %s"),diafile+" "+diafile+".ref "));
+ else
+ mydisp(msprintf(gettext("Test Failed. See : diff -wu %s"),diafile+" "+diafile+".ref "));
+ end
+ else
+ mydisp(gettext("Test passed"));
+ end
+ end
+ mydisp("----------------------------------------------------------");
+
+endfunction
+
+function mydisp(str)
+ write(%io(2),str,"(a)")
+endfunction
+
+function myexec()
+ if getos() == "Windows" then
+ if fileinfo(tmpfiles+"dia")<>[] then
+ deletefile(tmpfiles+"dia")
+ end
+ dos(""""+SCI+"\bin\scilex.exe"+""""+" -nwni -args -nouserstartup -f "+tmpfiles+"tst 1>NUL");
+ else
+ if fileinfo(tmpfiles+"dia")<>[] then
+ deletefile(tmpfiles+"dia")
+ end
+ unix_s("( "+SCI+"/bin/scilab -nw -args -nouserstartup -f "+tmpfiles+"tst > "+tmpfiles+"res ) 2> "+tmpfiles+"err")
+ end
+endfunction
diff --git a/modules/development_tools/macros/test_clean.bin b/modules/development_tools/macros/test_clean.bin
new file mode 100755
index 000000000..b805d5a7c
--- /dev/null
+++ b/modules/development_tools/macros/test_clean.bin
Binary files differ
diff --git a/modules/development_tools/macros/test_clean.sci b/modules/development_tools/macros/test_clean.sci
new file mode 100755
index 000000000..f57fe4344
--- /dev/null
+++ b/modules/development_tools/macros/test_clean.sci
@@ -0,0 +1,223 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// =============================================================================
+// Clean tests
+// =============================================================================
+
+function test_clean(varargin)
+
+ lhs = argn(1);
+ rhs = argn(2);
+
+ global test_list;
+ global test_count;
+ global displayed_txt;
+
+ // test type
+ test_types = ["unit_tests","nonreg_tests"];
+ test_types_keeped = "";
+
+ test_count = 0;
+
+ displayed_txt = "";
+
+ // =======================================================
+ // Gestion des types de tests à lancer
+ // =======================================================
+
+ if rhs < 3 then
+ test_types_keeped = "all_tests";
+ else
+ option_mat = varargin(3);
+
+ if ((grep(option_mat,"unit_tests")<>[]) & (grep(option_mat,"nonreg_tests")<>[])) ..
+ | (grep(option_mat,"all_tests")<>[]) then
+ test_types_keeped = "all_tests";
+
+ elseif grep(option_mat,"unit_tests") <> [] then
+ test_types_keeped = "unit_tests";
+
+ elseif grep(option_mat,"nonreg_tests") <> [] then
+ test_types_keeped = "nonreg_tests";
+
+ else
+ test_types_keeped = "all_tests";
+
+ end
+
+ end
+
+ // =======================================================
+ // Gestion des tests à lancer
+ // =======================================================
+
+ if (rhs == 0) ..
+ | ((rhs == 1) & (varargin(1)==[])) ..
+ | (((rhs == 2)|(rhs == 3)) & (varargin(1)==[]) & (varargin(2)==[])) then
+
+ // No input argument
+ // test_clean()
+ // test_clean([])
+ // => Launch each test of each module
+
+ module_list = getmodules();
+ module_list = gsort(module_list,"lr","i");
+ for k=1:size(module_list,"*")
+ test_clean_module(module_list(k),test_types_keeped);
+ end
+
+ elseif (rhs == 1) ..
+ | ((rhs == 2) & (varargin(2)==[])) ..
+ | ((rhs == 3) & (varargin(2)==[])) then
+
+ // One input argument
+ // test_clean(<module_name>)
+ // test_clean([<module_name_1>,<module_name_2>])
+
+ // varargin(1) = [<module_name_1>,<module_name_2>]
+
+ module_mat = varargin(1);
+
+ [nl,nc] = size(module_mat);
+
+ // test_clean([<module_name_1>,<module_name_2>])
+
+ for i=1:nl
+ for j=1:nc
+ if( with_module(module_mat(i,j)) ) then
+ test_clean_module(module_mat(i,j),test_types_keeped);
+ else
+ error(sprintf(gettext("%s is not an installed module"),module_mat(i,j)));
+ end
+ end
+ end
+
+ elseif (rhs == 2) | (rhs == 3) then
+
+ // Two input arguments
+ // test_clean(<module_name>,<test_name>)
+ // test_clean(<module_name>,[<test_name_1>,<test_name_2>] )
+
+ // varargin(1) = <module_name> ==> string 1x1
+ // varargin(2) = <test_name_1> ==> mat nl x nc
+
+ module = varargin(1);
+ test_mat = varargin(2);
+
+ if ((or(size(module) <> [1,1])) & (test_mat <> [])) then
+ example = test_examples();
+ err = ["" ; msprintf(gettext("%s: Wrong size for input argument."),"test_clean") ; "" ; example ];
+ printf("%s\n",err);
+ return;
+ end
+
+ [nl,nc] = size(test_mat);
+
+ for i=1:nl
+ for j=1:nc
+
+ if (fileinfo(SCI+"/modules/"+module+"/tests/unit_tests/"+test_mat(i,j)+".dia")<>[]) ..
+ & ( (test_types_keeped=="all_tests") | (test_types_keeped=="unit_tests") ) then
+ test_clean_onetest(module,test_mat(i,j),"unit_tests");
+
+ elseif (fileinfo(SCI+"/modules/"+module+"/tests/nonreg_tests/"+test_mat(i,j)+".dia")<>[]) ..
+ & ( (test_types_keeped=="all_tests") | (test_types_keeped=="nonreg_tests") ) then
+ test_clean_onetest(module,test_mat(i,j),"nonreg_tests");
+
+ else
+ error(sprintf(gettext("The test ""%s"" is not available from the ""%s"" module"),test_mat(i,j),module));
+
+ end
+ end
+ end
+ else
+ error(msprintf(gettext("%s: Wrong number of input arguments."),"test_clean"));
+ end
+
+ // =======================================================
+ // Test clean
+ // =======================================================
+
+ for i=1:test_count
+ printf(" %03d/%03d - ",i,test_count);
+ printf("[%s] %s.dia\n",test_list(i,1),test_list(i,2));
+ test_clean_dia(test_list(i,1),test_list(i,2),test_list(i,3));
+ end
+
+endfunction
+
+//-----------------------------------------------------------------------------
+// Pierre MARECHAL
+// Scilab team
+// Date : 28 oct. 2007
+//
+// => List all test files in the module <module_mat>
+// => Add them to the test_mat matrix
+//-----------------------------------------------------------------------------
+
+function test_clean_module(module_mat,test_type)
+
+ if (test_type == "all_tests") | (test_type == "unit_tests") then
+
+ module_test_dir = SCI+"/modules/"+module_mat+"/tests/unit_tests";
+ test_mat = gsort(basename(listfiles(module_test_dir+"/*.dia")),"lr","i");
+
+ nl = size(test_mat,"*");
+ for i=1:nl
+ test_clean_onetest(module_mat,test_mat(i),"unit_tests");
+ end
+
+ end
+
+ if (test_type == "all_tests") | (test_type == "nonreg_tests") then
+
+ module_test_dir = SCI+"/modules/"+module_mat+"/tests/nonreg_tests";
+ test_mat = gsort(basename(listfiles(module_test_dir+"/*.dia")),"lr","i");
+
+ nl = size(test_mat,"*");
+ for i=1:nl
+ test_clean_onetest(module_mat,test_mat(i),"nonreg_tests");
+ end
+
+ end
+
+endfunction
+
+//-----------------------------------------------------------------------------
+// Pierre MARECHAL
+// Scilab team
+// Date : 28 oct. 2007
+//
+// => Add the test <test> to the test_mat matrix
+//-----------------------------------------------------------------------------
+
+function test_clean_onetest(module,test,test_type)
+
+ global test_list;
+ global test_count;
+
+ test_count = test_count + 1;
+ test_list( test_count , 1 ) = module;
+ test_list( test_count , 2 ) = test;
+ test_list( test_count , 3 ) = test_type;
+
+endfunction
+
+//-----------------------------------------------------------------------------
+// Pierre MARECHAL
+// Scilab team
+// Date : 15 jan. 2008
+//
+// => remove dia file
+//-----------------------------------------------------------------------------
+
+function test_clean_dia(module,test,test_type)
+ mdelete(SCI+"/modules/"+module+"/tests/"+test_type+"/"+test+".dia");
+endfunction
diff --git a/modules/development_tools/macros/test_run.bin b/modules/development_tools/macros/test_run.bin
new file mode 100755
index 000000000..88f19ffd5
--- /dev/null
+++ b/modules/development_tools/macros/test_run.bin
Binary files differ
diff --git a/modules/development_tools/macros/test_run.sci b/modules/development_tools/macros/test_run.sci
new file mode 100755
index 000000000..ff9f68e26
--- /dev/null
+++ b/modules/development_tools/macros/test_run.sci
@@ -0,0 +1,1301 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL
+// Copyright (C) 2009-2011 - DIGITEO - Michael Baudin
+// Copyright (C) 2010-2012 - DIGITEO - Antoine ELIAS
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// test_run --
+// Launch unit tests.
+
+function test_run_result = test_run(varargin)
+ lhs = argn(1);
+ rhs = argn(2);
+ test_run_result = %f;
+ // =========================================================================
+ // Print test_run help
+ // =========================================================================
+ if (rhs >= 3) & (~ isempty(grep(varargin(3),"help"))) then
+ example = test_examples();
+ printf("%s\n",example);
+ return;
+ end
+
+ status.detailled_failures = "";
+ status.testsuites = [];
+ status.test_count = 0;
+ status.test_passed_count = 0;
+ status.test_failed_count = 0;
+ status.test_skipped_count = 0;
+ status.totalTime = 0;
+ status.list = [];
+
+ params.longtime = %f;
+ params.wanted_mode = "";
+ params.error_output = "check";
+ params.reference = "check";
+ params.testTypes = "all_tests";
+ params.skip_mat = [];
+ params.tests_mat = [];
+ params.test_passed_percent = 0;
+ params.test_failed_percent = 0;
+ params.test_skipped_percent = 0;
+ params.full_summary = %t;
+ params.show_diff = %f;
+ params.show_error = %f;
+
+ // =======================================================
+ // Management of the kind of tests to run and the options
+ // =======================================================
+ if rhs >= 3 then
+
+ option_mat = varargin(3);
+ if (check_option(option_mat, "unit_tests") & check_option(option_mat, "nonreg_tests")) | check_option(option_mat, "all_tests") then
+ params.testTypes = "all_tests";
+ elseif check_option(option_mat, "unit_tests") then
+ params.testTypes = "unit_tests";
+ elseif check_option(option_mat, "nonreg_tests") then
+ params.testTypes = "nonreg_tests";
+ end
+
+ option_mat = clean_option(option_mat, "unit_tests");
+ option_mat = clean_option(option_mat, "nonreg_tests");
+ option_mat = clean_option(option_mat, "all_tests");
+
+ // Skip tests
+ params.skip_mat = assign_option(option_mat, "skip_tests", varargin(2), params.skip_mat);
+ option_mat = clean_option(option_mat, "skip_tests");
+
+ // Mode
+ params.wanted_mode = assign_option(option_mat, "mode_nw", "NW", params.wanted_mode);
+ option_mat = clean_option(option_mat, "mode_nw");
+
+ params.wanted_mode = assign_option(option_mat, "mode_nwni", "NWNI", params.wanted_mode);
+ option_mat = clean_option(option_mat, "mode_nwni");
+
+ // Reference
+ params.reference = assign_option(option_mat, "no_check_ref", "skip", params.reference);
+ option_mat = clean_option(option_mat, "no_check_ref");
+
+ params.reference = assign_option(option_mat, "create_ref", "create", params.reference);
+ option_mat = clean_option(option_mat, "create_ref");
+
+ params.reference = assign_option(option_mat, "list", "list", params.reference);
+ option_mat = clean_option(option_mat, "list");
+
+ // Error Output
+ params.error_output = assign_option(option_mat, "no_check_error_output", "skip", params.error_output);
+ option_mat = clean_option(option_mat, "no_check_error_output");
+
+ // Enable long-time tests
+ params.longtime = assign_option(option_mat, "disable_lt", %f, params.longtime);
+ option_mat = clean_option(option_mat, "disable_lt");
+
+ params.longtime = assign_option(option_mat, "enable_lt", %t, params.longtime);
+ option_mat = clean_option(option_mat, "enable_lt");
+
+ // Summary display management
+ params.full_summary = assign_option(option_mat, "short_summary", %f, params.full_summary);
+ option_mat = clean_option(option_mat, "short_summary");
+
+ params.show_diff = assign_option(option_mat, "show_diff", %t, params.show_diff);
+ option_mat = clean_option(option_mat, "show_diff");
+
+ params.show_error = assign_option(option_mat, "show_error", %t, params.show_error);
+ option_mat = clean_option(option_mat, "show_error");
+
+ if option_mat <> [] then
+ printf("\nUnrecognized option(s): \n\n");
+ for i=1:size(option_mat, "*")
+ printf(" - ""%s""\n", option_mat(i));
+ end
+
+ return;
+ end
+
+ if rhs == 4 then
+ params.exportFile = varargin(4);
+ // Doing the XML export, force the display of the error and diff
+ params.show_diff = %t;
+ params.show_error = %t;
+ end
+ end
+
+
+ if params.reference <> "list" & params.full_summary then
+ printf(" TMPDIR = %s\n",TMPDIR);
+ printf("\n");
+ end
+ // =======================================================
+ // Management of the tests to run
+ // =======================================================
+ if (rhs == 0) ..
+ | ((rhs == 1) & (varargin(1)==[])) ..
+ | (((rhs == 2)|(rhs == 3)|(rhs == 4)) & (varargin(1)==[]) & (varargin(2)==[])) then
+
+
+ // No input argument
+ // test_run()
+ // test_run([])
+ // => Launch each test of each module
+
+ module_list = getmodules();
+ module_list = gsort(module_list,"lr","i");
+
+ test_count = size(module_list,"*");
+ for i=1:test_count
+ if params.reference <> "list" then
+ printf(" %03d/%03d - [%s] : \n\n", i, test_count, module_list(i));
+ end
+
+ params.tests_mat = [];
+ params.moduleName = module_list(i);
+
+ result = test_module(params);
+
+ if params.reference <> "list" then
+ status.detailled_failures = [status.detailled_failures; result.detailled_failures];
+ status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
+ status.test_skipped_count = status.test_skipped_count + result.test_skipped_count;
+
+ // Do not take in account skipped tests
+ status.test_count = status.test_count + result.test_count - status.test_skipped_count;
+ status.test_passed_count = status.test_passed_count + result.test_passed_count;
+ status.test_failed_count = status.test_failed_count + result.test_failed_count;
+ status.totalTime = status.totalTime + result.totalTime;
+ printf("\n");
+ else
+ status.test_count = status.test_count + result.test_count;
+ status.list = [status.list; result.list];
+ end
+ end
+
+ elseif (rhs == 1) ..
+ | ((rhs == 2) & (varargin(2)==[])) ..
+ | ((rhs == 3) & (varargin(2)==[])) ..
+ | ((rhs == 4) & (varargin(2)==[])) ..
+ | ( ~ isempty(params.skip_mat)) then
+
+ // One input argument
+ // test_run(<module_name>)
+ // test_run([<module_name_1>,<module_name_2>])
+ // varargin(1) = [<module_name_1>,<module_name_2>]
+
+ module_mat = varargin(1);
+
+ test_count = size(module_mat,"*");
+ for i = 1:test_count
+ if params.reference <> "list" then
+ printf(" %03d/%03d - [%s] : \n\n", i, test_count, module_mat(i));
+ end
+
+ params.tests_mat = [];
+ params.moduleName = module_mat(i);
+
+ result = test_module(params);
+
+ status.test_count = status.test_count + result.test_count;
+ if params.reference <> "list" then
+ status.detailled_failures = [status.detailled_failures; result.detailled_failures];
+ status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
+
+ status.test_skipped_count = status.test_skipped_count + result.test_skipped_count;
+ status.test_passed_count = status.test_passed_count + result.test_passed_count;
+ status.test_failed_count = status.test_failed_count + result.test_failed_count;
+ status.totalTime = status.totalTime + result.totalTime;
+
+ printf("\n");
+ else
+ status.test_count = status.test_count + result.test_count;
+ status.list = [status.list; result.list];
+ end
+ end
+ // Do not take in account skipped tests
+ status.test_count = status.test_count - status.test_skipped_count;
+ elseif or(rhs==[2 3 4]) then
+ // Two input arguments
+ // test_run(<module_name>,<test_name>)
+ // test_run(<module_name>,[<test_name_1>,<test_name_2>] )
+
+ // varargin(1) = <module_name> ==> string 1x1
+ // varargin(2) = <test_name_1> ==> mat nl x nc
+
+ params.tests_mat = varargin(2);
+ params.moduleName = varargin(1);
+
+ if ((or(size(params.moduleName) <> [1,1])) & (params.tests_mat <> [])) then
+ example = test_examples();
+ err = ["" ; msprintf(gettext("%s: Wrong size for input argument."),"test_run") ; "" ; example ];
+ printf("%s\n",err);
+ return;
+ end
+
+ result = test_module(params);
+
+ if params.reference <> "list" then
+ status.totalTime = result.totalTime;
+ status.detailled_failures = [status.detailled_failures; result.detailled_failures];
+ status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
+ status.test_skipped_count = status.test_skipped_count + result.test_skipped_count;
+
+ // Do not take in account skipped tests
+ status.test_count = status.test_count + result.test_count - status.test_skipped_count;
+ status.test_passed_count = status.test_passed_count + result.test_passed_count;
+ status.test_failed_count = status.test_failed_count + result.test_failed_count;
+ else
+ status.test_count = status.test_count + result.test_count;
+ status.list = [status.list; result.list];
+ end
+ else
+ error(msprintf(gettext("%s: Wrong number of input arguments."),"test_run"));
+ end
+
+ if params.reference == "list" then
+ test_count = size(status.list, "r");
+ for i=1:test_count
+ printf(" %4.d - [%s] %s\n", i, status.list(i, 1), status.list(i,2));
+ end
+ return;
+ end
+
+ // percent computation
+ if status.test_count <> 0 then
+ test_passed_percent = status.test_passed_count / status.test_count * 100;
+ test_failed_percent = status.test_failed_count / status.test_count * 100;
+ else
+ test_passed_percent = 0;
+ test_failed_percent = 0;
+ end
+
+ if isfield(params, "exportFile") then
+ exportToXUnitFormat(params.exportFile, status.testsuites);
+ end
+
+ if params.full_summary then
+ printf("\n");
+ printf(" --------------------------------------------------------------------------\n");
+ printf(" Summary\n\n");
+ printf(" tests %4d - 100 %%\n", status.test_count);
+ printf(" passed %4d - %3d %%\n", status.test_passed_count, test_passed_percent);
+ printf(" failed %4d - %3d %%\n", status.test_failed_count, test_failed_percent);
+ printf(" skipped %4d\n", status.test_skipped_count);
+ printf(" length %4.2f sec\n", status.totalTime);
+ printf(" --------------------------------------------------------------------------\n");
+
+ if isfield(params, "exportFile") then
+ printf(" Export to %s\n", params.exportFile);
+ printf(" --------------------------------------------------------------------------\n");
+ end
+
+ if status.test_failed_count > 0 then
+ printf(" Details\n\n");
+ printf("%s\n",status.detailled_failures);
+ printf("\n");
+ printf(" --------------------------------------------------------------------------\n");
+ end
+ else
+ printf("\n");
+ printf(" --------------------------------------------------------------------------\n");
+ printf(" Tests: %4d, ", status.test_count);
+ printf(" Passed: %4d, ", status.test_passed_count);
+ printf(" Failed: %4d, ", status.test_failed_count);
+ printf(" Skipped: %4d\n", status.test_skipped_count);
+ printf(" --------------------------------------------------------------------------\n");
+ end
+
+ // Returns %t if no error has been detected
+ // Returns %f if any error has been detected
+ test_run_result = (status.test_failed_count == 0);
+
+endfunction
+
+
+
+function status = test_module(_params)
+ name = splitModule(_params.moduleName);
+
+ if with_module(name(1)) then
+ // It's a scilab internal module
+ module.path = pathconvert(SCI + "/modules/" + name(1), %F);
+ elseif or(librarieslist() == "atomslib") & atomsIsLoaded(name(1)) then
+ // It's an ATOMS module
+ module.path = pathconvert(atomsGetLoadedPath(name(1)) , %F, %T);
+ elseif isdir(name(1)) then
+ // It's an external module
+ module.path = pathconvert(name(1), %F);
+ else
+ // It's an error
+ error(sprintf(gettext("%s is not an installed module or toolbox"), name(1)));
+ end
+
+ //get tests from path
+ my_types = ["unit_tests","nonreg_tests"];
+
+ directories = [];
+ for i=1:size(my_types,"*")
+ if (_params.testTypes == "all_tests") | (_params.testTypes == my_types(i)) then
+ directory_path = module.path + "/tests/" + my_types(i);
+ for j=2:size(name,"*")
+ directory_path = directory_path + filesep() + name(j);
+ end
+
+ if isdir(directory_path) then
+ directories = [directories;getDirectories(directory_path + filesep())];
+ end
+ end
+ end
+
+ tests = [];
+ if( _params.tests_mat == [])
+ for i=1:size(directories, "*")
+ currentDir = directories(i);
+ tests_mat = gsort(basename(listfiles(currentDir + filesep() + "*.tst")),"lr","i");
+
+ for j = 1:size(tests_mat, "*")
+ if or(tests_mat(j) == _params.skip_mat) == %f then
+ tests($+1, [1,2]) = [currentDir, tests_mat(j)];
+ end
+ end
+ end
+ else
+ //not empty tests_mat
+ for i = 1:size(_params.tests_mat, "*")
+ bFind = %f;
+ for j = 1:size(directories, "*")
+ currentDir = directories(j);
+ testFile = currentDir + filesep() + _params.tests_mat(i) + ".tst";
+ if isfile(testFile) then
+ tests($+1, [1,2]) = [currentDir, _params.tests_mat(i)];
+ bFind = %t;
+ end
+ end
+
+ if bFind == %f then
+ error(sprintf(gettext("The test ""%s"" is not available from the ""%s"" module"), _params.tests_mat(i), name(1)));
+ end
+ end
+ end
+
+ //initialize counter
+ detailled_failures = "";
+ test_count = size(tests, "r");
+ test_passed_count = 0;
+ test_failed_count = 0;
+ test_skipped_count = 0;
+
+ moduleName = _params.moduleName;
+ // Improve the display of the module
+ if isdir(moduleName) then
+ if part(moduleName,1:length(SCI)) == SCI then
+ moduleName = "SCI" + part(moduleName,length(SCI)+1:length(moduleName));
+ elseif part(moduleName,1:length(SCIHOME)) == SCIHOME then
+ moduleName = "SCIHOME" + part(moduleName,length(SCIHOME)+1:length(moduleName));
+ end
+ end
+
+ // For the XML export
+ testsuite.name=moduleName
+ testsuite.time=0
+ testsuite.tests=0
+ testsuite.errors=0
+
+ //don't test only return list of tests.
+ if _params.reference == "list" then
+ for i = 1:test_count
+ if size(name, "*") > 1 then
+ displayModuleName = sprintf("%s", name(1));
+ for j=2:size(name, "*")
+ displayModuleName = displayModuleName + sprintf("|%s", name(j));
+ end
+ else
+ displayModuleName = sprintf("%s", name(1));
+ end
+ tests(i,1) = displayModuleName;
+ end
+ status.list = tests;
+ status.test_count = test_count;
+ return;
+ end
+
+ tic();
+ for i = 1:test_count
+ printf(" %03d/%03d - ",i, test_count);
+
+ if size(name, "*") > 1 then
+ displayModuleName = sprintf("[%s", name(1));
+ for j=2:size(name, "*")
+ displayModuleName = displayModuleName + sprintf("|%s", name(j));
+ end
+ displayModuleName = displayModuleName + sprintf("] %s", tests(i,2));
+ else
+ displayModuleName = sprintf("[%s] %s", name(1), tests(i,2));
+ end
+
+ printf("%s", displayModuleName);
+ if length(displayModuleName) >= 50 then
+ printf(" ");
+ end
+ for j = length(displayModuleName):50
+ printf(".");
+ end
+
+ elapsedTimeBefore=toc();
+ result = test_single(_params, tests(i,1), tests(i,2));
+ elapsedTimeAfter=toc();
+
+ testsuite.tests = testsuite.tests + 1
+
+ testsuite.testcase(i).name=tests(i,2);
+ testsuite.testcase(i).time=elapsedTimeAfter-elapsedTimeBefore;
+ testsuite.testcase(i).skipped=(result.id >= 10) & (result.id < 20);
+
+ if result.id == 0 then
+ printf("passed\n");
+ test_passed_count = test_passed_count + 1;
+ else
+ msg = sprintf(result.message);
+ printf("%s \n", msg(1));
+ for kline = 2:size(msg, "*")
+ printf(part(" ", 1:62) + "%s \n", msg(2));
+ end
+
+ if result.id < 10 then
+ //failed
+ test_failed_count = test_failed_count + 1;
+ detailled_failures = [ detailled_failures ; sprintf(" TEST : [%s] %s", _params.moduleName, tests(i,2))];
+ detailled_failures = [ detailled_failures ; sprintf(" %s", result.message) ];
+ detailled_failures = [ detailled_failures ; result.details ];
+ detailled_failures = [ detailled_failures ; "" ];
+
+ testsuite.errors = testsuite.errors + 1
+ testsuite.testcase(i).failure.type=result.message
+ testsuite.testcase(i).failure.content=result.details
+
+ elseif (result.id >= 10) & (result.id < 20) then
+ // skipped
+ test_skipped_count = test_skipped_count + 1;
+ end
+ end
+ end
+
+ status.totalTime = toc();
+
+ testsuite.time=status.totalTime;
+
+ clearglobal TICTOC;
+ status.test_passed_count = test_passed_count;
+ status.test_failed_count = test_failed_count;
+ status.test_skipped_count = test_skipped_count;
+
+ // Summary
+ status.test_count = test_count;
+ status.detailled_failures = detailled_failures;
+ status.testsuite = testsuite;
+endfunction
+
+function status = test_single(_module, _testPath, _testName)
+ //option flag
+
+ skip = %F;
+ interactive = %F;
+ notyetfixed = %F;
+ longtime = %F;
+ reopened = %F;
+ jvm = %T;
+ graphic = %F;
+ mpi = %F;
+ execMode = "";
+ platform = "all";
+ language = "any";
+ try_catch = %T;
+ error_output = "check";
+ reference = "check";
+ xcosNeeded = %F;
+
+ //some paths
+ tmp_tst = pathconvert( TMPDIR + "/" + _testName + ".tst", %F);
+ tmp_dia = pathconvert( TMPDIR + "/" + _testName + ".dia.tmp", %F);
+ tmp_res = pathconvert( TMPDIR + "/" + _testName + ".res", %F);
+ tmp_err = pathconvert( TMPDIR + "/" + _testName + ".err", %F);
+ path_dia = pathconvert( TMPDIR + "/" + _testName + ".dia", %F);
+
+ path_dia_ref = _testPath + _testName + ".dia.ref";
+ // Reference file management OS by OS
+ if getos() == "Windows" then
+ [branch info] = getversion();
+ if info(2) == "x86" then // Look for a 32bits-specific reference file
+ altreffile = [ _testPath + _testName + ".win.dia.ref" ; _testPath + _testName + ".win32.dia.ref" ];
+ else
+ altreffile = [ _testPath + _testName + ".win.dia.ref" ];
+ end
+ elseif getos() == "Darwin" then
+ altreffile = [ _testPath + _testName + ".unix.dia.ref" ; _testPath + _testName + ".macosx.dia.ref" ];
+ elseif getos() == "Linux" then
+ [branch info] = getversion();
+ if info(2) == "x86" then // Look for a 32bits-specific reference file
+ altreffile = [ _testPath + _testName + ".unix.dia.ref" ; _testPath + _testName + ".linux.dia.ref" ; _testPath + _testName + ".linux32.dia.ref" ];
+ else
+ altreffile = [ _testPath + _testName + ".unix.dia.ref" ; _testPath + _testName + ".linux.dia.ref" ];
+ end
+ else
+ altreffile = [ _testPath + _testName + ".unix.dia.ref" ];
+ end
+
+ for i=1:size(altreffile,"*")
+ if isfile(altreffile(i)) then
+ path_dia_ref = altreffile(i);
+ end
+ end
+
+ //output structure
+ status.id = 0;
+ status.message = "";
+ status.details = "";
+
+ //Reset standard globals
+ rand("seed",0);
+ rand("uniform");
+
+ //load file
+ testFile = _testPath + _testName + ".tst";
+ sciFile = mgetl(testFile);
+
+ //read options
+ if ~isempty(grep(sciFile, "<-- NOT FIXED -->")) then
+ status.id = 10;
+ status.message = "skipped: not yet fixed";
+ return;
+ end
+
+ if ~isempty(grep(sciFile, "<-- REOPENED -->")) then
+ status.id = 10;
+ status.message = "skipped: Bug reopened";
+ return;
+ end
+
+ // platform
+ if ~isempty(grep(sciFile, "<-- WINDOWS ONLY -->")) & getos() <> "Windows" then
+ status.id = 10;
+ status.message = "skipped: Windows only";
+ return;
+ end
+
+ if ~isempty(grep(sciFile, "<-- UNIX ONLY -->")) & getos() == "Windows" then
+ status.id = 10;
+ status.message = "skipped: Unix only";
+ return;
+ end
+
+ if ~isempty(grep(sciFile, "<-- LINUX ONLY -->")) & getos() <> "Linux" then
+ status.id = 10;
+ status.message = "skipped: Linux only";
+ return;
+ end
+
+ if ~isempty(grep(sciFile, "<-- MACOSX ONLY -->")) & getos() <> "Darwin" then
+ status.id = 10;
+ status.message = "skipped: MacOSX only";
+ return;
+ end
+
+ // Test execution
+ if ~isempty(grep(sciFile, "<-- INTERACTIVE TEST -->")) then
+ status.id = 10;
+ status.message = "skipped: interactive test";
+ return;
+ end
+
+ if ~isempty(grep(sciFile, "<-- LONG TIME EXECUTION -->")) & ~_module.longtime then
+ status.id = 10;
+ status.message = "skipped: Long time duration";
+ return;
+ end
+
+ if ~isempty(grep(sciFile, "<-- TEST WITH GRAPHIC -->")) then
+ if _module.wanted_mode == "NWNI" then
+ status.id = 10;
+ status.message = "skipped: Test with graphic";
+ return;
+ end
+
+ graphic = %T;
+ jvm = %T;
+ execMode = "NW";
+ end
+
+ if (~isempty(grep(sciFile, "<-- JVM NOT MANDATORY -->")) | ~isempty(grep(sciFile, "<-- CLI SHELL MODE -->"))) then
+ jvm = %F;
+ execMode = "NWNI";
+ end
+
+ MPITestPos=grep(sciFile, "<-- MPI TEST")
+ if ~isempty(MPITestPos) then
+ mpi_node=msscanf(sciFile(MPITestPos), "// <-- MPI TEST %d -->")
+ if mpi_node == [] then
+ // No node found ? No worries, default to 2
+ mpi_node = 2
+ end
+ mpi = %t;
+ execMode = "NWNI";
+ reference = "skip";
+ end
+ clear MPITestPos
+
+ if ~isempty(grep(sciFile, "<-- XCOS TEST -->")) then
+ if _module.wanted_mode == "NWNI" then
+ status.id = 10;
+ status.message = "skipped: Test with xcos";
+ return;
+ end
+ xcosNeeded = %T;
+ jvm = %T;
+ end
+
+ // Language
+ if ~isempty(grep(sciFile, "<-- FRENCH IMPOSED -->")) then
+ language = "fr_FR";
+ end
+
+
+ if ~isempty(grep(sciFile, "<-- ENGLISH IMPOSED -->")) then
+ language = "en_US";
+ end
+
+ // Test building
+ if ~isempty(grep(sciFile, "<-- NO TRY CATCH -->")) then
+ try_catch = %F;
+ end
+
+ // Test result
+ if ~isempty(grep(sciFile, "<-- NO CHECK ERROR OUTPUT -->")) then
+ error_output = "skip";
+ end
+
+ if ~isempty(grep(sciFile, "<-- NO CHECK REF -->")) then
+ reference = "skip";
+ end
+
+ //build real test file
+
+ // Do some modification in tst file
+ //replace "pause,end" by "bugmes();quit;end"
+ sciFile = strsubst(sciFile, "pause,end", "bugmes();quit;end");
+ sciFile = strsubst(sciFile, "pause, end", "bugmes();quit;end");
+ sciFile = strsubst(sciFile, "pause;end", "bugmes();quit;end");
+ sciFile = strsubst(sciFile, "pause; end", "bugmes();quit;end");
+
+ //to avoid suppression of input --> with prompts
+ sciFile = strsubst(sciFile, "-->", "@#>");
+ //remove halt calls
+ sciFile = strsubst(sciFile, "halt();", "");
+
+ // Build test header
+ head = [
+ "// <-- HEADER START -->";
+ "mode(3);" ;
+ "lines(28,72);";
+ "lines(0);" ;
+ "function %onprompt" ;
+ " quit;" ;
+ "endfunction" ;
+ "function []=bugmes(), printf(''error on test'');endfunction"
+ "predef(''all'');";
+ "tmpdirToPrint = msprintf(''TMPDIR1=''''%s'''';//\n'',TMPDIR);"
+ ];
+
+ if xcosNeeded then
+ head = [
+ head;
+ "prot=funcprot(); funcprot(0);";
+ "loadXcosLibs(); loadScicos();";
+ "funcprot(prot);";
+ ];
+ end
+
+ if try_catch then
+ head = [ head ; "try" ];
+ end
+
+ head = [
+ head;
+ "diary(''" + tmp_dia + "'');";
+ "printf(''%s\n'',tmpdirToPrint);";
+ "// <-- HEADER END -->"
+ ];
+
+ // Build test footer
+ tail = [ "// <-- FOOTER START -->" ];
+
+ if try_catch then
+ tail = [
+ tail;
+ "catch";
+ " errmsg = ""<--""+""Error on the test script file""+""-->"";";
+ " printf(""%s\n"",errmsg);";
+ " lasterror()";
+ "end";
+ ];
+ end
+
+ tail = [ tail; "diary(0);" ];
+
+ if graphic then
+ tail = [ tail; "xdel(winsid());sleep(1000);" ];
+ end
+
+ tail = [ tail; "exit(0);" ; "// <-- FOOTER END -->" ];
+
+ //Build final test
+ sciFile = [head ; sciFile ; tail];
+
+
+ //Build command to execute
+
+ //scilab path
+ if (getos() <> "Windows") & ~isfile(SCI+"/bin/scilab") then
+ SCI_BIN = strsubst(SCI,"share/scilab","");
+ else
+ SCI_BIN = SCI;
+ end
+
+ //mode
+ if _module.wanted_mode == "NW" then
+ mode_arg = "-nw";
+ elseif _module.wanted_mode == "NWNI" then
+ mode_arg = "-nwni";
+ else
+ if execMode == "NWNI" then
+ mode_arg = "-nwni";
+ elseif execMode == "NW" then
+ mode_arg = "-nw";
+ else
+ mode_arg = "-nw";
+ end
+ end
+
+ if mpi == %t then
+ prefix_bin="mpirun -c " + string(mpi_node) + " -bynode"
+ else
+ prefix_bin=""
+ end
+
+
+ //language
+ if language == "any" then
+ language_arg = "";
+ elseif getos() == "Windows" then
+ language_arg = "-l "+ language;
+ else
+ language_arg = "LANG=" + language + " ";
+ end
+
+ loader_path = pathconvert(fullfile(_module.moduleName, "loader.sce"), %f);
+
+ // Build final command
+ if getos() == "Windows" then
+ if (isdir(_module.moduleName) & isfile(loader_path)) // external module not in Scilab
+ test_cmd = "( """ + SCI_BIN + "\bin\scilex.exe" + """" + " " + mode_arg + " " + language_arg + " -nb -e ""exec(""""" + loader_path + """"");exec(""""" + tmp_tst + """"");"" > """ + tmp_res + """ ) 2> """ + tmp_err + """";
+ else // standard module
+ test_cmd = "( """ + SCI_BIN + "\bin\scilex.exe" + """" + " " + mode_arg + " " + language_arg + " -nb -f """ + tmp_tst + """ > """ + tmp_res + """ ) 2> """ + tmp_err + """";
+ end
+ else
+ if (isdir(_module.moduleName) & isfile(loader_path))
+ test_cmd = "( " + language_arg + " " + SCI_BIN + "/bin/scilab " + mode_arg + " -nb -e ""exec(''" + loader_path + "'');exec(''" + tmp_tst +"'');""" + " > " + tmp_res + " ) 2> " + tmp_err;
+ else
+ test_cmd = "( " + language_arg + " " + prefix_bin + " " + SCI_BIN + "/bin/scilab " + mode_arg + " -nb -f " + tmp_tst + " > " + tmp_res + " ) 2> " + tmp_err;
+ end
+ end
+
+ //clean previous tmp files
+ if isfile(tmp_tst) then
+ deletefile(tmp_tst);
+ end
+
+ if isfile(tmp_dia) then
+ deletefile(tmp_dia);
+ end
+
+ if isfile(tmp_res) then
+ deletefile(tmp_res);
+ end
+
+ if isfile(tmp_err) then
+ deletefile(tmp_err);
+ end
+
+ //create tmp test file
+ mputl(sciFile, tmp_tst);
+
+ //execute test
+ returnStatus = host(test_cmd);
+ //Check return status
+ if (returnStatus <> 0)
+ status.id = 5;
+ status.message = "failed: Slave Scilab exited with error code " + string(returnStatus);
+ return;
+ end
+
+ //Check errors
+ if (error_output == "check") & (_module.error_output == "check") then
+ if getos() == "Darwin" then
+ tmp_errfile_info = fileinfo(tmp_err);
+ msg = "JavaVM: requested Java version (1.5) not available. Using Java at ""/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"" instead."
+
+ if ~isempty(tmp_errfile_info) then
+ txt = mgetl(tmp_err);
+ txt(txt==msg) = [];
+ if isempty(txt) then
+ deletefile(tmp_err);
+ else // Remove messages due to JOGL2 RC8
+ toRemove = grep(txt, "__NSAutoreleaseNoPool()");
+ txt(toRemove) = [];
+ if isempty(txt) then
+ deletefile(tmp_err);
+ end
+ end
+ end
+ end
+
+ if getos() == "Linux" then // Ignore JOGL2 debug message
+ tmp_errfile_info = fileinfo(tmp_err);
+ msg = "Error: unable to open display (null)"
+
+ if ~isempty(tmp_errfile_info) then
+ txt = mgetl(tmp_err);
+ txt(txt==msg) = [];
+ if isempty(txt) then
+ deletefile(tmp_err);
+ else // Remove messages due to warning message from library
+ toRemove = grep(txt, "libEGL warning: failed to find any driver");
+ txt(toRemove) = [];
+
+ if ~isempty(txt) then
+ toRemove = grep(txt, "extension ""RANDR"" missing on display");
+ txt(toRemove) = [];
+ end
+
+ if isempty(txt) then
+ deletefile(tmp_err);
+ end
+ end
+ end
+ end
+
+ if getos() == "Windows" then // Ignore JOGL 2.2.4 debug message
+ tmp_errfile_info = fileinfo(tmp_err);
+ msg = "Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x500";
+
+ if ~isempty(tmp_errfile_info) then
+ txt = mgetl(tmp_err);
+ txt(txt==msg) = [];
+ if isempty(txt) then
+ deletefile(tmp_err);
+ else // Ignore JOGL 2.1.4 debug message
+ msg = "Info: GLDrawableHelper.reshape: pre-exisiting GL error 0x500";
+ txt(txt==msg) = [];
+ if isempty(txt) then
+ deletefile(tmp_err);
+ end
+ end
+ end
+ end
+
+ tmp_errfile_info = fileinfo(tmp_err);
+
+ if isfile(tmp_err) & tmp_errfile_info(1) <> 0 then
+ status.id = 5;
+ status.message = "failed: error_output not empty\n Use ''no_check_error_output'' option to disable this check.";
+ status.details = checkthefile(tmp_err);
+ return;
+ end
+ end
+
+ //Process output files
+
+ //Get the dia file
+ if isfile(tmp_dia) then
+ dia = mgetl(tmp_dia);
+ else
+ status.id = 6;
+ status.message = "failed: Cannot find the dia file: " + tmp_dia + "\nCheck if the Scilab used correctly starts";
+ status.details = checkthefile(tmp_dia);
+ return;
+ end
+
+ // To get TMPDIR value
+ tmpdir1_line = grep(dia, "TMPDIR1");
+ execstr(dia(tmpdir1_line));
+
+ //Check for execution errors
+ if try_catch & grep(dia,"<--Error on the test script file-->") <> [] then
+ details = [ checkthefile(tmp_dia); ..
+ launchthecommand(testFile)];
+ status.id = 3;
+ status.message = "failed: premature end of the test script";
+ status.details = details;
+ if params.show_error == %t then
+ status.details = [ status.details; dia($-10:$) ]
+ end
+
+ return;
+ end
+
+ // Remove Header and Footer
+ dia = remove_headers(dia);
+
+ //Check for execution errors
+ dia_tmp = dia;
+
+ // remove commented lines
+ dia_tmp(grep(dia_tmp, "//")) = [];
+
+ if try_catch & grep(dia_tmp, "!--error") <> [] then
+ details = [ checkthefile(tmp_dia); ..
+ launchthecommand(testFile) ];
+ status.id = 1;
+ status.message = "failed: the string (!--error) has been detected";
+ status.details = details;
+ return;
+ end
+
+
+ if grep(dia_tmp,"error on test")<>[] then
+ details = [ checkthefile(tmp_dia); ..
+ launchthecommand(testFile) ];
+ status.id = 2;
+ status.message = "failed: one or several tests failed";
+ status.details = details;
+ if params.show_error == %t then
+ status.details = [ status.details; dia($-min(10, size(dia, "*")-1):$) ]
+ end
+ return;
+ end
+
+
+ if tmpdir1_line == [] then
+ status.id = 6;
+ status.message = "failed: the dia file is not correct";
+ status.details = checkthefile(tmp_dia);
+ return;
+ end
+
+
+ // Check the reference file only if check_ref (i.e. for the whole
+ // test sequence) is true and this_check_ref (i.e. for the specific current .tst)
+ // is true.
+
+ if (reference=="check") & (_module.reference=="check") then
+ if isfile(path_dia_ref) == %f then
+ status.id = 5;
+ status.message = "failed: the ref file doesn''t exist\n Use ''no_check_ref'' option to disable this check.";
+ status.details = createthefile(path_dia_ref);
+ return;
+ end
+ end
+
+ // Comparaison ref <--> dia
+
+ if ( (reference=="check") & (_module.reference=="check") ) | (_module.reference=="create") then
+ // Do some modification in dia file
+
+ dia(grep(dia, "write(%io(2), tmpdirToPrint")) = [];
+ dia(grep(dia, "TMPDIR1")) = [];
+ dia(grep(dia, "diary(0)")) = [];
+
+ if getos() == "Darwin" then // TMPDIR is a symblic link
+ dia = strsubst(dia,"/private" + TMPDIR1, "TMPDIR");
+ dia = strsubst(dia,"/private" + TMPDIR, "TMPDIR");
+ end
+ dia = strsubst(dia,TMPDIR ,"TMPDIR");
+ dia = strsubst(dia,TMPDIR1, "TMPDIR");
+
+ if getos() == "Windows" then
+ dia = strsubst(dia, strsubst(TMPDIR, "\","/"), "TMPDIR");
+ dia = strsubst(dia, strsubst(TMPDIR1, "\","/"), "TMPDIR");
+ dia = strsubst(dia, strsubst(TMPDIR, "/","\"), "TMPDIR");
+ dia = strsubst(dia, strsubst(TMPDIR1, "/","\"), "TMPDIR");
+ dia = strsubst(dia, strsubst(getshortpathname(TMPDIR), "\","/"), "TMPDIR");
+ dia = strsubst(dia, strsubst(getshortpathname(TMPDIR1), "\","/"), "TMPDIR");
+ dia = strsubst(dia, getshortpathname(TMPDIR), "TMPDIR");
+ dia = strsubst(dia, getshortpathname(TMPDIR1), "TMPDIR");
+ end
+
+ dia = strsubst(dia, SCI, "SCI");
+
+ if getos() == "Windows" then
+ dia = strsubst(dia, strsubst(SCI, "\","/"), "SCI");
+ dia = strsubst(dia, strsubst(SCI, "/","\"), "SCI");
+ dia = strsubst(dia, strsubst(getshortpathname(SCI), "\","/"), "SCI");
+ dia = strsubst(dia, getshortpathname(SCI), "SCI");
+ end
+
+ //suppress the prompts
+ dia = strsubst(dia, "-->", "");
+ dia = strsubst(dia, "@#>", "-->");
+ dia = strsubst(dia, "-1->", "");
+
+ //standardise number display
+
+ // strsubst(dia, " .", "0.");
+ // strsubst(dia, "-.", "-0.")
+ // strsubst(dia, "E+", "D+");
+ // strsubst(dia, "E-", "D-");
+
+ //not to change the ref files
+ dia = strsubst(dia ,"bugmes();return", "bugmes();quit");
+
+ if _module.reference=="create" then
+ // Delete previous .dia.ref file
+ if isfile(path_dia_ref) then
+ deletefile(path_dia_ref)
+ end
+
+ mputl(dia, path_dia_ref);
+ status.id = 20;
+ status.message = "passed: ref created";
+ return;
+ else
+ // write down the resulting dia file
+ mputl(dia, path_dia);
+
+ //Check for diff with the .ref file
+ [u,ierr] = mopen(path_dia_ref, "r");
+ if ierr== 0 then //ref file exists
+ ref=mgetl(u);
+ mclose(u)
+
+ // suppress blank (diff -nw)
+ dia = strsubst(dia, " ", "")
+ ref = strsubst(ref, " ", "")
+
+ dia(find(dia == "")) = [];
+ ref(find(ref == "")) = [];
+
+ dia(find(dia == "")) = [];
+ ref(find(ref == "")) = [];
+
+ dia(find(part(dia, (1:2)) == "//")) = [];
+ ref(find(part(ref, (1:2)) == "//")) = [];
+
+ if or(ref <> dia) then
+ status.id = 4;
+ status.message = "failed: dia and ref are not equal";
+ status.details = comparethefiles(path_dia, path_dia_ref);
+ return;
+ end
+
+ else
+ error(sprintf(gettext("The ref file (%s) doesn''t exist"), path_dia_ref));
+ end
+ end
+ end
+endfunction
+
+// checkthefile
+function msg = checkthefile( filename )
+ // Returns a 2-by-1 matrix of strings, containing a message such as:
+ // Check the following file :
+ // - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.tst
+ // Workaround for bug #4827
+ msg(1) = " Check the following file :"
+ msg(2) = " - "+filename
+ if params.show_error == %t then
+ msg=[msg; mgetl(filename)]
+ end
+endfunction
+
+// launchthecommand
+function msg = launchthecommand( filename )
+ // Returns a 2-by-1 matrix of strings, containing a message such as:
+ // Or launch the following command :
+ // - exec("C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.tst")
+ // Workaround for bug #4827
+ msg(1) = " Or launch the following command :"
+ msg(2) = " - exec(""" + fullpath(filename) + """);"
+endfunction
+
+// => remove header from the diary txt
+function dia_out = remove_headers(dia_in)
+ dia_out = dia_in;
+ body_start = grep(dia_out,"// <-- HEADER END -->");
+ if body_start <> [] then
+ dia_out(1:body_start(1)) = [];
+ end
+
+ body_end = grep(dia_out,"// <-- FOOTER START -->");
+ if body_end <> [] then
+ [dia_nl,dia_nc] = size(dia);
+ dia_out(body_end(1):dia_nl) = [];
+ end
+endfunction
+
+//createthefile
+function msg = createthefile ( filename )
+ // Returns a 2-by-1 matrix of strings, containing a message such as:
+ // Add or create the following file :
+ // - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia.ref
+ // Workaround for bug #4827
+ msg(1) = " Add or create the following file: "
+ msg(2) = " - "+filename
+endfunction
+
+// comparethefiles
+function msg = comparethefiles ( filename1 , filename2 )
+ // Returns a 3-by-1 matrix of strings, containing a message such as:
+ // Compare the following files :
+ // - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia
+ // - C:\path\scilab\modules\optimization\tests\unit_testseldermeadeldermead_configure.dia.ref
+ // Workaround for bug #4827
+ msg(1) = " Compare the following files:"
+ msg(2) = " - "+filename1
+ msg(3) = " - "+filename2
+ if params.show_diff == %t then
+ if getos() == "Windows" then
+ diffTool = SCI + "\tools\diff\diff.exe";
+ else
+ diffTool = "diff";
+ end
+ targetFile=TMPDIR + filesep() + "tempdiff.diff";
+ unix(diffTool + " -u " + filename1 + " " + filename2 + " > " + targetFile);
+ // unix_g is failing to return the output into a variable
+ msg=[msg; mgetl(targetFile)]
+ deletefile(targetFile);
+ end
+endfunction
+
+function directories = getDirectories(directory)
+ directories = directory;
+ items = gsort(listfiles(directory),"lr","i");
+
+ for i=1:size(items,"*")
+ if isdir(directory + items(i)) then
+ directories = [directories; getDirectories(directory + items(i) + filesep())];
+ end
+ end
+endfunction
+
+function name = splitModule(name)
+ if ~isempty( regexp(stripblanks(name),"/\|/") ) then
+ name = stripblanks( strsubst( strsplit(name,regexp(stripblanks(name),"/\|/")) , "/\|$/","","r" ) );
+ end
+endfunction
+
+function example = test_examples()
+ example = [ sprintf("Examples :\n\n") ];
+ example = [ example ; sprintf("// Launch all tests\n") ];
+ example = [ example ; sprintf("test_run();\n") ];
+ example = [ example ; sprintf("test_run([]);\n") ];
+ example = [ example ; sprintf("test_run([],[]);\n") ];
+ example = [ example ; "" ];
+ example = [ example ; sprintf("// Test one or several module\n") ];
+ example = [ example ; sprintf("test_run(''core'');\n") ];
+ example = [ example ; sprintf("test_run(''core'',[]);\n") ];
+ example = [ example ; sprintf("test_run([''core'',''string'']);\n") ];
+ example = [ example ; "" ];
+ example = [ example ; sprintf("// Launch one or several test in a specified module\n") ];
+ example = [ example ; sprintf("test_run(''core'',[''trycatch'',''opcode'']);\n") ];
+ example = [ example ; "" ];
+ example = [ example ; sprintf("// With options\n") ];
+ example = [ example ; sprintf("test_run([],[],''no_check_ref'');\n") ];
+ example = [ example ; sprintf("test_run([],[],''no_check_error_output'');\n") ];
+ example = [ example ; sprintf("test_run([],[],''create_ref'');\n") ];
+ example = [ example ; sprintf("test_run([],[],''list'');\n") ];
+ example = [ example ; sprintf("test_run([],[],''help'');\n") ];
+ example = [ example ; sprintf("test_run([],[],[''no_check_ref'',''mode_nw'']);\n") ];
+ example = [ example ; "" ];
+endfunction
+
+function newOption = clean_option(var, option)
+ newOption = var;
+ newOption(newOption == option) = [];
+endfunction
+
+function result = check_option(var, option)
+ result = or(var == option);
+endfunction
+
+function value = assign_option(var, option, truevalue, falsevalue)
+ if check_option(var, option) then
+ value = truevalue;
+ else
+ value = falsevalue;
+ end
+endfunction
+
+
+function exportToXUnitFormat(exportToFile, testsuites)
+
+ if isfile(exportToFile) then
+ // File already existing. Append the results
+ doc = xmlRead(exportToFile);
+ appendIntoFile = %t;
+ node = xmlXPath(doc, "//testsuites");
+ if node.size == 0 then
+ error(msprintf(gettext("The file ''%s'' is not following the XUnit XML format. Root tag expected ''testsuites''.\n"),exportToFile))
+ end
+ else
+ doc = xmlDocument(exportToFile);
+
+ appendIntoFile = %f;
+ end
+ root = xmlElement(doc, "testsuites");
+
+ for i=1:size(testsuites, "*") // Export module by module
+ module = testsuites(i);
+ testsuite = xmlElement(doc,"testsuite");
+ testsuite.attributes.name = module.name;
+
+ testsuite.attributes.time = string(module.time);
+
+ testsuite.attributes.tests = string(module.tests);
+ testsuite.attributes.errors = string(module.errors);
+
+ for j=1:size(module.testcase,"*") // Export test by test
+ testsuite.children(j) = xmlElement(doc,"testcase");
+ unitTest = module.testcase(j);
+ testsuite.children(j).attributes.name = unitTest.name;
+ testsuite.children(j).attributes.time = string(unitTest.time);
+ testsuite.children(j).attributes.classname = getversion()+"."+module.name;
+ if isfield(unitTest,"failure") & size(unitTest.failure,"*") >= 1 then
+ testsuite.children(j).children(1) = xmlElement(doc,"failure");
+ testsuite.children(j).children(1).attributes.type = unitTest.failure.type;
+ content = unitTest.failure.content;
+ for kL=1:size(content, "*")
+ ampIdx = strindex(content(kL), "&");
+ while ~isempty(ampIdx)
+ cur = ampIdx(1);
+ ampIdx(1) = [];
+ if or(part(content(kL), (cur+1):(cur+3))==["gt;" "lt"]) then
+ // Ignored
+ else
+ content(kL) = part(content(kL), 1:cur) + "amp;" + part(content(kL), (cur+1):$);
+ ampIdx = strindex(part(content(kL), (cur+1):$), "&");
+ end
+ end
+ end
+ testsuite.children(j).children(1).content = content;
+ elseif unitTest.skipped then
+ testsuite.children(j).children(1) = xmlElement(doc,"skipped");
+ end
+ end
+
+ if appendIntoFile then
+ // We will add the new elements into 'testsuites'
+ c=node(1).children;
+ nb=size(c,"*");
+ c(nb + 1)=testsuite; // Add the new results into the list of results
+ root.children=c;
+ else
+ root.children(i)=testsuite
+ end
+ end // list of modules
+
+ doc.root=root
+
+ xmlWrite(doc);
+endfunction
diff --git a/modules/development_tools/macros/test_run_level.bin b/modules/development_tools/macros/test_run_level.bin
new file mode 100755
index 000000000..b9fcec6b9
--- /dev/null
+++ b/modules/development_tools/macros/test_run_level.bin
Binary files differ
diff --git a/modules/development_tools/macros/test_run_level.sci b/modules/development_tools/macros/test_run_level.sci
new file mode 100755
index 000000000..a235a0ae0
--- /dev/null
+++ b/modules/development_tools/macros/test_run_level.sci
@@ -0,0 +1,37 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// test_run --
+// Launch unit tests.
+
+function test_run_level(severity)
+ disp("Run all test level " + string(severity));
+ doc = xmlRead(SCI+"/modules/development_tools/data/test_run_level.xml");
+
+ // Retrieve the list of modules
+ modules=xmlXPath(doc, "/tests/level[@severity=" + string(severity) + "]/module");
+
+ for (i=1:modules.size)
+
+ // Retrieve the list of tests
+ tests = xmlAsText(xmlXPath(modules(i),"test"));
+
+ // Run the test
+ status = test_run(modules(i).attributes.name, tests, ["no_check_error_output","short_summary","show_diff","show_error"],TMPDIR+"/../test_runelevel_report.xml");
+
+ if (status == %f) then
+ error("At least one error has been detected. Failing all tests.");
+ // Since make check is launched by the build system
+ // It checks if any error occurred and fails if it happens
+ end
+ end
+
+ xmlDelete(doc);
+
+endfunction
diff --git a/modules/development_tools/macros/testexamples.bin b/modules/development_tools/macros/testexamples.bin
new file mode 100755
index 000000000..4d90eba00
--- /dev/null
+++ b/modules/development_tools/macros/testexamples.bin
Binary files differ
diff --git a/modules/development_tools/macros/testexamples.sci b/modules/development_tools/macros/testexamples.sci
new file mode 100755
index 000000000..2d6ff7f70
--- /dev/null
+++ b/modules/development_tools/macros/testexamples.sci
@@ -0,0 +1,268 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function r=load_ref(name)
+ if exists(name)==0 then r=%f;return,end
+ v=evstr(name)
+ if type(v) == 9 then v = ghdl2tree(v);end,
+ if type(v) == 128 then v=128,end //lu handle
+ load(%U,name+"_ref");
+ if exists(name+"_ref")==0 then
+ disp(msprintf(gettext("No variable %s_ref in reference file"),name))
+ r=%t
+ return
+ end
+ execstr("r=%CMP(v,"+name+"_ref);")
+endfunction
+
+function r=load_ref_nocheck(name)
+
+ if exists(name)==0 then r=%f;return,end
+ v=evstr(name)
+ if type(v) == 9 then v = ghdl2tree(v);end,
+ if type(v) == 128 then v=128,end //lu handle
+ load(%U,name+"_ref");
+ if exists(name+"_ref")==0 then
+ disp(msprintf(gettext("No variable %s_ref in reference file"),name))
+ r=%t
+ return
+ end
+ r=%f
+
+endfunction
+
+
+
+function reinit_for_test()
+
+ //reinitialize some Scilab state to be able to reproduce the same tests
+ sdf();sda()
+ xdel(winsid())
+ grand("setgen","clcg4");grand("setall",11111111,22222222,33333333,44444444);
+ grand("setgen","kiss");grand("setsd",362436069,521288629,123456789,380116160);
+ grand("setgen","clcg2");grand("setsd",1234567890,123456789);
+ grand("setgen","urand");grand("setsd",0);
+ grand("setgen","fsultra");grand("setsd",1234567,7654321);
+ grand("setgen","mt");grand("setsd",5489);
+ rand("seed",0);
+ format("v",10);
+ clearglobal()
+
+endfunction
+
+
+
+function r=xdel_run(w,opt)
+
+ //Author : Serge Steer, april 2005, Copyright INRIA
+ //
+ //Compare the graphic windows to be cleared with the reference given in a Scilab binary file.
+ // This function must mirror the xdel_build one.
+
+ r=%f
+ if winsid()==[] then return,end
+ cur=xget("window")
+ //
+ if argn(2)==1 then
+ ids_=[]
+ for k=1:size(w,"*")
+ xset("window",w(k))
+ if get("figure_style")=="new" then ids_=[ids_,w(k)],end
+ end
+ load(%U,"ids_ref")
+ if or(ids_ref<>ids_) then r=%t,return,end
+ for k=ids_ref
+ %wins_=ghdl2tree(scf(k));
+ load(%U,"%wins_ref");
+ if %CMP(%wins_, %wins_ref) then r=%t,return,end
+ end
+ xdel(w)
+ else
+ if get("figure_style")=="old" then return,end
+ ids_=xget("window")
+ load(%U,"ids_ref")
+ if or(ids_ref<>ids_) then r=%t,return,end
+ %wins_=ghdl2tree(gcf());
+ load(%U,"%wins_ref");
+ if %CMP(%wins_,%wins_ref) then r=%t,return,end
+ xdel()
+ end
+ if or(winsid()==cur) then xset("window",cur),end
+
+endfunction
+
+
+
+function r=clf_run(w,opt)
+
+ //Author : Serge Steer, april 2005, Copyright INRIA
+ //
+ //Compare the graphic windows to be cleared with the reference given in a Scilab binary file.
+ // This function must mirror the clf_build one.
+
+ r=%f
+ if winsid()==[] then return,end
+ cur=xget("window")
+ rhs=argn(2)
+ if rhs==1&type(w)==10 then opt=w;rhs=0,end
+ if winsid()==[] then return,end
+ //
+ if rhs==1 then
+ ids_=[]
+ if type(w)==9 then
+ H=w;w=[]
+ for h=H,w=[w,h.figure_id],end
+ end
+ for k=1:size(w,"*")
+ xset("window",w(k))
+ if get("figure_style")=="new" then ids_=[ids_,w(k)],end
+ end
+ load(%U,"ids_ref")
+ if or(ids_ref<>ids_) then r=%t,return,end
+ for k=ids_ref
+ %wins_=ghdl2tree(scf(k));
+ load(%U,"%wins_ref");
+ if %CMP(%wins_, %wins_ref) then r=%t,return,end
+ end
+ if rhs==1 then clf(w),else clf(w,opt),end
+ else
+ if get("figure_style")=="old" then return,end
+ ids_=xget("window")
+ load(%U,"ids_ref")
+ if or(ids_ref<>ids_) then r=%t,return,end
+ %wins_=ghdl2tree(gcf());
+ load(%U,"%wins_ref");
+ if %CMP(%wins_,%wins_ref) then r=%t,return,end
+ clf()
+ end
+ if or(winsid()==cur) then xset("window",cur),end
+
+endfunction
+
+
+
+function r=xbasc_run(w)
+
+ //Author : Serge Steer, april 2005, Copyright INRIA
+ //
+ //Compare the graphic windows to be cleared with the reference given in a Scilab binary file.
+ // This function must mirror the xbasc_build one.
+ r=%f
+ if winsid()==[] then return,end
+ cur=xget("window")
+ //
+ if argn(2)==1 then
+ ids_=[]
+ for k=1:size(w,"*")
+ xset("window",w(k))
+ if get("figure_style")=="new" then ids_=[ids_,w(k)],end
+ end
+ load(%U,"ids_ref")
+ if or(ids_ref<>ids_) then r=%t,return,end
+ for k=ids_ref
+ %wins_=ghdl2tree(scf(k));
+ load(%U,"%wins_ref");
+ %wins_ref.figure_position=%wins_.figure_position
+ if %CMP(%wins_, %wins_ref) then r=%t,return,end
+ end
+
+ clf(w)
+ else
+ if get("figure_style")=="old" then return,end
+ ids_=xget("window");
+ load(%U,"ids_ref")
+ if or(ids_ref<>ids_) then r=%t,return,end
+ %wins_=ghdl2tree(gcf());
+ load(%U,"%wins_ref");
+ %wins_ref.figure_position=%wins_.figure_position
+ if %CMP(%wins_, %wins_ref) then r=%t,return,end
+ clf()
+ end
+ if or(winsid()==cur) then xset("window",cur),end
+
+endfunction
+
+
+
+function r=%CMP(%A,%B)
+
+ //Author : Serge Steer, april 2005, Copyright INRIA
+ //
+ // this function compares two variables, floating points data are
+ // compared using a relative tolerance
+
+ r=%f
+ tol=0.00001
+ if type(%A)<>type(%B) then r=%t,return,end
+ select type(%A)
+ case 1 then //float
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ %ka=~isnan(%A);%kb=~isnan(%B);
+ if or(%ka<>%kb) then r=%t,return,end
+ if isreal(%A)<>isreal(%A) then r=%t,return,end
+ if or(clean(%A(%ka)-%B(%kb))<>0) then r=%t,return,end
+ case 2 then //polynomial
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ if or(degree(%A)<>degree(%B)) then r=%t,return,end
+ if or(clean(%A-%B)<>0) then r=%t,return,end
+ case 4 then //boolean
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ if or(%A<>%B) then r=%t,return,end
+ case 5 then //sparse
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ [ija,%A]=spget(%A);[ijb,%B]=spget(%B);
+ if or(ija<>ijb) then r=%t,return,end
+ %ka=~isnan(%A);%kb=~isnan(%B);
+ if or(%ka<>%kb) then r=%t,return,end
+ if or(clean(%A(%ka)-%B(%kb))<>0) then r=%t,return,end
+ case 6 then //boolean sparse
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ if or(%A<>%B) then r=%t,return,end
+ case 8 then //int
+ if or(inttype(%A)<>inttype(%B)) then r=%t,return,end
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ if or(%A<>%B) then r=%t,return,end
+ case 9 then //handle
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ // if or(%A<>%B) then r=%t,return,end
+ case 10 then //string
+ if or(size(%A)<>size(%B)) then r=%t,return,end
+ if or(%A<>%B) then r=%t,return,end
+ case 13 then //compiled function
+ if %A<>%B then r=%t,return,end
+ case 14 then //library
+ if or(gsort(string(%A))<>gsort(string(%B))) then r=%t,return,end
+ case 15 then //list
+ if or(lstsize(%A)<>lstsize(%B)) then r=%t,return,end
+ if or(definedfields(%A)<>definedfields(%B)) then r=%t,return,end
+ for k = definedfields(%A)
+ if %CMP(%A(k),%B(k)) then r=%t,return,end
+ end
+ case 16 then //tlist
+ if or(lstsize(%A)<>lstsize(%B)) then r=%t,return,end
+ if or(definedfields(%A)<>definedfields(%B)) then r=%t,return,end
+ if typeof(%A)=="rational" then
+ if or(clean(%A-%B)<>0) then r=%t,end
+ return
+ end
+ for k = definedfields(%A)
+ if %CMP(%A(k),%B(k)) then r=%t,return,end
+ end
+ case 17 then //mlist
+ if or(lstsize(%A)<>lstsize(%B)) then r=%t,return,end
+ if or(definedfields(%A)<>definedfields(%B)) then r=%t,return,end
+ for k = definedfields(%A)
+ if %CMP(getfield(k,%A),getfield(k,%B)) then r=%t,return,end
+ end
+ case 130 then
+ if %A<>%B then r=%t,return,end
+ else
+ r=%f
+ end
+endfunction
diff --git a/modules/development_tools/macros/unit_test_run.bin b/modules/development_tools/macros/unit_test_run.bin
new file mode 100755
index 000000000..f9d60aa84
--- /dev/null
+++ b/modules/development_tools/macros/unit_test_run.bin
Binary files differ
diff --git a/modules/development_tools/macros/unit_test_run.sci b/modules/development_tools/macros/unit_test_run.sci
new file mode 100755
index 000000000..578b116db
--- /dev/null
+++ b/modules/development_tools/macros/unit_test_run.sci
@@ -0,0 +1,39 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// =============================================================================
+// Launch unitary tests
+// =============================================================================
+
+function unit_test_run(varargin)
+
+ lhs = argn(1);
+ rhs = argn(2);
+
+ if (rhs == 0) then
+ test_run([],[],["unit_tests"]);
+
+ elseif rhs == 1 then
+ argument_1 = varargin(1);
+ test_run(argument_1,[],["unit_tests"]);
+
+ elseif rhs == 2 then
+ argument_1 = varargin(1);
+ argument_2 = varargin(2);
+ test_run(argument_1,argument_2,["unit_tests"]);
+
+ elseif rhs == 3 then
+ argument_1 = varargin(1);
+ argument_2 = varargin(2);
+ argument_3 = varargin(3);
+ test_run(argument_1,argument_2,[argument_3,"unit_tests"]);
+
+ end
+
+endfunction