dotest.pp 24 KB

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