44
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % UTP_PREPARE_RESULT prepares a result structure from the inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % M Hewitson 07-11-07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % $Id: utp_prepare_result.m,v 1.13 2011/04/27 09:03:02 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 function result = utp_prepare_result(a, s, stack, call, varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 result.a = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 result.s = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 result.fcn = '?';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 result.num = '?';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 result.date = time;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 result.runtime = toc();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 result.msg = '?';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 result.method = '?';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 result.class = '?';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 result.file = '?';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 if numel(stack)>1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % look for utp_run
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 idx = -1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 for kk=1:numel(stack)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 if strcmp(stack(kk).name, 'utp_run')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 idx = kk;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 if idx>0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 call = stack(idx-1).name;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % parse out utp number
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 parts = regexp(stack(1).name, '_', 'split');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 parts = regexp(parts{end}, '(\w+)(\(.*\))*', 'tokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 utpnum = parts{1}{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 result.a = a;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 result.s = s;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 result.fcn = sprintf('%s_%s', call, utpnum);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 result.num = utpnum;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 result.subnum = parts{1}{2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 result.msg = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 parts = regexp(call, '_', 'split');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 result.method = parts{end};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 result.class = parts{end-1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 result.utp = strrep(stack(1).name, result.subnum, '');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 if ismember('file', fieldnames(stack(1)))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 result.file = stack(1).file;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 result.file = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 if a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 as = 'Pass';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 as = 'Fail';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 if s
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 ss = 'Pass';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 ss = 'Fail';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 if numel(varargin) >= 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 result.msg = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 fprintf(' %-27s | %s | %s | %s\n', result.num, ss, as, varargin{1});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 fprintf(' %-27s | %s | %s\n', result.num, ss, as);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 end
|