dotest.pp 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874
  1. {
  2. This file is part of the Free Pascal test suite.
  3. Copyright (c) 1999-2002 by the Free Pascal development team.
  4. This program makes the compilation and
  5. execution of individual test sources.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$mode objfpc}
  13. {$goto on}
  14. {$H+}
  15. program dotest;
  16. uses
  17. dos,
  18. {$ifdef macos}
  19. macutils,
  20. {$endif}
  21. teststr,
  22. testu,
  23. redir,
  24. bench,
  25. classes;
  26. {$ifdef go32v2}
  27. {$define LIMIT83FS}
  28. {$endif}
  29. {$ifdef os2}
  30. {$define LIMIT83FS}
  31. {$endif}
  32. type
  33. tcompinfo = (compver,comptarget,compcpu);
  34. tdelexecutable = (deBefore, deAfter);
  35. tdelexecutables = set of tdelexecutable;
  36. const
  37. ObjExt='o';
  38. PPUExt='ppu';
  39. {$ifdef UNIX}
  40. SrcExeExt='';
  41. {$else UNIX}
  42. {$ifdef MACOS}
  43. SrcExeExt='';
  44. {$else MACOS}
  45. SrcExeExt='.exe';
  46. {$endif MACOS}
  47. {$endif UNIX}
  48. ExeExt : string = '';
  49. DefaultTimeout=60;
  50. var
  51. Config : TConfig;
  52. CompilerLogFile,
  53. ExeLogFile,
  54. LongLogfile,
  55. FailLogfile,
  56. RTLUnitsDir,
  57. TestOutputDir,
  58. OutputDir : string;
  59. CompilerBin,
  60. { CompilerCPU and CompilerTarget are lowercased at start
  61. to avoid need to call lowercase again and again ... }
  62. CompilerCPU,
  63. CompilerTarget,
  64. CompilerVersion,
  65. DefaultCompilerCPU,
  66. DefaultCompilerTarget,
  67. DefaultCompilerVersion : string;
  68. PPFile : TStringList;
  69. PPFileInfo : TStringList;
  70. TestName : string;
  71. Current : longint;
  72. const
  73. DoGraph : boolean = false;
  74. UseOSOnly : boolean = false;
  75. DoInteractive : boolean = false;
  76. DoExecute : boolean = false;
  77. DoKnown : boolean = false;
  78. DoAll : boolean = false;
  79. DoUsual : boolean = true;
  80. { TargetDir : string = ''; unused }
  81. BenchmarkInfo : boolean = false;
  82. ExtraCompilerOpts : string = '';
  83. DelExecutable : TDelExecutables = [];
  84. RemoteAddr : string = '';
  85. RemotePath : string = '/tmp';
  86. RemotePara : string = '';
  87. RemoteRshParas : string = '';
  88. RemoteShell : string = '';
  89. RemoteShellBase : string = '';
  90. RemoteShellNeedsExport : boolean = false;
  91. rshprog : string = 'rsh';
  92. rcpprog : string = 'rcp';
  93. rquote : char = '''';
  94. UseTimeout : boolean = false;
  95. emulatorname : string = '';
  96. TargetCanCompileLibraries : boolean = true;
  97. { Constants used in IsAbsolute function }
  98. TargetHasDosStyleDirectories : boolean = false;
  99. TargetAmigaLike : boolean = false;
  100. TargetIsMacOS : boolean = false;
  101. TargetIsUnix : boolean = false;
  102. { extracted from rtl/macos/macutils.inc }
  103. function IsMacFullPath (const path: string): Boolean;
  104. begin
  105. if Pos(':', path) = 0 then {its partial}
  106. IsMacFullPath := false
  107. else if path[1] = ':' then
  108. IsMacFullPath := false
  109. else
  110. IsMacFullPath := true
  111. end;
  112. Function IsAbsolute (Const F : String) : boolean;
  113. {
  114. Returns True if the name F is a absolute file name
  115. }
  116. begin
  117. IsAbsolute:=false;
  118. if TargetHasDosStyleDirectories then
  119. begin
  120. if (F[1]='/') or (F[1]='\') then
  121. IsAbsolute:=true;
  122. if (Length(F)>2) and (F[2]=':') and ((F[3]='\') or (F[3]='/')) then
  123. IsAbsolute:=true;
  124. end
  125. else if TargetAmigaLike then
  126. begin
  127. if (length(F)>0) and (Pos(':',F) <> 0) then
  128. IsAbsolute:=true;
  129. end
  130. else if TargetIsMacOS then
  131. begin
  132. IsAbsolute:=IsMacFullPath(F);
  133. end
  134. { generic case }
  135. else if (F[1]='/') then
  136. IsAbsolute:=true;
  137. end;
  138. Function FileExists (Const F : String) : Boolean;
  139. {
  140. Returns True if the file exists, False if not.
  141. }
  142. Var
  143. info : searchrec;
  144. begin
  145. FindFirst (F,anyfile,Info);
  146. FileExists:=DosError=0;
  147. FindClose (Info);
  148. end;
  149. Function PathExists (Const F : String) : Boolean;
  150. {
  151. Returns True if the file exists, False if not.
  152. }
  153. Var
  154. info : searchrec;
  155. begin
  156. FindFirst (F,anyfile,Info);
  157. PathExists:=(DosError=0) and (Info.Attr and Directory=Directory);
  158. FindClose (Info);
  159. end;
  160. function ToStr(l:longint):string;
  161. var
  162. s : string;
  163. begin
  164. Str(l,s);
  165. ToStr:=s;
  166. end;
  167. function ToStrZero(l:longint;nbzero : byte):string;
  168. var
  169. s : string;
  170. begin
  171. Str(l,s);
  172. while length(s)<nbzero do
  173. s:='0'+s;
  174. ToStrZero:=s;
  175. end;
  176. function trimspace(const s:string):string;
  177. var
  178. i,j : longint;
  179. begin
  180. i:=length(s);
  181. while (i>0) and (s[i] in [#9,' ']) do
  182. dec(i);
  183. j:=1;
  184. while (j<i) and (s[j] in [#9,' ']) do
  185. inc(j);
  186. trimspace:=Copy(s,j,i-j+1);
  187. end;
  188. function IsInList(const entry,list:string):boolean;
  189. var
  190. i,istart : longint;
  191. begin
  192. IsInList:=false;
  193. i:=0;
  194. while (i<length(list)) do
  195. begin
  196. { Find list item }
  197. istart:=i+1;
  198. while (i<length(list)) and
  199. (list[i+1]<>',') do
  200. inc(i);
  201. if Upcase(entry)=Upcase(TrimSpace(Copy(list,istart,i-istart+1))) then
  202. begin
  203. IsInList:=true;
  204. exit;
  205. end;
  206. { skip , }
  207. inc(i);
  208. end;
  209. end;
  210. procedure SetPPFileInfo;
  211. Var
  212. info : searchrec;
  213. dt : DateTime;
  214. begin
  215. FindFirst (PPFile[current],anyfile,Info);
  216. If DosError=0 then
  217. begin
  218. UnpackTime(info.time,dt);
  219. PPFileInfo.Insert(current,PPFile[current]+' '+ToStr(dt.year)+'/'+ToStrZero(dt.month,2)+'/'+
  220. ToStrZero(dt.day,2)+' '+ToStrZero(dt.Hour,2)+':'+ToStrZero(dt.min,2)+':'+ToStrZero(dt.sec,2));
  221. end
  222. else
  223. PPFileInfo.Insert(current,PPFile[current]);
  224. FindClose (Info);
  225. end;
  226. function SplitPath(const s:string):string;
  227. var
  228. i : longint;
  229. begin
  230. i:=Length(s);
  231. while (i>0) and not(s[i] in ['/','\'{$IFDEF MACOS},':'{$ENDIF}]) do
  232. dec(i);
  233. SplitPath:=Copy(s,1,i);
  234. end;
  235. Function SplitFileName(const s:string):string;
  236. var
  237. p : dirstr;
  238. n : namestr;
  239. e : extstr;
  240. begin
  241. FSplit(s,p,n,e);
  242. SplitFileName:=n+e;
  243. end;
  244. Function SplitFileBase(const s:string):string;
  245. var
  246. p : dirstr;
  247. n : namestr;
  248. e : extstr;
  249. begin
  250. FSplit(s,p,n,e);
  251. SplitFileBase:=n;
  252. end;
  253. function ForceExtension(Const HStr,ext:String):String;
  254. {
  255. Return a filename which certainly has the extension ext
  256. }
  257. var
  258. j : longint;
  259. begin
  260. j:=length(Hstr);
  261. while (j>0) and (Hstr[j]<>'.') do
  262. dec(j);
  263. if j=0 then
  264. j:=length(Hstr)+1;
  265. if Ext<>'' then
  266. begin
  267. if Ext[1]='.' then
  268. ForceExtension:=Copy(Hstr,1,j-1)+Ext
  269. else
  270. ForceExtension:=Copy(Hstr,1,j-1)+'.'+Ext
  271. end
  272. else
  273. ForceExtension:=Copy(Hstr,1,j-1);
  274. end;
  275. procedure mkdirtree(const s:string);
  276. var
  277. hs : string;
  278. begin
  279. if s='' then
  280. exit;
  281. if s[length(s)] in ['\','/'{$IFDEF MACOS},':'{$ENDIF}] then
  282. hs:=Copy(s,1,length(s)-1)
  283. else
  284. hs:=s;
  285. if not PathExists(hs) then
  286. begin
  287. { Try parent first }
  288. mkdirtree(SplitPath(hs));
  289. { make this dir }
  290. Verbose(V_Debug,'Making Directory '+s);
  291. {$I-}
  292. mkdir(s);
  293. {$I+}
  294. ioresult;
  295. end;
  296. end;
  297. Function RemoveFile(const f:string):boolean;
  298. var
  299. g : file;
  300. begin
  301. assign(g,f);
  302. {$I-}
  303. erase(g);
  304. {$I+}
  305. RemoveFile:=(ioresult=0);
  306. end;
  307. function Copyfile(const fn1,fn2:string;append:boolean) : longint;
  308. const
  309. bufsize = 16384;
  310. var
  311. f,g : file;
  312. addsize,
  313. i : longint;
  314. buf : pointer;
  315. begin
  316. if Append then
  317. Verbose(V_Debug,'Appending '+fn1+' to '+fn2)
  318. else
  319. Verbose(V_Debug,'Copying '+fn1+' to '+fn2);
  320. assign(f,fn1);
  321. assign(g,fn2);
  322. {$I-}
  323. reset(f,1);
  324. {$I+}
  325. addsize:=0;
  326. if ioresult<>0 then
  327. Verbose(V_Error,'Can''t open '+fn1);
  328. if append then
  329. begin
  330. {$I-}
  331. reset(g,1);
  332. {$I+}
  333. if ioresult<>0 then
  334. append:=false
  335. else
  336. seek(g,filesize(g));
  337. end;
  338. if not append then
  339. begin
  340. {$I-}
  341. rewrite(g,1);
  342. {$I+}
  343. if ioresult<>0 then
  344. Verbose(V_Error,'Can''t open '+fn2+' for output');
  345. end;
  346. getmem(buf,bufsize);
  347. repeat
  348. blockread(f,buf^,bufsize,i);
  349. blockwrite(g,buf^,i);
  350. addsize:=addsize+i;
  351. until i<bufsize;
  352. freemem(buf,bufsize);
  353. close(f);
  354. close(g);
  355. CopyFile:=addsize;
  356. end;
  357. procedure AddLog(const logfile,s:string);
  358. var
  359. t : text;
  360. begin
  361. assign(t,logfile);
  362. {$I-}
  363. append(t);
  364. {$I+}
  365. if ioresult<>0 then
  366. begin
  367. {$I-}
  368. rewrite(t);
  369. {$I+}
  370. if ioresult<>0 then
  371. Verbose(V_Abort,'Can''t append to '+logfile);
  372. end;
  373. writeln(t,s);
  374. close(t);
  375. end;
  376. function GetCompilerInfo(c:tcompinfo):boolean;
  377. function GetToken(var s:string):string;
  378. var
  379. i : longint;
  380. begin
  381. i:=pos(' ',s);
  382. if i=0 then
  383. i:=length(s)+1;
  384. GetToken:=Copy(s,1,i-1);
  385. Delete(s,1,i);
  386. end;
  387. var
  388. t : text;
  389. hs : string;
  390. begin
  391. GetCompilerInfo:=false;
  392. { Try to get all information in one call, this is
  393. supported in 1.1. Older compilers 1.0.x will only
  394. return the first info }
  395. case c of
  396. compver :
  397. begin
  398. if DefaultCompilerVersion<>'' then
  399. begin
  400. GetCompilerInfo:=true;
  401. exit;
  402. end;
  403. hs:='-iVTPTO';
  404. end;
  405. compcpu :
  406. begin
  407. if DefaultCompilerCPU<>'' then
  408. begin
  409. GetCompilerInfo:=true;
  410. exit;
  411. end;
  412. hs:='-iTPTOV';
  413. end;
  414. comptarget :
  415. begin
  416. if DefaultCompilerTarget<>'' then
  417. begin
  418. GetCompilerInfo:=true;
  419. exit;
  420. end;
  421. hs:='-iTOTPV';
  422. end;
  423. end;
  424. ExecuteRedir(CompilerBin,hs,'','out','');
  425. assign(t,'out');
  426. {$I-}
  427. reset(t);
  428. readln(t,hs);
  429. close(t);
  430. erase(t);
  431. {$I+}
  432. if ioresult<>0 then
  433. Verbose(V_Error,'Can''t get Compiler Info')
  434. else
  435. begin
  436. Verbose(V_Debug,'Retrieved Compiler Info: "'+hs+'"');
  437. case c of
  438. compver :
  439. begin
  440. DefaultCompilerVersion:=GetToken(hs);
  441. DefaultCompilerCPU:=GetToken(hs);
  442. DefaultCompilerTarget:=GetToken(hs);
  443. end;
  444. compcpu :
  445. begin
  446. DefaultCompilerCPU:=GetToken(hs);
  447. DefaultCompilerTarget:=GetToken(hs);
  448. DefaultCompilerVersion:=GetToken(hs);
  449. end;
  450. comptarget :
  451. begin
  452. DefaultCompilerTarget:=GetToken(hs);
  453. DefaultCompilerCPU:=GetToken(hs);
  454. DefaultCompilerVersion:=GetToken(hs);
  455. end;
  456. end;
  457. GetCompilerInfo:=true;
  458. end;
  459. end;
  460. function GetCompilerVersion:boolean;
  461. const
  462. CompilerVersionDebugWritten : boolean = false;
  463. begin
  464. if CompilerVersion='' then
  465. begin
  466. GetCompilerVersion:=GetCompilerInfo(compver);
  467. CompilerVersion:=DefaultCompilerVersion;
  468. end
  469. else
  470. GetCompilerVersion:=true;
  471. if GetCompilerVersion and not CompilerVersionDebugWritten then
  472. begin
  473. Verbose(V_Debug,'Compiler Version: "'+CompilerVersion+'"');
  474. CompilerVersionDebugWritten:=true;
  475. end;
  476. end;
  477. function GetCompilerCPU:boolean;
  478. const
  479. CompilerCPUDebugWritten : boolean = false;
  480. begin
  481. if CompilerCPU='' then
  482. begin
  483. GetCompilerCPU:=GetCompilerInfo(compcpu);
  484. CompilerCPU:=lowercase(DefaultCompilerCPU);
  485. end
  486. else
  487. GetCompilerCPU:=true;
  488. if GetCompilerCPU and not CompilerCPUDebugWritten then
  489. begin
  490. Verbose(V_Debug,'Compiler CPU: "'+CompilerCPU+'"');
  491. CompilerCPUDebugWritten:=true;
  492. end;
  493. end;
  494. function GetCompilerTarget:boolean;
  495. const
  496. CompilerTargetDebugWritten : boolean = false;
  497. begin
  498. if CompilerTarget='' then
  499. begin
  500. GetCompilerTarget:=GetCompilerInfo(comptarget);
  501. CompilerTarget:=lowercase(DefaultCompilerTarget);
  502. end
  503. else
  504. GetCompilerTarget:=true;
  505. if GetCompilerTarget and not CompilerTargetDebugWritten then
  506. begin
  507. Verbose(V_Debug,'Compiler Target: "'+CompilerTarget+'"');
  508. CompilerTargetDebugWritten:=true;
  509. end;
  510. end;
  511. function CompilerFullTarget:string;
  512. begin
  513. if UseOSOnly then
  514. CompilerFullTarget:=CompilerTarget
  515. else
  516. CompilerFullTarget:=CompilerCPU+'-'+CompilerTarget;
  517. end;
  518. { Set the three constants above according to
  519. the current target }
  520. procedure SetTargetDirectoriesStyle;
  521. var
  522. LTarget : string;
  523. res : boolean;
  524. begin
  525. { Call this first to ensure that CompilerTarget is not empty }
  526. res:=GetCompilerTarget;
  527. LTarget := CompilerTarget;
  528. TargetHasDosStyleDirectories :=
  529. (LTarget='emx') or
  530. (LTarget='go32v2') or
  531. (LTarget='nativent') or
  532. (LTarget='os2') or
  533. (LTarget='symbian') or
  534. (LTarget='watcom') or
  535. (LTarget='wdosx') or
  536. (LTarget='win32') or
  537. (LTarget='win64');
  538. TargetAmigaLike:=
  539. (LTarget='amiga') or
  540. (LTarget='morphos');
  541. TargetIsMacOS:=
  542. (LTarget='macos');
  543. { Base on whether UNIX is defined as default macro
  544. in extradefines in systesms/i_XXX.pas units }
  545. TargetIsUnix:=
  546. (LTarget='linux') or
  547. (LTarget='linux6432') or
  548. (LTarget='freebsd') or
  549. (LTarget='openbsd') or
  550. (LTarget='netbsd') or
  551. (LTarget='beos') or
  552. (LTarget='haiku') or
  553. (LTarget='solaris') or
  554. (LTarget='iphonesim') or
  555. (LTarget='darwin');
  556. { Set ExeExt for CompilerTarget.
  557. This list has been set up 2011-06 using the information in
  558. compiler/system/i_XXX.pas units.
  559. We should update this list when adding new targets PM }
  560. if (TargetHasDosStyleDirectories) then
  561. ExeExt:='.exe'
  562. else if LTarget='atari' then
  563. ExeExt:='.tpp'
  564. else if LTarget='gba' then
  565. ExeExt:='.gba'
  566. else if LTarget='nds' then
  567. ExeExt:='.bin'
  568. else if (LTarget='netware') or (LTarget='netwlibc') then
  569. ExeExt:='.nlm'
  570. else if LTarget='wii' then
  571. ExeExt:='.dol'
  572. else if LTarget='wince' then
  573. ExeExt:='.exe';
  574. end;
  575. {$ifndef LIMIT83FS}
  576. { Set the UseOSOnly constant above according to
  577. the current target }
  578. procedure SetUseOSOnly;
  579. var
  580. LTarget : string;
  581. res : boolean;
  582. begin
  583. { Call this first to ensure that CompilerTarget is not empty }
  584. res:=GetCompilerTarget;
  585. LTarget := CompilerTarget;
  586. UseOSOnly:= (LTarget='emx') or
  587. (LTarget='go32v2') or
  588. (LTarget='os2');
  589. end;
  590. {$endif not LIMIT83FS}
  591. procedure SetTargetCanCompileLibraries;
  592. var
  593. LTarget : string;
  594. res : boolean;
  595. begin
  596. { Call this first to ensure that CompilerTarget is not empty }
  597. res:=GetCompilerTarget;
  598. LTarget := CompilerTarget;
  599. { Feel free to add other targets here }
  600. if (LTarget='go32v2') then
  601. TargetCanCompileLibraries:=false;
  602. end;
  603. function OutputFileName(Const s,ext:String):String;
  604. begin
  605. {$ifndef macos}
  606. OutputFileName:=OutputDir+'/'+ForceExtension(s,ext);
  607. {$else macos}
  608. OutputFileName:=ConcatMacPath(OutputDir,ForceExtension(s,ext));
  609. {$endif macos}
  610. end;
  611. function TestOutputFileName(Const pref,base,ext:String):String;
  612. begin
  613. {$ifndef macos}
  614. TestOutputFileName:=TestOutputDir+'/'+ForceExtension(pref+SplitFileName(base),ext);
  615. {$else macos}
  616. TestOutputFileName:=ConcatMacPath(TestOutputDir,ForceExtension(pref+SplitFileName(base),ext));
  617. {$endif macos}
  618. end;
  619. function ExitWithInternalError(const OutName:string):boolean;
  620. var
  621. t : text;
  622. s : string;
  623. begin
  624. ExitWithInternalError:=false;
  625. { open logfile }
  626. assign(t,Outname);
  627. {$I-}
  628. reset(t);
  629. {$I+}
  630. if ioresult<>0 then
  631. exit;
  632. while not eof(t) do
  633. begin
  634. readln(t,s);
  635. if pos('Fatal: Internal error ',s)>0 then
  636. begin
  637. ExitWithInternalError:=true;
  638. break;
  639. end;
  640. end;
  641. close(t);
  642. end;
  643. { Takes each option from AddOptions list
  644. considered as a space separated list
  645. and adds the option to args
  646. unless option contains a percent sign,
  647. in that case, the option after % will be added
  648. to args only if CompilerTarget is listed in
  649. the string part before %.
  650. NOTE: this function does not check for
  651. quoted options...
  652. The list before % must of course contain no spaces. }
  653. procedure AppendOptions(AddOptions : string;var args : string);
  654. var
  655. endopt,percentpos : longint;
  656. opttarget, currentopt : string;
  657. begin
  658. Verbose(V_Debug,'AppendOptions called with AddOptions="'+AddOptions+'"');
  659. AddOptions:=trimspace(AddOptions);
  660. repeat
  661. endopt:=pos(' ',AddOptions);
  662. if endopt=0 then
  663. endopt:=length(AddOptions);
  664. currentopt:=trimspace(copy(AddOptions,1,endopt));
  665. AddOptions:=trimspace(copy(Addoptions,endopt+1,length(AddOptions)));
  666. if currentopt<>'' then
  667. begin
  668. percentpos:=pos('%',currentopt);
  669. if (percentpos=0) then
  670. begin
  671. Verbose(V_Debug,'Adding option="'+currentopt+'"');
  672. args:=args+' '+currentopt;
  673. end
  674. else
  675. begin
  676. opttarget:=lowercase(copy(currentopt,1,percentpos-1));
  677. if IsInList(CompilerTarget, opttarget) then
  678. begin
  679. Verbose(V_Debug,'Adding target specific option="'+currentopt+'" for '+opttarget);
  680. args:=args+' '+copy(currentopt,percentpos+1,length(currentopt))
  681. end
  682. else
  683. Verbose(V_Debug,'No matching target "'+currentopt+'"');
  684. end;
  685. end;
  686. until AddOptions='';
  687. end;
  688. { This function removes some incompatible
  689. options from TEST_OPT before adding them to
  690. the list of options passed to the compiler.
  691. %DELOPT=XYZ will remove XYZ exactly
  692. %DELOPT=XYZ* will remove all options starting with XYZ.
  693. NOTE: This fuinction does not handle quoted options. }
  694. function DelOptions(Pattern, opts : string) : string;
  695. var
  696. currentopt : string;
  697. optpos, endopt, startpos, endpos : longint;
  698. iswild : boolean;
  699. begin
  700. opts:=trimspace(opts);
  701. pattern:=trimspace(pattern);
  702. repeat
  703. endpos:=pos(' ',pattern);
  704. if endpos=0 then
  705. endpos:=length(pattern);
  706. currentopt:=trimspace(copy(pattern,1,endpos));
  707. pattern:=trimspace(copy(pattern,endpos+1,length(pattern)));
  708. if currentopt<>'' then
  709. begin
  710. if currentopt[length(currentopt)]='*' then
  711. begin
  712. iswild:=true;
  713. system.delete(currentopt,length(currentopt),1);
  714. end
  715. else
  716. iswild:=false;
  717. startpos:=1;
  718. repeat
  719. optpos:=pos(currentopt,copy(opts,startpos,length(opts)));
  720. if optpos>0 then
  721. begin
  722. { move to index in full opts string }
  723. optpos:=optpos+startpos-1;
  724. { compute position of end of opt }
  725. endopt:=optpos+length(currentopt);
  726. { use that end as start position for next round }
  727. startpos:=endopt;
  728. if iswild then
  729. begin
  730. while (opts[endopt]<>' ') and
  731. (endopt<length(opts)) do
  732. begin
  733. inc(endopt);
  734. inc(startpos);
  735. end;
  736. Verbose(V_Debug,'Pattern match found "'+currentopt+'*" in "'+opts+'"');
  737. system.delete(opts,optpos,endopt-optpos+1);
  738. Verbose(V_Debug,'After opts="'+opts+'"');
  739. end
  740. else
  741. begin
  742. if (endopt>length(opts)) or (opts[endopt]=' ') then
  743. begin
  744. Verbose(V_Debug,'Exact match found "'+currentopt+'" in "'+opts+'"');
  745. system.delete(opts,optpos,endopt-optpos+1);
  746. Verbose(V_Debug,'After opts="'+opts+'"');
  747. end
  748. else
  749. begin
  750. Verbose(V_Debug,'No exact match "'+currentopt+'" in "'+opts+'"');
  751. end;
  752. end;
  753. end;
  754. until optpos=0;
  755. end;
  756. until pattern='';
  757. DelOptions:=opts;
  758. end;
  759. function RunCompiler:boolean;
  760. var
  761. args,LocalExtraArgs,
  762. wpoargs : string;
  763. passnr,
  764. passes : longint;
  765. execres : boolean;
  766. EndTicks,
  767. StartTicks : int64;
  768. begin
  769. RunCompiler:=false;
  770. args:='-n -T'+CompilerTarget+' -Fu'+RTLUnitsDir;
  771. args:=args+' -FE'+TestOutputDir;
  772. if TargetIsMacOS then
  773. args:=args+' -WT '; {tests should be compiled as MPWTool}
  774. if Config.DelOptions<>'' then
  775. LocalExtraArgs:=DelOptions(Config.DelOptions,ExtraCompilerOpts)
  776. else
  777. LocalExtraArgs:=ExtraCompilerOpts;
  778. if LocalExtraArgs<>'' then
  779. args:=args+' '+LocalExtraArgs;
  780. if TargetIsUnix then
  781. begin
  782. { Add runtime library path to current dir to find .so files }
  783. if Config.NeedLibrary then
  784. begin
  785. if CompilerTarget<>'darwin' then
  786. { do not use single quote for -k as they are mishandled on
  787. Windows Shells }
  788. args:=args+' -Fl'+TestOutputDir+' -k-rpath -k.'
  789. else
  790. args:=args+' -Fl'+TestOutputDir;
  791. end;
  792. end;
  793. if Config.NeedOptions<>'' then
  794. AppendOptions(Config.NeedOptions,args);
  795. wpoargs:='';
  796. if (Config.WpoPasses=0) or
  797. (Config.WpoParas='') then
  798. passes:=1
  799. else
  800. passes:=config.wpopasses+1;
  801. args:=args+' '+PPFile[current];
  802. for passnr:=1 to passes do
  803. begin
  804. if (passes>1) then
  805. begin
  806. wpoargs:=' -OW'+config.wpoparas+' -FW'+TestOutputFileName('',PPFile[current],'wp'+tostr(passnr));
  807. if (passnr>1) then
  808. wpoargs:=wpoargs+' -Ow'+config.wpoparas+' -Fw'+TestOutputFileName('',PPFile[current],'wp'+tostr(passnr-1));
  809. end;
  810. Verbose(V_Debug,'Executing '+compilerbin+' '+args+wpoargs);
  811. { also get the output from as and ld that writes to stderr sometimes }
  812. StartTicks:=GetMicroSTicks;
  813. {$ifndef macos}
  814. execres:=ExecuteRedir(CompilerBin,args+wpoargs,'',CompilerLogFile,'stdout');
  815. {$else macos}
  816. {Due to that Toolserver is not reentrant, we have to asm and link via script.}
  817. execres:=ExecuteRedir(CompilerBin,'-s '+args+wpoargs,'',CompilerLogFile,'stdout');
  818. if execres then
  819. execres:=ExecuteRedir(TestOutputDir + ':ppas','','',CompilerLogFile,'stdout');
  820. {$endif macos}
  821. EndTicks:=GetMicroSTicks;
  822. Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
  823. if BenchmarkInfo then
  824. begin
  825. Verbose(V_Normal,'Compilation took '+ToStr(EndTicks-StartTicks)+' us');
  826. end;
  827. { Error during execution? }
  828. if (not execres) and (ExecuteResult=0) then
  829. begin
  830. AddLog(FailLogFile,TestName);
  831. AddLog(ResLogFile,failed_to_compile+PPFileInfo[current]);
  832. AddLog(LongLogFile,line_separation);
  833. AddLog(LongLogFile,failed_to_compile+PPFileInfo[current]);
  834. if CopyFile(CompilerLogFile,LongLogFile,true)=0 then
  835. AddLog(LongLogFile,'IOStatus'+ToStr(IOStatus));
  836. { avoid to try again }
  837. AddLog(ExeLogFile,failed_to_compile+PPFileInfo[current]);
  838. Verbose(V_Warning,'IOStatus: '+ToStr(IOStatus));
  839. exit;
  840. end;
  841. { Check for internal error }
  842. if ExitWithInternalError(CompilerLogFile) then
  843. begin
  844. AddLog(FailLogFile,TestName);
  845. if Config.Note<>'' then
  846. AddLog(FailLogFile,Config.Note);
  847. AddLog(ResLogFile,failed_to_compile+PPFileInfo[current]+' internalerror generated');
  848. AddLog(LongLogFile,line_separation);
  849. AddLog(LongLogFile,failed_to_compile+PPFileInfo[current]);
  850. if Config.Note<>'' then
  851. AddLog(LongLogFile,Config.Note);
  852. if CopyFile(CompilerLogFile,LongLogFile,true)=0 then
  853. AddLog(LongLogFile,'Internal error in compiler');
  854. { avoid to try again }
  855. AddLog(ExeLogFile,failed_to_compile+PPFileInfo[current]);
  856. Verbose(V_Warning,'Internal error in compiler');
  857. exit;
  858. end;
  859. end;
  860. { Should the compile fail ? }
  861. if Config.ShouldFail then
  862. begin
  863. if ExecuteResult<>0 then
  864. begin
  865. AddLog(ResLogFile,success_compilation_failed+PPFileInfo[current]);
  866. { avoid to try again }
  867. AddLog(ExeLogFile,success_compilation_failed+PPFileInfo[current]);
  868. RunCompiler:=true;
  869. end
  870. else
  871. begin
  872. AddLog(FailLogFile,TestName);
  873. if Config.Note<>'' then
  874. AddLog(FailLogFile,Config.Note);
  875. AddLog(ResLogFile,failed_compilation_successful+PPFileInfo[current]);
  876. AddLog(LongLogFile,line_separation);
  877. AddLog(LongLogFile,failed_compilation_successful+PPFileInfo[current]);
  878. { avoid to try again }
  879. AddLog(ExeLogFile,failed_compilation_successful+PPFileInfo[current]);
  880. if Config.Note<>'' then
  881. AddLog(LongLogFile,Config.Note);
  882. CopyFile(CompilerLogFile,LongLogFile,true);
  883. end;
  884. end
  885. else
  886. begin
  887. if (ExecuteResult<>0) and
  888. (((Config.KnownCompileNote<>'') and (Config.KnownCompileError=0)) or
  889. ((Config.KnownCompileError<>0) and (ExecuteResult=Config.KnownCompileError))) then
  890. begin
  891. AddLog(FailLogFile,TestName+known_problem+Config.KnownCompileNote);
  892. AddLog(ResLogFile,failed_to_compile+PPFileInfo[current]+known_problem+Config.KnownCompileNote);
  893. AddLog(LongLogFile,line_separation);
  894. AddLog(LongLogFile,known_problem+Config.KnownCompileNote);
  895. AddLog(LongLogFile,failed_to_compile+PPFileInfo[current]+' ('+ToStr(ExecuteResult)+')');
  896. if Copyfile(CompilerLogFile,LongLogFile,true)=0 then
  897. AddLog(LongLogFile,known_problem+'exitcode: '+ToStr(ExecuteResult));
  898. Verbose(V_Warning,known_problem+'exitcode: '+ToStr(ExecuteResult));
  899. end
  900. else if ExecuteResult<>0 then
  901. begin
  902. AddLog(FailLogFile,TestName);
  903. if Config.Note<>'' then
  904. AddLog(FailLogFile,Config.Note);
  905. AddLog(ResLogFile,failed_to_compile+PPFileInfo[current]);
  906. AddLog(LongLogFile,line_separation);
  907. AddLog(LongLogFile,failed_to_compile+PPFileInfo[current]);
  908. if Config.Note<>'' then
  909. AddLog(LongLogFile,Config.Note);
  910. if CopyFile(CompilerLogFile,LongLogFile,true)=0 then
  911. AddLog(LongLogFile,'Exitcode: '+ToStr(ExecuteResult)+' (expected 0)');
  912. { avoid to try again }
  913. AddLog(ExeLogFile,failed_to_compile+PPFileInfo[current]);
  914. Verbose(V_Warning,'Exitcode: '+ToStr(ExecuteResult)+' (expected 0)');
  915. end
  916. else
  917. begin
  918. AddLog(ResLogFile,successfully_compiled+PPFileInfo[current]);
  919. RunCompiler:=true;
  920. end;
  921. end;
  922. end;
  923. function CheckTestExitCode(const OutName:string):boolean;
  924. var
  925. t : text;
  926. s : string;
  927. i,code : integer;
  928. begin
  929. CheckTestExitCode:=false;
  930. { open logfile }
  931. assign(t,Outname);
  932. {$I-}
  933. reset(t);
  934. {$I+}
  935. if ioresult<>0 then
  936. exit;
  937. while not eof(t) do
  938. begin
  939. readln(t,s);
  940. i:=pos('TestExitCode: ',s);
  941. if i>0 then
  942. begin
  943. delete(s,1,i+14-1);
  944. val(s,ExecuteResult,code);
  945. if code=0 then
  946. CheckTestExitCode:=true;
  947. break;
  948. end;
  949. end;
  950. close(t);
  951. end;
  952. function LibraryExists(const PPFile : string; out FileName : string) : boolean;
  953. begin
  954. { Check if a dynamic library XXX was created }
  955. { Windows XXX.dll style }
  956. FileName:=TestOutputFilename('',PPFile,'dll');
  957. if FileExists(FileName) then
  958. begin
  959. LibraryExists:=true;
  960. exit;
  961. end;
  962. { Linux libXXX.so style }
  963. FileName:=TestOutputFilename('lib',PPFile,'so');
  964. if FileExists(FileName) then
  965. begin
  966. LibraryExists:=true;
  967. exit;
  968. end;
  969. { Darwin libXXX.dylib style }
  970. FileName:=TestOutputFilename('lib',PPFile,'dylib');
  971. if FileExists(FileName) then
  972. begin
  973. LibraryExists:=true;
  974. exit;
  975. end;
  976. { MacOS LibXXX style }
  977. FileName:=TestOutputFilename('Lib',PPFile,'');
  978. if FileExists(FileName) then
  979. begin
  980. LibraryExists:=true;
  981. exit;
  982. end;
  983. { Netware wlic XXX.nlm style }
  984. FileName:=TestOutputFilename('',PPFile,'nlm');
  985. if FileExists(FileName) then
  986. begin
  987. LibraryExists:=true;
  988. exit;
  989. end;
  990. { Amiga XXX.library style }
  991. FileName:=TestOutputFilename('',PPFile,'library');
  992. if FileExists(FileName) then
  993. begin
  994. LibraryExists:=true;
  995. exit;
  996. end;
  997. LibraryExists:=false;
  998. end;
  999. function ExecuteRemote(const prog,args:string;out StartTicks,EndTicks : int64):boolean;
  1000. const
  1001. MaxTrials = 5;
  1002. var
  1003. Trials : longint;
  1004. Res : boolean;
  1005. begin
  1006. Verbose(V_Debug,'RemoteExecuting '+Prog+' '+args);
  1007. StartTicks:=GetMicroSTicks;
  1008. Res:=false;
  1009. Trials:=0;
  1010. While (Trials<MaxTrials) and not Res do
  1011. begin
  1012. inc(Trials);
  1013. Res:=ExecuteRedir(prog,args,'',EXELogFile,'stdout');
  1014. if not Res then
  1015. Verbose(V_Debug,'Call to '+prog+' failed: '+
  1016. 'IOStatus='+ToStr(IOStatus)+
  1017. ' RedirErrorOut='+ToStr(RedirErrorOut)+
  1018. ' RedirErrorIn='+ToStr(RedirErrorIn)+
  1019. ' RedirErrorError='+ToStr(RedirErrorError)+
  1020. ' ExecuteResult='+ToStr(ExecuteResult));
  1021. end;
  1022. if Trials>1 then
  1023. Verbose(V_Debug,'Done in '+tostr(trials)+' trials');
  1024. EndTicks:=GetMicroSTicks;
  1025. ExecuteRemote:=res;
  1026. end;
  1027. function ExecuteEmulated(const prog,args,FullExeLogFile:string;out StartTicks,EndTicks : int64):boolean;
  1028. begin
  1029. Verbose(V_Debug,'EmulatorExecuting '+Prog+' '+args);
  1030. StartTicks:=GetMicroSTicks;
  1031. ExecuteEmulated:=ExecuteRedir(prog,args,'',FullExeLogFile,'stdout');
  1032. EndTicks:=GetMicroSTicks;
  1033. end;
  1034. function MaybeCopyFiles(const FileToCopy : string) : boolean;
  1035. var
  1036. TestRemoteExe,
  1037. s : string;
  1038. pref : string;
  1039. LocalFile, RemoteFile: string;
  1040. LocalPath: string;
  1041. index : integer;
  1042. execres : boolean;
  1043. EndTicks,
  1044. StartTicks : int64;
  1045. begin
  1046. if RemoteAddr='' then
  1047. begin
  1048. exit(false);
  1049. end;
  1050. execres:=true;
  1051. { We don't want to create subdirs, remove paths from the test }
  1052. TestRemoteExe:=RemotePath+'/'+SplitFileName(FileToCopy);
  1053. if deBefore in DelExecutable then
  1054. ExecuteRemote(rshprog,RemoteRshParas+' rm -f '+TestRemoteExe,
  1055. StartTicks,EndTicks);
  1056. execres:=ExecuteRemote(rcpprog,RemotePara+' '+FileToCopy+' '+
  1057. RemoteAddr+':'+TestRemoteExe,StartTicks,EndTicks);
  1058. if not execres then
  1059. begin
  1060. Verbose(V_normal, 'Could not copy executable '+FileToCopy);
  1061. exit(execres);
  1062. end;
  1063. s:=Config.Files;
  1064. if length(s) > 0 then
  1065. begin
  1066. LocalPath:=SplitPath(PPFile[current]);
  1067. if Length(LocalPath) > 0 then
  1068. LocalPath:=LocalPath+'/';
  1069. repeat
  1070. index:=pos(' ',s);
  1071. if index=0 then
  1072. LocalFile:=s
  1073. else
  1074. LocalFile:=copy(s,1,index-1);
  1075. RemoteFile:=RemotePath+'/'+SplitFileName(LocalFile);
  1076. LocalFile:=LocalPath+LocalFile;
  1077. if DoVerbose and (rcpprog='pscp') then
  1078. pref:='-v '
  1079. else
  1080. pref:='';
  1081. execres:=ExecuteRemote(rcpprog,pref+RemotePara+' '+LocalFile+' '+
  1082. RemoteAddr+':'+RemoteFile,StartTicks,EndTicks);
  1083. if not execres then
  1084. begin
  1085. Verbose(V_normal, 'Could not copy required file '+LocalFile);
  1086. exit(false);
  1087. end;
  1088. if index=0 then
  1089. break;
  1090. s:=copy(s,index+1,length(s)-index);
  1091. until false;
  1092. end;
  1093. MaybeCopyFiles:=execres;
  1094. end;
  1095. function RunExecutable:boolean;
  1096. const
  1097. {$ifdef unix}
  1098. CurrDir = './';
  1099. {$else}
  1100. CurrDir = '';
  1101. {$endif}
  1102. var
  1103. OldDir, s,
  1104. execcmd,
  1105. FullExeLogFile,
  1106. TestRemoteExe,
  1107. TestExe : string;
  1108. execres : boolean;
  1109. EndTicks,
  1110. StartTicks : int64;
  1111. begin
  1112. RunExecutable:=false;
  1113. execres:=true;
  1114. TestExe:=OutputFileName(PPFile[current],ExeExt);
  1115. if EmulatorName<>'' then
  1116. begin
  1117. { Get full name out log file, because we change the directory during
  1118. execution }
  1119. FullExeLogFile:=FExpand(EXELogFile);
  1120. {$I-}
  1121. GetDir(0,OldDir);
  1122. ChDir(TestOutputDir);
  1123. {$I+}
  1124. ioresult;
  1125. s:=CurrDir+SplitFileName(TestExe);
  1126. execres:=ExecuteEmulated(EmulatorName,s,FullExeLogFile,StartTicks,EndTicks);
  1127. {$I-}
  1128. ChDir(OldDir);
  1129. {$I+}
  1130. end
  1131. else if RemoteAddr<>'' then
  1132. begin
  1133. execres:=MaybeCopyFiles(TestExe);
  1134. TestRemoteExe:=RemotePath+'/'+SplitFileName(TestExe);
  1135. { rsh doesn't pass the exitcode, use a second command to print the exitcode
  1136. on the remoteshell to stdout }
  1137. if DoVerbose and (rshprog='plink') then
  1138. execcmd:='-v '+RemoteRshParas
  1139. else
  1140. execcmd:=RemoteRshParas;
  1141. execcmd:=execcmd+' '+rquote+
  1142. 'chmod 755 '+TestRemoteExe+
  1143. ' ; cd '+RemotePath+' ; ';
  1144. { Using -rpath . at compile time does not seem
  1145. to work for programs copied over to remote machine,
  1146. at least not for FreeBSD.
  1147. Does this work for all shells? }
  1148. if Config.NeedLibrary then
  1149. begin
  1150. if RemoteShellNeedsExport then
  1151. execcmd:=execcmd+' LD_LIBRARY_PATH=.; export LD_LIBRARY_PATH;'
  1152. else
  1153. execcmd:=execcmd+' setenv LD_LIBRARY_PATH=.; ';
  1154. end;
  1155. if UseTimeout then
  1156. begin
  1157. if Config.Timeout=0 then
  1158. Config.Timeout:=DefaultTimeout;
  1159. str(Config.Timeout,s);
  1160. if (RemoteShellBase='bash') then
  1161. execcmd:=execcmd+'ulimit -t '+s+'; '
  1162. else
  1163. execcmd:=execcmd+'timeout -9 '+s;
  1164. end;
  1165. { as we moved to RemotePath, if path is not absolute
  1166. we need to use ./execfilename only }
  1167. if not isabsolute(TestRemoteExe) then
  1168. execcmd:=execcmd+' ./'+SplitFileName(TestRemoteExe)
  1169. else
  1170. execcmd:=execcmd+' '+TestRemoteExe;
  1171. execcmd:=execcmd+' ; echo "TestExitCode: $?"';
  1172. if (deAfter in DelExecutable) and
  1173. not Config.NeededAfter then
  1174. execcmd:=execcmd+' ; rm -f '+SplitFileName(TestRemoteExe);
  1175. execcmd:=execcmd+rquote;
  1176. execres:=ExecuteRemote(rshprog,execcmd,StartTicks,EndTicks);
  1177. { Check for TestExitCode error in output, sets ExecuteResult }
  1178. if not CheckTestExitCode(EXELogFile) then
  1179. Verbose(V_Debug,'Failed to check exit code for '+execcmd);
  1180. end
  1181. else
  1182. begin
  1183. { Get full name out log file, because we change the directory during
  1184. execution }
  1185. FullExeLogFile:=FExpand(EXELogFile);
  1186. Verbose(V_Debug,'Executing '+TestExe);
  1187. {$I-}
  1188. GetDir(0,OldDir);
  1189. ChDir(TestOutputDir);
  1190. {$I+}
  1191. ioresult;
  1192. { don't redirect interactive and graph programs }
  1193. StartTicks:=GetMicroSTicks;
  1194. if Config.IsInteractive or Config.UsesGraph then
  1195. execres:=ExecuteRedir(CurrDir+SplitFileName(TestExe),'','','','')
  1196. else
  1197. execres:=ExecuteRedir(CurrDir+SplitFileName(TestExe),'','',FullExeLogFile,'stdout');
  1198. EndTicks:=GetMicroSTicks;
  1199. {$I-}
  1200. ChDir(OldDir);
  1201. {$I+}
  1202. ioresult;
  1203. end;
  1204. { Error during execution? }
  1205. Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
  1206. if BenchmarkInfo then
  1207. begin
  1208. Verbose(V_Normal,'Execution took '+ToStr(EndTicks-StartTicks)+' us');
  1209. end;
  1210. if (not execres) and (ExecuteResult=0) then
  1211. begin
  1212. AddLog(FailLogFile,TestName);
  1213. AddLog(ResLogFile,failed_to_run+PPFileInfo[current]);
  1214. AddLog(LongLogFile,line_separation);
  1215. AddLog(LongLogFile,failed_to_run+PPFileInfo[current]);
  1216. if CopyFile(EXELogFile,LongLogFile,true)=0 then
  1217. AddLog(LongLogFile,'IOStatus: '+ToStr(IOStatus));
  1218. { avoid to try again }
  1219. AddLog(ExeLogFile,failed_to_run+PPFileInfo[current]);
  1220. Verbose(V_Warning,'IOStatus: '+ToStr(IOStatus));
  1221. exit;
  1222. end;
  1223. if ExecuteResult<>Config.ResultCode then
  1224. begin
  1225. if (ExecuteResult<>0) and
  1226. (ExecuteResult=Config.KnownRunError) then
  1227. begin
  1228. AddLog(FailLogFile,TestName+known_problem+Config.KnownRunNote);
  1229. AddLog(ResLogFile,failed_to_run+PPFileInfo[current]+known_problem+Config.KnownRunNote);
  1230. AddLog(LongLogFile,line_separation);
  1231. AddLog(LongLogFile,known_problem+Config.KnownRunNote);
  1232. AddLog(LongLogFile,failed_to_run+PPFileInfo[current]+' ('+ToStr(ExecuteResult)+')');
  1233. if Copyfile(EXELogFile,LongLogFile,true)=0 then
  1234. begin
  1235. AddLog(LongLogFile,known_problem+'exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  1236. AddLog(ExeLogFile,known_problem+'exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  1237. end;
  1238. Verbose(V_Warning,known_problem+'exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  1239. end
  1240. else
  1241. begin
  1242. AddLog(FailLogFile,TestName);
  1243. AddLog(ResLogFile,failed_to_run+PPFileInfo[current]);
  1244. AddLog(LongLogFile,line_separation);
  1245. AddLog(LongLogFile,failed_to_run+PPFileInfo[current]+' ('+ToStr(ExecuteResult)+')');
  1246. if Copyfile(EXELogFile,LongLogFile,true)=0 then
  1247. begin
  1248. AddLog(LongLogFile,'Exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  1249. AddLog(ExeLogFile,'Exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  1250. end;
  1251. Verbose(V_Warning,'Exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  1252. end
  1253. end
  1254. else
  1255. begin
  1256. AddLog(ResLogFile,successfully_run+PPFileInfo[current]);
  1257. RunExecutable:=true;
  1258. end;
  1259. if (deAfter in DelExecutable) and not Config.NeededAfter then
  1260. begin
  1261. Verbose(V_Debug,'Deleting executable '+TestExe);
  1262. RemoveFile(TestExe);
  1263. RemoveFile(ForceExtension(TestExe,ObjExt));
  1264. RemoveFile(ForceExtension(TestExe,PPUExt));
  1265. end;
  1266. end;
  1267. { Try to collect information concerning the remote configuration
  1268. Currently only records RemoteShell name and sets
  1269. RemoteShellNeedsExport boolean variable }
  1270. procedure SetRemoteConfiguration;
  1271. var
  1272. f : text;
  1273. StartTicks,EndTicks : int64;
  1274. begin
  1275. if RemoteAddr='' then
  1276. exit;
  1277. ExeLogFile:='__remote.tmp';
  1278. ExecuteRemote(rshprog,RemoteRshParas+
  1279. ' "echo SHELL=${SHELL}"',StartTicks,EndTicks);
  1280. Assign(f,ExeLogFile);
  1281. Reset(f);
  1282. While not eof(f) do
  1283. begin
  1284. Readln(f,RemoteShellBase);
  1285. if pos('SHELL=',RemoteShellBase)>0 then
  1286. begin
  1287. RemoteShell:=TrimSpace(Copy(RemoteShellBase,pos('SHELL=',RemoteShellBase)+6,
  1288. length(RemoteShellBase)));
  1289. Verbose(V_Debug,'Remote shell is "'+RemoteShell+'"');
  1290. RemoteShellBase:=SplitFileBase(RemoteShell);
  1291. if (RemoteShellBase='bash') or (RemoteShellBase='sh') then
  1292. RemoteShellNeedsExport:=true;
  1293. end;
  1294. end;
  1295. Close(f);
  1296. end;
  1297. procedure getargs;
  1298. procedure helpscreen;
  1299. begin
  1300. writeln('dotest [Options] <File>');
  1301. writeln;
  1302. writeln('Options can be:');
  1303. writeln(' !ENV_NAME parse environment variable ENV_NAME for options');
  1304. writeln(' -A include ALL tests');
  1305. writeln(' -B delete executable before remote upload');
  1306. writeln(' -C<compiler> set compiler to use');
  1307. writeln(' -D display execution time');
  1308. writeln(' -E execute test also');
  1309. writeln(' -G include graph tests');
  1310. writeln(' -I include interactive tests');
  1311. writeln(' -K include known bug tests');
  1312. writeln(' -M<emulator> run the tests using the given emulator');
  1313. writeln(' -O use timeout wrapper for (remote) execution');
  1314. writeln(' -P<path> path to the tests tree on the remote machine');
  1315. writeln(' -R<remote> run the tests remotely with the given rsh/ssh address');
  1316. writeln(' -S use ssh instead of rsh');
  1317. writeln(' -T[cpu-]<os> run tests for target cpu and os');
  1318. writeln(' -U<remotepara>');
  1319. writeln(' pass additional parameter to remote program. Multiple -U can be used');
  1320. writeln(' -V be verbose');
  1321. writeln(' -W use putty compatible file names when testing (plink and pscp)');
  1322. writeln(' -X don''t use COMSPEC');
  1323. writeln(' -Y<opts> extra options passed to the compiler. Several -Y<opt> can be given.');
  1324. writeln(' -Z remove temporary files (executable,ppu,o)');
  1325. halt(1);
  1326. end;
  1327. procedure interpret_option (para : string);
  1328. var
  1329. ch : char;
  1330. j : longint;
  1331. begin
  1332. Verbose(V_Debug,'Interpreting option"'+para+'"');
  1333. ch:=Upcase(para[2]);
  1334. delete(para,1,2);
  1335. case ch of
  1336. 'A' :
  1337. begin
  1338. DoGraph:=true;
  1339. DoInteractive:=true;
  1340. DoKnown:=true;
  1341. DoAll:=true;
  1342. end;
  1343. 'B' : Include(DelExecutable,deBefore);
  1344. 'C' : CompilerBin:=Para;
  1345. 'D' : BenchMarkInfo:=true;
  1346. 'E' : DoExecute:=true;
  1347. 'G' : begin
  1348. DoGraph:=true;
  1349. if para='-' then
  1350. DoUsual:=false;
  1351. end;
  1352. 'I' : begin
  1353. DoInteractive:=true;
  1354. if para='-' then
  1355. DoUsual:=false;
  1356. end;
  1357. 'K' : begin
  1358. DoKnown:=true;
  1359. if para='-' then
  1360. DoUsual:=false;
  1361. end;
  1362. 'M' : EmulatorName:=Para;
  1363. 'O' : UseTimeout:=true;
  1364. 'P' : RemotePath:=Para;
  1365. 'R' : RemoteAddr:=Para;
  1366. 'S' :
  1367. begin
  1368. rshprog:='ssh';
  1369. rcpprog:='scp';
  1370. end;
  1371. 'T' :
  1372. begin
  1373. j:=Pos('-',Para);
  1374. if j>0 then
  1375. begin
  1376. CompilerCPU:=Copy(Para,1,j-1);
  1377. CompilerTarget:=Copy(Para,j+1,length(para));
  1378. end
  1379. else
  1380. CompilerTarget:=Para
  1381. end;
  1382. 'U' :
  1383. RemotePara:=RemotePara+' '+Para;
  1384. 'V' : DoVerbose:=true;
  1385. 'W' :
  1386. begin
  1387. rshprog:='plink';
  1388. rcpprog:='pscp';
  1389. rquote:='"';
  1390. end;
  1391. 'X' : UseComSpec:=false;
  1392. 'Y' : ExtraCompilerOpts:= ExtraCompilerOpts +' '+ Para;
  1393. 'Z' : Include(DelExecutable,deAfter);
  1394. end;
  1395. end;
  1396. procedure interpret_env(arg : string);
  1397. var
  1398. para : string;
  1399. pspace : longint;
  1400. begin
  1401. Verbose(V_Debug,'Interpreting environment option"'+arg+'"');
  1402. { Get rid of leading '!' }
  1403. delete(arg,1,1);
  1404. arg:=getenv(arg);
  1405. Verbose(V_Debug,'Environment value is "'+arg+'"');
  1406. while (length(arg)>0) do
  1407. begin
  1408. while (length(arg)>0) and (arg[1]=' ') do
  1409. delete(arg,1,1);
  1410. pspace:=pos(' ',arg);
  1411. if pspace=0 then
  1412. pspace:=length(arg)+1;
  1413. para:=copy(arg,1,pspace-1);
  1414. if (length(para)>0) and (para[1]='-') then
  1415. interpret_option (para)
  1416. else
  1417. begin
  1418. PPFile.Insert(current,ForceExtension(Para,'pp'));
  1419. inc(current);
  1420. end;
  1421. delete(arg,1,pspace);
  1422. end;
  1423. end;
  1424. var
  1425. param : string;
  1426. i : longint;
  1427. begin
  1428. CompilerBin:='ppc386'+srcexeext;
  1429. for i:=1 to paramcount do
  1430. begin
  1431. param:=Paramstr(i);
  1432. if (param[1]='-') then
  1433. interpret_option(param)
  1434. else if (param[1]='!') then
  1435. interpret_env(param)
  1436. else
  1437. begin
  1438. PPFile.Insert(current,ForceExtension(Param,'pp'));
  1439. inc(current);
  1440. end;
  1441. end;
  1442. if current=0 then
  1443. HelpScreen;
  1444. { disable graph,interactive when running remote }
  1445. if RemoteAddr<>'' then
  1446. begin
  1447. DoGraph:=false;
  1448. DoInteractive:=false;
  1449. end;
  1450. { If we use PuTTY plink program with -load option,
  1451. the IP address or name should not be added to
  1452. the command line }
  1453. if (rshprog='plink') and (pos('-load',RemotePara)>0) then
  1454. RemoteRshParas:=RemotePara
  1455. else
  1456. RemoteRshParas:=RemotePara+' '+RemoteAddr;
  1457. end;
  1458. procedure RunTest;
  1459. var
  1460. PPDir,LibraryName : string;
  1461. Res : boolean;
  1462. begin
  1463. Res:=GetConfig(PPFile[current],Config);
  1464. if Res then
  1465. begin
  1466. Res:=GetCompilerCPU;
  1467. Res:=GetCompilerTarget;
  1468. {$ifndef MACOS}
  1469. RTLUnitsDir:='units/'+CompilerFullTarget;
  1470. {$else MACOS}
  1471. RTLUnitsDir:=':units:'+CompilerFullTarget;
  1472. {$endif MACOS}
  1473. if not PathExists(RTLUnitsDir) then
  1474. Verbose(V_Abort,'Unit path "'+RTLUnitsDir+'" does not exists');
  1475. {$ifndef MACOS}
  1476. OutputDir:='output/'+CompilerFullTarget;
  1477. {$else MACOS}
  1478. OutputDir:=':output:'+CompilerFullTarget;
  1479. {$endif MACOS}
  1480. if not PathExists(OutputDir) then
  1481. Verbose(V_Abort,'Output path "'+OutputDir+'" does not exists');
  1482. { Global log files }
  1483. ResLogFile:=OutputFileName('log','');
  1484. LongLogFile:=OutputFileName('longlog','');
  1485. FailLogFile:=OutputFileName('faillist','');
  1486. { Make subdir in output if needed }
  1487. PPDir:=SplitPath(PPFile[current]);
  1488. if PPDir[length(PPDir)] in ['/','\'{$ifdef MACOS},':'{$endif MACOS}] then
  1489. Delete(PPDir,length(PPDir),1);
  1490. if PPDir<>'' then
  1491. begin
  1492. {$ifndef MACOS}
  1493. TestOutputDir:=OutputDir+'/'+PPDir;
  1494. {$else MACOS}
  1495. TestOutputDir:=OutputDir+PPDir;
  1496. {$endif MACOS}
  1497. mkdirtree(TestOutputDir);
  1498. end
  1499. else
  1500. TestOutputDir:=OutputDir;
  1501. { Per test logfiles }
  1502. CompilerLogFile:=TestOutputFileName('',SplitFileName(PPFile[current]),'log');
  1503. ExeLogFile:=TestOutputFileName('',SplitFileName(PPFile[current]),'elg');
  1504. Verbose(V_Debug,'Using Compiler logfile: '+CompilerLogFile);
  1505. Verbose(V_Debug,'Using Execution logfile: '+ExeLogFile);
  1506. end;
  1507. if Res then
  1508. begin
  1509. if Config.UsesGraph and (not DoGraph) then
  1510. begin
  1511. AddLog(ResLogFile,skipping_graph_test+PPFileInfo[current]);
  1512. { avoid a second attempt by writing to elg file }
  1513. AddLog(EXELogFile,skipping_graph_test+PPFileInfo[current]);
  1514. Verbose(V_Warning,skipping_graph_test);
  1515. Res:=false;
  1516. end;
  1517. end;
  1518. if Res then
  1519. begin
  1520. if Config.IsInteractive and (not DoInteractive) then
  1521. begin
  1522. { avoid a second attempt by writing to elg file }
  1523. AddLog(EXELogFile,skipping_interactive_test+PPFileInfo[current]);
  1524. AddLog(ResLogFile,skipping_interactive_test+PPFileInfo[current]);
  1525. Verbose(V_Warning,skipping_interactive_test);
  1526. Res:=false;
  1527. end;
  1528. end;
  1529. if Res then
  1530. begin
  1531. if Config.IsKnownCompileError and (not DoKnown) then
  1532. begin
  1533. { avoid a second attempt by writing to elg file }
  1534. AddLog(EXELogFile,skipping_known_bug+PPFileInfo[current]);
  1535. AddLog(ResLogFile,skipping_known_bug+PPFileInfo[current]);
  1536. Verbose(V_Warning,skipping_known_bug);
  1537. Res:=false;
  1538. end;
  1539. end;
  1540. if Res and not DoUsual then
  1541. res:=(Config.IsInteractive and DoInteractive) or
  1542. (Config.IsKnownRunError and DoKnown) or
  1543. (Config.UsesGraph and DoGraph);
  1544. if Res then
  1545. begin
  1546. if (Config.MinVersion<>'') and not DoAll then
  1547. begin
  1548. Verbose(V_Debug,'Required compiler version: '+Config.MinVersion);
  1549. Res:=GetCompilerVersion;
  1550. if CompilerVersion<Config.MinVersion then
  1551. begin
  1552. { avoid a second attempt by writing to elg file }
  1553. AddLog(EXELogFile,skipping_compiler_version_too_low+PPFileInfo[current]);
  1554. AddLog(ResLogFile,skipping_compiler_version_too_low+PPFileInfo[current]);
  1555. Verbose(V_Warning,'Compiler version too low '+CompilerVersion+' < '+Config.MinVersion);
  1556. Res:=false;
  1557. end;
  1558. end;
  1559. end;
  1560. if Res then
  1561. begin
  1562. if (Config.MaxVersion<>'') and not DoAll then
  1563. begin
  1564. Verbose(V_Debug,'Highest compiler version: '+Config.MaxVersion);
  1565. Res:=GetCompilerVersion;
  1566. if CompilerVersion>Config.MaxVersion then
  1567. begin
  1568. { avoid a second attempt by writing to elg file }
  1569. AddLog(EXELogFile,skipping_compiler_version_too_high+PPFileInfo[current]);
  1570. AddLog(ResLogFile,skipping_compiler_version_too_high+PPFileInfo[current]);
  1571. Verbose(V_Warning,'Compiler version too high '+CompilerVersion+' > '+Config.MaxVersion);
  1572. Res:=false;
  1573. end;
  1574. end;
  1575. end;
  1576. if Res then
  1577. begin
  1578. if Config.NeedCPU<>'' then
  1579. begin
  1580. Verbose(V_Debug,'Required compiler cpu: '+Config.NeedCPU);
  1581. if not IsInList(CompilerCPU,Config.NeedCPU) then
  1582. begin
  1583. { avoid a second attempt by writing to elg file }
  1584. AddLog(EXELogFile,skipping_other_cpu+PPFileInfo[current]);
  1585. AddLog(ResLogFile,skipping_other_cpu+PPFileInfo[current]);
  1586. Verbose(V_Warning,'Compiler cpu "'+CompilerCPU+'" is not in list "'+Config.NeedCPU+'"');
  1587. Res:=false;
  1588. end;
  1589. end;
  1590. end;
  1591. if Res then
  1592. begin
  1593. if Config.SkipCPU<>'' then
  1594. begin
  1595. Verbose(V_Debug,'Skip compiler cpu: '+Config.SkipCPU);
  1596. if IsInList(CompilerCPU,Config.SkipCPU) then
  1597. begin
  1598. { avoid a second attempt by writing to elg file }
  1599. AddLog(EXELogFile,skipping_other_cpu+PPFileInfo[current]);
  1600. AddLog(ResLogFile,skipping_other_cpu+PPFileInfo[current]);
  1601. Verbose(V_Warning,'Compiler cpu "'+CompilerCPU+'" is in list "'+Config.SkipCPU+'"');
  1602. Res:=false;
  1603. end;
  1604. end;
  1605. end;
  1606. if Res then
  1607. begin
  1608. if Config.SkipEmu<>'' then
  1609. begin
  1610. Verbose(V_Debug,'Skip emulator: '+emulatorname);
  1611. if IsInList(emulatorname,Config.SkipEmu) then
  1612. begin
  1613. { avoid a second attempt by writing to elg file }
  1614. AddLog(EXELogFile,skipping_other_cpu+PPFileInfo[current]);
  1615. AddLog(ResLogFile,skipping_other_cpu+PPFileInfo[current]);
  1616. Verbose(V_Warning,'Emulator "'+emulatorname+'" is in list "'+Config.SkipEmu+'"');
  1617. Res:=false;
  1618. end;
  1619. end;
  1620. end;
  1621. if Res then
  1622. begin
  1623. if Config.NeedTarget<>'' then
  1624. begin
  1625. Verbose(V_Debug,'Required compiler target: '+Config.NeedTarget);
  1626. if not IsInList(CompilerTarget,Config.NeedTarget) then
  1627. begin
  1628. { avoid a second attempt by writing to elg file }
  1629. AddLog(EXELogFile,skipping_other_target+PPFileInfo[current]);
  1630. AddLog(ResLogFile,skipping_other_target+PPFileInfo[current]);
  1631. Verbose(V_Warning,'Compiler target "'+CompilerTarget+'" is not in list "'+Config.NeedTarget+'"');
  1632. Res:=false;
  1633. end;
  1634. end;
  1635. end;
  1636. if Res then
  1637. begin
  1638. if Config.SkipTarget<>'' then
  1639. begin
  1640. Verbose(V_Debug,'Skip compiler target: '+Config.SkipTarget);
  1641. if IsInList(CompilerTarget,Config.SkipTarget) then
  1642. begin
  1643. { avoid a second attempt by writing to elg file }
  1644. AddLog(EXELogFile,skipping_other_target+PPFileInfo[current]);
  1645. AddLog(ResLogFile,skipping_other_target+PPFileInfo[current]);
  1646. Verbose(V_Warning,'Compiler target "'+CompilerTarget+'" is in list "'+Config.SkipTarget+'"');
  1647. Res:=false;
  1648. end;
  1649. end;
  1650. end;
  1651. if Res then
  1652. begin
  1653. { Use known bug, to avoid adding a new entry for this PM 2011-06-24 }
  1654. if Config.NeedLibrary and not TargetCanCompileLibraries then
  1655. begin
  1656. AddLog(EXELogFile,skipping_known_bug+PPFileInfo[current]);
  1657. AddLog(ResLogFile,skipping_known_bug+PPFileInfo[current]);
  1658. Verbose(V_Warning,'Compiler target "'+CompilerTarget+'" does not support library compilation');
  1659. Res:=false;
  1660. end;
  1661. end;
  1662. if Res then
  1663. begin
  1664. Res:=RunCompiler;
  1665. if Res and Config.NeedRecompile then
  1666. Res:=RunCompiler;
  1667. end;
  1668. if Res and (not Config.ShouldFail) then
  1669. begin
  1670. if (Config.NoRun) then
  1671. begin
  1672. { avoid a second attempt by writing to elg file }
  1673. AddLog(EXELogFile,skipping_run_test+PPFileInfo[current]);
  1674. AddLog(ResLogFile,skipping_run_test+PPFileInfo[current]);
  1675. Verbose(V_Debug,skipping_run_test);
  1676. if LibraryExists(PPFile[current],LibraryName) then
  1677. MaybeCopyFiles(LibraryName);
  1678. end
  1679. else if Config.IsKnownRunError and (not DoKnown) then
  1680. begin
  1681. { avoid a second attempt by writing to elg file }
  1682. AddLog(EXELogFile,skipping_known_bug+PPFileInfo[current]);
  1683. AddLog(ResLogFile,skipping_known_bug+PPFileInfo[current]);
  1684. Verbose(V_Warning,skipping_known_bug);
  1685. end
  1686. else
  1687. begin
  1688. if DoExecute then
  1689. begin
  1690. if FileExists(TestOutputFilename('',PPFile[current],'ppu')) or
  1691. FileExists(TestOutputFilename('',PPFile[current],'ppo')) or
  1692. FileExists(TestOutputFilename('',PPFile[current],'ppw')) then
  1693. begin
  1694. AddLog(ExeLogFile,skipping_run_unit+PPFileInfo[current]);
  1695. AddLog(ResLogFile,skipping_run_unit+PPFileInfo[current]);
  1696. Verbose(V_Debug,'Unit found, skipping run test')
  1697. end
  1698. else if LibraryExists(PPFile[current],LibraryName) then
  1699. begin
  1700. Verbose(V_Debug,'Library found, skipping run test');
  1701. MaybeCopyFiles(LibraryName);
  1702. end
  1703. else
  1704. Res:=RunExecutable;
  1705. end;
  1706. end;
  1707. end;
  1708. end;
  1709. begin
  1710. Current:=0;
  1711. PPFile:=TStringList.Create;
  1712. PPFile.Capacity:=10;
  1713. PPFileInfo:=TStringList.Create;
  1714. PPFileInfo.Capacity:=10;
  1715. GetArgs;
  1716. SetTargetDirectoriesStyle;
  1717. SetTargetCanCompileLibraries;
  1718. SetRemoteConfiguration;
  1719. {$ifdef LIMIT83fs}
  1720. UseOSOnly:=true;
  1721. {$else not LIMIT83fs}
  1722. SetUseOSOnly;
  1723. {$endif not LIMIT83fs}
  1724. Verbose(V_Debug,'Found '+ToStr(PPFile.Count)+' tests to run');
  1725. if current>0 then
  1726. for current:=0 to PPFile.Count-1 do
  1727. begin
  1728. SetPPFileInfo;
  1729. TestName:=Copy(PPFile[current],1,Pos('.pp',PPFile[current])-1);
  1730. Verbose(V_Normal,'Running test '+TestName+', file '+PPFile[current]);
  1731. RunTest;
  1732. end;
  1733. PPFile.Free;
  1734. PPFileInfo.Free;
  1735. end.