source: issm/trunk/test/NightlyRun/IdToName.m

Last change on this file was 19105, checked in by Mathieu Morlighem, 10 years ago

merged trunk-jpl and trunk for revision 19103

  • Property svn:executable set to *
File size: 1.3 KB
RevLine 
[5100]1function name=IdToName(id);
2%IDTONAME- return name of test
[19105]3%
4% if id=0, the full list of test is returned
[4950]5%
6% Usage:
[19105]7% name=IdToName();
[5100]8% name=IdToName(id);
[4950]9
[19105]10if nargin==0 | id==0,
11 flist=dir;%use dir, as it seems to act OS independent
12 list_ids=[];
13 for i=1:numel(flist),
14 if ( strncmp(flist(i).name,'test',4) &... %File name must start with 'test'
15 strncmp(fliplr(flist(i).name),fliplr('.m'),2)&... %File name must end by '.m'
16 ~strcmp(flist(i).name,'test.m')) %File name must be different than 'test.m'
17 id=str2num(flist(i).name(5:end-2));
18 if isempty(id),
19 disp(['WARNING: ignore file ' flist(i).name ]);
20 else
21 list_ids(end+1)=eval(flist(i).name(5:end-2)); %Keep test id only (skip 'test' and '.m')
22 end
23 end
24 end
25 list_ids=sort(list_ids);
26 for i=list_ids,
27 name=IdToName(i);
28 disp(['test ' num2str(i,'%5i\n') ' : ' name]);
29 end
30 return;
31end
[13395]32
[19105]33filename = ['test' num2str(id) '.m'];
[16560]34
[19105]35if ~exist(filename,'file')
36 error(['file ' filename ' does not exist']);
[6265]37end
[19105]38
39string='%TestName:';
40fid=fopen(filename,'r');
41A=fscanf(fid,'%s',3);
42if ~strncmp(A,string,numel(string)) | numel(A)<numel(string)+2,
43 error(['Test file ' filename ' does to start with a test name']);
44end
45name = A(numel(string)+1:end);
46fclose(fid);
Note: See TracBrowser for help on using the repository browser.