aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/scilab/swigtest.start
blob: e4347bd90ae77d6676e5d60975e0e3d0ca1d8c8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
lines(0);
warning('off');
ilib_verbose(0);

// Get test name (used in swigtest.quit file)
[units, typ, names] = file(1);
swigtestname = strsubst(fileparts(names, "fname"), "_runme", "");

// Does the library exists? If not then exit!
libname = "lib" + swigtestname + getdynlibext();
if ~isfile(libname) then
    mfprintf(0, "*** LIBRARY NOT FOUND: %s ***\n", libname);
    exit(1)
end

// Load library
try
    exec("loader.sce", -1);
catch
    mfprintf(0, "*** LOADER EXECUTION FAILED ***\n");
    exit(1)
end

// Module initialization
try
    moduleInit = sprintf("%s_Init()", swigtestname);
    execstr(moduleInit);
catch
    mfprintf(0, "*** MODULE INIT FAILED ***\n");
    exit(1)
end

// Error management function
function swigtesterror(msg)
    [lines, names] = where();
    if size(lines, '*') > 0
        mfprintf(0, "*** TEST FAILED (at line %d) ***\n", lines($));
        if argn(2) >= 1 then disp(msg); end
    else
        mfprintf(0, "*** TEST FAILED ***\n");
    end;
    exit(1)
endfunction

// Check equal function
function checkequal(returned, expected, message)
  if typeof(returned) <> typeof(expected) then
    returned_type_msg = ["returned type:"; typeof(returned)];
    expected_type_msg = ["expected type:"; typeof(expected)];
    swigtesterror([message; returned_type_msg; expected_type_msg]);
  end
  if ~isequal(returned, expected) then
    returned_value_msg = ["returned value:"; string(returned)];
    expected_value_msg = ["expected value:"; string(expected)];
    swigtesterror([message; returned_value_msg; expected_value_msg]);
  end
endfunction