dotest.pp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. {
  2. $Id$
  3. This file is part of the Free Pascal test suite.
  4. Copyright (c) 1999-2002 by the Free Pascal development team.
  5. This program makes the compilation and
  6. execution of individual test sources.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$H+}
  14. program dotest;
  15. uses
  16. dos,
  17. teststr,
  18. testu,
  19. redir;
  20. type
  21. tcompinfo = (compver,comptarget,compcpu);
  22. const
  23. {$ifdef UNIX}
  24. ExeExt='';
  25. {$else UNIX}
  26. ExeExt='exe';
  27. {$endif UNIX}
  28. var
  29. Config : TConfig;
  30. CompilerBin : string;
  31. CompilerCPU : string;
  32. CompilerTarget : string;
  33. CompilerVersion : string;
  34. PPFile : string;
  35. PPFileInfo : string;
  36. TestName : string;
  37. const
  38. LongLogfile : string[32] = 'longlog';
  39. FailLogfile : string[32] = 'faillist';
  40. DoGraph : boolean = false;
  41. DoInteractive : boolean = false;
  42. DoExecute : boolean = false;
  43. DoKnown : boolean = false;
  44. DoAll : boolean = false;
  45. DoUsual : boolean = true;
  46. Function FileExists (Const F : String) : Boolean;
  47. {
  48. Returns True if the file exists, False if not.
  49. }
  50. Var
  51. info : searchrec;
  52. begin
  53. FindFirst (F,anyfile,Info);
  54. FileExists:=DosError=0;
  55. FindClose (Info);
  56. end;
  57. function ToStr(l:longint):string;
  58. var
  59. s : string;
  60. begin
  61. Str(l,s);
  62. ToStr:=s;
  63. end;
  64. function ToStrZero(l:longint;nbzero : byte):string;
  65. var
  66. s : string;
  67. begin
  68. Str(l,s);
  69. while length(s)<nbzero do
  70. s:='0'+s;
  71. ToStrZero:=s;
  72. end;
  73. function trimspace(const s:string):string;
  74. var
  75. i,j : longint;
  76. begin
  77. i:=length(s);
  78. while (i>0) and (s[i] in [#9,' ']) do
  79. dec(i);
  80. j:=1;
  81. while (j<i) and (s[j] in [#9,' ']) do
  82. inc(j);
  83. trimspace:=Copy(s,j,i-j+1);
  84. end;
  85. function IsInList(const entry,list:string):boolean;
  86. var
  87. i,istart : longint;
  88. begin
  89. IsInList:=false;
  90. i:=0;
  91. while (i<length(list)) do
  92. begin
  93. { Find list item }
  94. istart:=i+1;
  95. while (i<length(list)) and
  96. (list[i+1]<>',') do
  97. inc(i);
  98. if Upcase(entry)=Upcase(TrimSpace(Copy(list,istart,i-istart+1))) then
  99. begin
  100. IsInList:=true;
  101. exit;
  102. end;
  103. { skip , }
  104. inc(i);
  105. end;
  106. end;
  107. procedure SetPPFileInfo;
  108. Var
  109. info : searchrec;
  110. dt : DateTime;
  111. begin
  112. FindFirst (PPFile,anyfile,Info);
  113. If DosError=0 then
  114. begin
  115. UnpackTime(info.time,dt);
  116. PPFileInfo:=PPFile+' '+ToStr(dt.year)+'/'+ToStrZero(dt.month,2)+'/'+
  117. ToStrZero(dt.day,2)+' '+ToStrZero(dt.Hour,2)+':'+ToStrZero(dt.min,2)+':'+ToStrZero(dt.sec,2);
  118. end
  119. else
  120. PPFileInfo:=PPfile;
  121. FindClose (Info);
  122. end;
  123. function SplitPath(const s:string):string;
  124. var
  125. i : longint;
  126. begin
  127. i:=Length(s);
  128. while (i>0) and not(s[i] in ['/','\']) do
  129. dec(i);
  130. SplitPath:=Copy(s,1,i);
  131. end;
  132. function ForceExtension(Const HStr,ext:String):String;
  133. {
  134. Return a filename which certainly has the extension ext
  135. }
  136. var
  137. j : longint;
  138. begin
  139. j:=length(Hstr);
  140. while (j>0) and (Hstr[j]<>'.') do
  141. dec(j);
  142. if j=0 then
  143. j:=255;
  144. if Ext<>'' then
  145. ForceExtension:=Copy(Hstr,1,j-1)+'.'+Ext
  146. else
  147. ForceExtension:=Copy(Hstr,1,j-1);
  148. end;
  149. procedure Copyfile(const fn1,fn2:string;append:boolean);
  150. const
  151. bufsize = 16384;
  152. var
  153. f,g : file;
  154. i : longint;
  155. buf : pointer;
  156. begin
  157. if Append then
  158. Verbose(V_Debug,'Appending '+fn1+' to '+fn2)
  159. else
  160. Verbose(V_Debug,'Copying '+fn1+' to '+fn2);
  161. assign(f,fn1);
  162. assign(g,fn2);
  163. {$I-}
  164. reset(f,1);
  165. {$I+}
  166. if ioresult<>0 then
  167. Verbose(V_Error,'Can''t open '+fn1);
  168. if append then
  169. begin
  170. {$I-}
  171. reset(g,1);
  172. {$I+}
  173. if ioresult<>0 then
  174. append:=false
  175. else
  176. seek(g,filesize(g));
  177. end;
  178. if not append then
  179. begin
  180. {$I-}
  181. rewrite(g,1);
  182. {$I+}
  183. if ioresult<>0 then
  184. Verbose(V_Error,'Can''t open '+fn2+' for output');
  185. end;
  186. getmem(buf,bufsize);
  187. repeat
  188. blockread(f,buf^,bufsize,i);
  189. blockwrite(g,buf^,i);
  190. until i<bufsize;
  191. freemem(buf,bufsize);
  192. close(f);
  193. close(g);
  194. end;
  195. procedure AddLog(const logfile,s:string);
  196. var
  197. t : text;
  198. begin
  199. assign(t,logfile);
  200. {$I-}
  201. append(t);
  202. {$I+}
  203. if ioresult<>0 then
  204. begin
  205. {$I-}
  206. rewrite(t);
  207. {$I+}
  208. if ioresult<>0 then
  209. Verbose(V_Abort,'Can''t append to '+logfile);
  210. end;
  211. writeln(t,s);
  212. close(t);
  213. end;
  214. function GetCompilerInfo(c:tcompinfo):boolean;
  215. function GetToken(var s:string):string;
  216. var
  217. i : longint;
  218. begin
  219. i:=pos(' ',s);
  220. if i=0 then
  221. i:=length(s)+1;
  222. GetToken:=Copy(s,1,i-1);
  223. Delete(s,1,i);
  224. end;
  225. var
  226. t : text;
  227. hs : string;
  228. begin
  229. GetCompilerInfo:=false;
  230. { Try to get all information in one call, this is
  231. supported in 1.1. Older compilers 1.0.x will only
  232. return the first info }
  233. case c of
  234. compver :
  235. hs:='-iVTPTO';
  236. compcpu :
  237. hs:='-iTPTOV';
  238. comptarget :
  239. hs:='-iTOTPV';
  240. end;
  241. ExecuteRedir(CompilerBin,hs,'','out','');
  242. assign(t,'out');
  243. {$I-}
  244. reset(t);
  245. readln(t,hs);
  246. close(t);
  247. erase(t);
  248. {$I+}
  249. if ioresult<>0 then
  250. Verbose(V_Error,'Can''t get Compiler Info')
  251. else
  252. begin
  253. Verbose(V_Debug,'Retrieved Compiler Info: "'+hs+'"');
  254. case c of
  255. compver :
  256. begin
  257. CompilerVersion:=GetToken(hs);
  258. CompilerCPU:=GetToken(hs);
  259. CompilerTarget:=GetToken(hs);
  260. end;
  261. compcpu :
  262. begin
  263. CompilerCPU:=GetToken(hs);
  264. CompilerTarget:=GetToken(hs);
  265. CompilerVersion:=GetToken(hs);
  266. end;
  267. comptarget :
  268. begin
  269. CompilerTarget:=GetToken(hs);
  270. CompilerCPU:=GetToken(hs);
  271. CompilerVersion:=GetToken(hs);
  272. end;
  273. end;
  274. GetCompilerInfo:=true;
  275. end;
  276. end;
  277. function GetCompilerVersion:boolean;
  278. begin
  279. if CompilerVersion='' then
  280. GetCompilerVersion:=GetCompilerInfo(compver)
  281. else
  282. GetCompilerVersion:=true;
  283. if GetCompilerVersion then
  284. Verbose(V_Debug,'Current Compiler Version: "'+CompilerVersion+'"');
  285. end;
  286. function GetCompilerCPU:boolean;
  287. begin
  288. if CompilerCPU='' then
  289. GetCompilerCPU:=GetCompilerInfo(compcpu)
  290. else
  291. GetCompilerCPU:=true;
  292. if GetCompilerCPU then
  293. Verbose(V_Debug,'Current Compiler CPU: "'+CompilerCPU+'"');
  294. end;
  295. function GetCompilerTarget:boolean;
  296. begin
  297. if CompilerTarget='' then
  298. GetCompilerTarget:=GetCompilerInfo(comptarget)
  299. else
  300. GetCompilerTarget:=true;
  301. if GetCompilerTarget then
  302. Verbose(V_Debug,'Current Compiler Target: "'+CompilerTarget+'"');
  303. end;
  304. function ExitWithInternalError(const OutName:string):boolean;
  305. var
  306. t : text;
  307. s : string;
  308. begin
  309. ExitWithInternalError:=false;
  310. { open logfile }
  311. assign(t,Outname);
  312. {$I-}
  313. reset(t);
  314. {$I+}
  315. if ioresult<>0 then
  316. exit;
  317. while not eof(t) do
  318. begin
  319. readln(t,s);
  320. if pos('Fatal: Internal error ',s)>0 then
  321. begin
  322. ExitWithInternalError:=true;
  323. break;
  324. end;
  325. end;
  326. close(t);
  327. end;
  328. function RunCompiler:boolean;
  329. var
  330. outname,
  331. args : string;
  332. begin
  333. RunCompiler:=false;
  334. OutName:=ForceExtension(PPFile,'log');
  335. args:='-n -Fuunits';
  336. {$ifdef unix}
  337. { Add runtime library path to current dir to find .so files }
  338. if Config.NeedLibrary then
  339. args:=args+' ''-k-rpath .''';
  340. {$endif unix}
  341. if Config.NeedOptions<>'' then
  342. args:=args+' '+Config.NeedOptions;
  343. args:=args+' '+ppfile;
  344. Verbose(V_Debug,'Executing '+compilerbin+' '+args);
  345. { also get the output from as and ld that writes to stderr sometimes }
  346. ExecuteRedir(CompilerBin,args,'',OutName,OutName);
  347. Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
  348. { Check for internal error }
  349. if ExitWithInternalError(OutName) then
  350. begin
  351. AddLog(FailLogFile,TestName);
  352. if Config.Note<>'' then
  353. AddLog(FailLogFile,Config.Note);
  354. AddLog(ResLogFile,failed_to_compile+PPFileInfo+' internalerror generated');
  355. AddLog(LongLogFile,line_separation);
  356. AddLog(LongLogFile,failed_to_compile+PPFileInfo);
  357. if Config.Note<>'' then
  358. AddLog(LongLogFile,Config.Note);
  359. CopyFile(OutName,LongLogFile,true);
  360. { avoid to try again }
  361. AddLog(ForceExtension(PPFile,'elg'),'Failed to compile '++PPFileInfo);
  362. Verbose(V_Abort,'Internal error in compiler');
  363. exit;
  364. end;
  365. { Shoud the compile fail ? }
  366. if Config.ShouldFail then
  367. begin
  368. if ExecuteResult<>0 then
  369. begin
  370. AddLog(ResLogFile,success_compilation_failed+PPFileInfo);
  371. { avoid to try again }
  372. AddLog(ForceExtension(PPFile,'elg'),success_compilation_failed+PPFileInfo);
  373. RunCompiler:=true;
  374. end
  375. else
  376. begin
  377. AddLog(FailLogFile,TestName);
  378. if Config.Note<>'' then
  379. AddLog(FailLogFile,Config.Note);
  380. AddLog(ResLogFile,failed_compilation_successful+PPFileInfo);
  381. AddLog(LongLogFile,line_separation);
  382. AddLog(LongLogFile,failed_compilation_successful+PPFileInfo);
  383. { avoid to try again }
  384. AddLog(ForceExtension(PPFile,'elg'),failed_compilation_successful+PPFileInfo);
  385. if Config.Note<>'' then
  386. AddLog(LongLogFile,Config.Note);
  387. CopyFile(OutName,LongLogFile,true);
  388. end;
  389. end
  390. else
  391. begin
  392. if (ExecuteResult<>0) and
  393. (((Config.KnownCompileNote<>'') and (Config.KnownCompileError=0)) or
  394. ((Config.KnownCompileError<>0) and (ExecuteResult=Config.KnownCompileError))) then
  395. begin
  396. AddLog(FailLogFile,TestName+known_problem+Config.KnownCompileNote);
  397. AddLog(ResLogFile,failed_to_run+PPFileInfo+known_problem+Config.KnownCompileNote);
  398. AddLog(LongLogFile,line_separation);
  399. AddLog(LongLogFile,known_problem+Config.KnownCompileNote);
  400. AddLog(LongLogFile,failed_to_compile+PPFileInfo+' ('+ToStr(ExecuteResult)+')');
  401. Copyfile(OutName,LongLogFile,true);
  402. Verbose(V_Abort,known_problem+'exitcode: '+ToStr(ExecuteResult));
  403. end
  404. else if ExecuteResult<>0 then
  405. begin
  406. AddLog(FailLogFile,TestName);
  407. if Config.Note<>'' then
  408. AddLog(FailLogFile,Config.Note);
  409. AddLog(ResLogFile,failed_to_compile+PPFileInfo);
  410. AddLog(LongLogFile,line_separation);
  411. AddLog(LongLogFile,failed_to_compile+PPFileInfo);
  412. if Config.Note<>'' then
  413. AddLog(LongLogFile,Config.Note);
  414. CopyFile(OutName,LongLogFile,true);
  415. { avoid to try again }
  416. AddLog(ForceExtension(PPFile,'elg'),failed_to_compile+PPFileInfo);
  417. Verbose(V_Abort,'Exitcode: '+ToStr(ExecuteResult)+' (expected 0)');
  418. end
  419. else
  420. begin
  421. AddLog(ResLogFile,successfully_compiled+PPFileInfo);
  422. RunCompiler:=true;
  423. end;
  424. end;
  425. end;
  426. function RunExecutable:boolean;
  427. var
  428. outname,
  429. TestExe : string;
  430. begin
  431. RunExecutable:=false;
  432. TestExe:=ForceExtension(PPFile,ExeExt);
  433. OutName:=ForceExtension(PPFile,'elg');
  434. Verbose(V_Debug,'Executing '+TestExe);
  435. { don't redirect interactive and graph programs .. }
  436. if Config.IsInteractive or Config.UsesGraph then
  437. ExecuteRedir(TestExe,'','','','')
  438. else
  439. ExecuteRedir(TestExe,'','',OutName,'');
  440. Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
  441. if ExecuteResult<>Config.ResultCode then
  442. begin
  443. if (ExecuteResult<>0) and
  444. (ExecuteResult=Config.KnownRunError) then
  445. begin
  446. AddLog(FailLogFile,TestName+known_problem+Config.KnownRunNote);
  447. AddLog(ResLogFile,failed_to_run+PPFileInfo+known_problem+Config.KnownRunNote);
  448. AddLog(LongLogFile,line_separation);
  449. AddLog(LongLogFile,known_problem+Config.KnownRunNote);
  450. AddLog(LongLogFile,failed_to_run+PPFileInfo+' ('+ToStr(ExecuteResult)+')');
  451. Copyfile(OutName,LongLogFile,true);
  452. Verbose(V_Abort,known_problem+'exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  453. end
  454. else
  455. begin
  456. AddLog(FailLogFile,TestName);
  457. AddLog(ResLogFile,failed_to_run+PPFileInfo);
  458. AddLog(LongLogFile,line_separation);
  459. AddLog(LongLogFile,failed_to_run+PPFileInfo+' ('+ToStr(ExecuteResult)+')');
  460. Copyfile(OutName,LongLogFile,true);
  461. Verbose(V_Abort,'Exitcode: '+ToStr(ExecuteResult)+' (expected '+ToStr(Config.ResultCode)+')');
  462. end
  463. end
  464. else
  465. begin
  466. AddLog(ResLogFile,successfully_run+PPFileInfo);
  467. RunExecutable:=true;
  468. end;
  469. end;
  470. procedure getargs;
  471. var
  472. ch : char;
  473. para : string;
  474. i : longint;
  475. procedure helpscreen;
  476. begin
  477. writeln('dotest [Options] <File>');
  478. writeln;
  479. writeln('Options can be:');
  480. writeln(' -C<compiler> set compiler to use');
  481. writeln(' -V verbose');
  482. writeln(' -E execute test also');
  483. writeln(' -X don''t use COMSPEC');
  484. writeln(' -A include ALL tests');
  485. writeln(' -G include graph tests');
  486. writeln(' -K include known bug tests');
  487. writeln(' -I include interactive tests');
  488. halt(1);
  489. end;
  490. begin
  491. PPFile:='';
  492. if exeext<>'' then
  493. CompilerBin:='ppc386.'+exeext
  494. else
  495. CompilerBin:='ppc386';
  496. for i:=1 to paramcount do
  497. begin
  498. para:=Paramstr(i);
  499. if (para[1]='-') then
  500. begin
  501. ch:=Upcase(para[2]);
  502. delete(para,1,2);
  503. case ch of
  504. 'A' :
  505. begin
  506. DoGraph:=true;
  507. DoInteractive:=true;
  508. DoKnown:=true;
  509. DoAll:=true;
  510. end;
  511. 'C' : CompilerBin:=Para;
  512. 'E' : DoExecute:=true;
  513. 'G' : begin
  514. DoGraph:=true;
  515. if para='-' then
  516. DoUsual:=false;
  517. end;
  518. 'I' : begin
  519. DoInteractive:=true;
  520. if para='-' then
  521. DoUsual:=false;
  522. end;
  523. 'K' : begin
  524. DoKnown:=true;
  525. if para='-' then
  526. DoUsual:=false;
  527. end;
  528. 'V' : DoVerbose:=true;
  529. 'X' : UseComSpec:=false;
  530. end;
  531. end
  532. else
  533. begin
  534. If PPFile<>'' then
  535. HelpScreen;
  536. PPFile:=ForceExtension(Para,'pp');
  537. end;
  538. end;
  539. if (PPFile='') then
  540. HelpScreen;
  541. SetPPFileInfo;
  542. TestName:=Copy(PPFile,1,Pos('.pp',PPFile)-1);
  543. Verbose(V_Debug,'Running test '+TestName+', file '+PPFile);
  544. end;
  545. procedure RunTest;
  546. var
  547. Res : boolean;
  548. OutName : string;
  549. begin
  550. Res:=GetConfig(ppfile,Config);
  551. OutName:=ForceExtension(PPFile,'elg');
  552. if Res then
  553. begin
  554. if Config.UsesGraph and (not DoGraph) then
  555. begin
  556. AddLog(ResLogFile,skipping_graph_test+PPFileInfo);
  557. { avoid a second attempt by writing to elg file }
  558. AddLog(OutName,skipping_graph_test+PPFileInfo);
  559. Verbose(V_Abort,skipping_graph_test);
  560. Res:=false;
  561. end;
  562. end;
  563. if Res then
  564. begin
  565. if Config.IsInteractive and (not DoInteractive) then
  566. begin
  567. { avoid a second attempt by writing to elg file }
  568. AddLog(OutName,skipping_interactive_test+PPFileInfo);
  569. AddLog(ResLogFile,skipping_interactive_test+PPFileInfo);
  570. Verbose(V_Abort,skipping_interactive_test);
  571. Res:=false;
  572. end;
  573. end;
  574. if Res then
  575. begin
  576. if Config.IsKnownCompileError and (not DoKnown) then
  577. begin
  578. { avoid a second attempt by writing to elg file }
  579. AddLog(OutName,skipping_known_bug+PPFileInfo);
  580. AddLog(ResLogFile,skipping_known_bug+PPFileInfo);
  581. Verbose(V_Abort,skipping_known_bug);
  582. Res:=false;
  583. end;
  584. end;
  585. if Res and not DoUsual then
  586. res:=(Config.IsInteractive and DoInteractive) or
  587. (Config.IsKnownRunError and DoKnown) or
  588. (Config.UsesGraph and DoGraph);
  589. if Res then
  590. begin
  591. if (Config.MinVersion<>'') and not DoAll then
  592. begin
  593. Verbose(V_Debug,'Required compiler version: '+Config.MinVersion);
  594. Res:=GetCompilerVersion;
  595. if CompilerVersion<Config.MinVersion then
  596. begin
  597. { avoid a second attempt by writing to elg file }
  598. AddLog(OutName,skipping_compiler_version_too_low+PPFileInfo);
  599. AddLog(ResLogFile,skipping_compiler_version_too_low+PPFileInfo);
  600. Verbose(V_Abort,'Compiler version too low '+CompilerVersion+' < '+Config.MinVersion);
  601. Res:=false;
  602. end;
  603. end;
  604. end;
  605. if Res then
  606. begin
  607. if (Config.MaxVersion<>'') and not DoAll then
  608. begin
  609. Verbose(V_Debug,'Highest compiler version: '+Config.MaxVersion);
  610. Res:=GetCompilerVersion;
  611. if CompilerVersion>Config.MaxVersion then
  612. begin
  613. { avoid a second attempt by writing to elg file }
  614. AddLog(OutName,skipping_compiler_version_too_high+PPFileInfo);
  615. AddLog(ResLogFile,skipping_compiler_version_too_high+PPFileInfo);
  616. Verbose(V_Abort,'Compiler version too high '+CompilerVersion+' > '+Config.MaxVersion);
  617. Res:=false;
  618. end;
  619. end;
  620. end;
  621. if Res then
  622. begin
  623. if Config.NeedCPU<>'' then
  624. begin
  625. Verbose(V_Debug,'Required compiler cpu: '+Config.NeedCPU);
  626. Res:=GetCompilerCPU;
  627. if not IsInList(CompilerCPU,Config.NeedCPU) then
  628. begin
  629. { avoid a second attempt by writing to elg file }
  630. AddLog(OutName,skipping_other_cpu+PPFileInfo);
  631. AddLog(ResLogFile,skipping_other_cpu+PPFileInfo);
  632. Verbose(V_Abort,'Compiler cpu "'+CompilerCPU+'" is not in list "'+Config.NeedCPU+'"');
  633. Res:=false;
  634. end;
  635. end;
  636. end;
  637. if Res then
  638. begin
  639. if Config.SkipCPU<>'' then
  640. begin
  641. Verbose(V_Debug,'Skip compiler cpu: '+Config.NeedCPU);
  642. Res:=GetCompilerCPU;
  643. if IsInList(CompilerCPU,Config.SkipCPU) then
  644. begin
  645. { avoid a second attempt by writing to elg file }
  646. AddLog(OutName,skipping_other_cpu+PPFileInfo);
  647. AddLog(ResLogFile,skipping_other_cpu+PPFileInfo);
  648. Verbose(V_Abort,'Compiler cpu "'+CompilerCPU+'" is in list "'+Config.SkipCPU+'"');
  649. Res:=false;
  650. end;
  651. end;
  652. end;
  653. if Res then
  654. begin
  655. if Config.NeedTarget<>'' then
  656. begin
  657. Verbose(V_Debug,'Required compiler target: '+Config.NeedTarget);
  658. Res:=GetCompilerTarget;
  659. if not IsInList(CompilerTarget,Config.NeedTarget) then
  660. begin
  661. { avoid a second attempt by writing to elg file }
  662. AddLog(OutName,skipping_other_target+PPFileInfo);
  663. AddLog(ResLogFile,skipping_other_target+PPFileInfo);
  664. Verbose(V_Abort,'Compiler target "'+CompilerTarget+'" is not in list "'+Config.NeedTarget+'"');
  665. Res:=false;
  666. end;
  667. end;
  668. end;
  669. if Res then
  670. begin
  671. if Config.SkipTarget<>'' then
  672. begin
  673. Verbose(V_Debug,'Skip compiler target: '+Config.NeedTarget);
  674. Res:=GetCompilerTarget;
  675. if IsInList(CompilerTarget,Config.SkipTarget) then
  676. begin
  677. { avoid a second attempt by writing to elg file }
  678. AddLog(OutName,skipping_other_target+PPFileInfo);
  679. AddLog(ResLogFile,skipping_other_target+PPFileInfo);
  680. Verbose(V_Abort,'Compiler target "'+CompilerTarget+'" is in list "'+Config.SkipTarget+'"');
  681. Res:=false;
  682. end;
  683. end;
  684. end;
  685. if Res then
  686. begin
  687. Res:=RunCompiler;
  688. if Res and Config.NeedRecompile then
  689. Res:=RunCompiler;
  690. end;
  691. if Res then
  692. begin
  693. if (Config.NoRun) then
  694. begin
  695. { avoid a second attempt by writing to elg file }
  696. AddLog(OutName,skipping_run_test+PPFileInfo);
  697. AddLog(ResLogFile,skipping_run_test+PPFileInfo);
  698. Verbose(V_Debug,skipping_run_test);
  699. end
  700. else if Config.IsKnownRunError and (not DoKnown) then
  701. begin
  702. { avoid a second attempt by writing to elg file }
  703. AddLog(OutName,skipping_known_bug+PPFileInfo);
  704. AddLog(ResLogFile,skipping_known_bug+PPFileInfo);
  705. Verbose(V_Abort,skipping_known_bug);
  706. end
  707. else
  708. begin
  709. if (not Config.ShouldFail) and DoExecute then
  710. begin
  711. if FileExists(ForceExtension(PPFile,'ppu')) or
  712. FileExists(ForceExtension(PPFile,'ppo')) or
  713. FileExists(ForceExtension(PPFile,'ppw')) then
  714. begin
  715. AddLog(ForceExtension(PPFile,'elg'),skipping_run_unit+PPFileInfo);
  716. AddLog(ResLogFile,skipping_run_unit+PPFileInfo);
  717. Verbose(V_Debug,'Unit found, skipping run test')
  718. end
  719. else
  720. Res:=RunExecutable;
  721. end;
  722. end;
  723. end;
  724. end;
  725. begin
  726. GetArgs;
  727. RunTest;
  728. end.
  729. {
  730. $Log$
  731. Revision 1.29 2003-10-31 16:14:20 peter
  732. * remove compileerror10, note10
  733. * remove known, use knowncompileerror,knownrunerror instead
  734. * knowncompileerror,knownrunerror tests are now really skipped
  735. Revision 1.28 2003/10/13 14:19:02 peter
  736. * digest updated for max version limit
  737. Revision 1.27 2003/06/13 08:16:34 pierre
  738. * fix a problem with KNOWNCOMPILE10ERROR
  739. Revision 1.26 2003/02/20 12:41:15 pierre
  740. + handle KNOWNCOMPILEERROR and KNOWNCOMPILE10ERROR
  741. Revision 1.25 2002/12/24 22:30:41 peter
  742. * small verbosity update
  743. Revision 1.24 2002/12/24 21:47:49 peter
  744. * NeedTarget, SkipTarget, SkipCPU added
  745. * Retrieve compiler info in a single call for 1.1 compiler
  746. Revision 1.23 2002/12/17 15:04:32 michael
  747. + Added dbdigest to store results in a database
  748. Revision 1.22 2002/12/15 13:30:46 peter
  749. * NEEDLIBRARY option to add -rpath to the linker for unix. This is
  750. needed to test runtime library tests. The library needs the -FE.
  751. option to place the .so in the correct directory
  752. Revision 1.21 2002/12/05 16:03:34 pierre
  753. + -X option to disable UseComSpec
  754. Revision 1.20 2002/11/18 16:42:43 pierre
  755. + KNOWNRUNERROR added
  756. Revision 1.19 2002/11/18 01:31:07 pierre
  757. + use -n option
  758. + use -G- for only graph
  759. + use -I- for only interactive
  760. + use -K- for only known bugs.
  761. Revision 1.18 2002/11/14 10:36:12 pierre
  762. * add internalerror info to log file
  763. Revision 1.17 2002/11/13 15:26:24 pierre
  764. + digest program added
  765. Revision 1.16 2002/11/13 15:19:44 pierre
  766. log strings moved to teststr unit
  767. Revision 1.15 2002/09/07 15:40:56 peter
  768. * old logs removed and tabs fixed
  769. Revision 1.14 2002/04/21 18:15:32 peter
  770. * Check for internal errors
  771. Revision 1.13 2002/03/03 13:27:28 hajny
  772. + added support for OS/2 units (.ppo)
  773. Revision 1.12 2002/01/29 13:24:16 pierre
  774. + also generate .elg file for units
  775. Revision 1.11 2002/01/29 12:51:08 pierre
  776. + PPFileInfo to also display time stamp of test file
  777. * generate .elg file in several cases
  778. to avoid trying to recompute the same test
  779. over and over again.
  780. }