utests.pp 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976
  1. {$mode objfpc}
  2. {$h+}
  3. unit utests;
  4. interface
  5. uses
  6. cgiapp,
  7. sysutils,mysql55conn,sqldb,whtml,dbwhtml,db,
  8. tresults,
  9. Classes,ftFont,fpimage,fpimgcanv,fpWritePng,fpcanvas;
  10. const
  11. TestsuiteURLPrefix='http://www.freepascal.org/testsuite/';
  12. TestsuiteBin='testsuite.cgi';
  13. ViewURL='http://svn.freepascal.org/cgi-bin/viewvc.cgi/';
  14. ViewRevURL='http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=';
  15. TestsSubDir='/tests/';
  16. DataBaseSubDir='/packages/fcl-db/tests/';
  17. var
  18. TestsuiteCGIURL : string;
  19. Type
  20. TTestSuite = Class(TCgiApplication)
  21. Private
  22. FHTMLWriter : THtmlWriter;
  23. FComboBoxProducer : TComboBoxProducer;
  24. FDB : TSQLConnection;
  25. FTrans : TSQLTransaction;
  26. FRunID,
  27. FCompareRunID,
  28. FPreviousRunID,
  29. FNextRunID,
  30. FPrevious2RunID,
  31. FNext2RunID,
  32. FTestFileID,
  33. FTestFileName,
  34. FVersion,
  35. FVersionBranch,
  36. FCond,
  37. FSubmitter,
  38. FMachine,
  39. FComment,
  40. FCPU,
  41. FCategory,
  42. FOS : String;
  43. FViewVCURL : String;
  44. FDate : TDateTime;
  45. FDebug,
  46. FListAll,
  47. FNoSkipped,
  48. FOnlyFailed : Boolean;
  49. FRunSkipCount,
  50. FRunFailedCount,
  51. FRunCount : Integer;
  52. FAction,
  53. FLimit : Integer;
  54. FTestLastDays : Integer;
  55. FNeedEnd : boolean;
  56. Procedure GetOverviewRowAttr(Sender : TObject; Var BGColor : String;
  57. Var Align : THTMLAlign; Var VAlign : THTMLValign;
  58. Var CustomAttr : String) ;
  59. Procedure GetRunRowAttr(Sender : TObject; Var BGColor : String;
  60. Var Align : THTMLAlign; Var VAlign : THTMLValign;
  61. Var CustomAttr : String) ;
  62. Procedure FormatFailedOverview(Sender : TObject; Var CellData : String);
  63. Procedure FormatTestRunOverview(Sender : TObject; Var CellData : String);
  64. Procedure FormatFileDetails(Sender: TObject; var CellData: String);
  65. Procedure FormatFileIDDetails(Sender: TObject; var CellData: String);
  66. Procedure FormatTestResult(Sender: TObject; var CellData: String);
  67. Procedure FormatSVN(Sender: TObject; var CellData: String);
  68. Procedure FormatSVNData(var CellData: String);
  69. Function FormatDetailURL(const RunIdStr, CellData : String) : string;
  70. Procedure DoDrawPie(Img : TFPCustomImage; Skipped,Failed,Total : Integer);
  71. Public
  72. Function CreateDataset(Qry : String) : TSQLQuery;
  73. Function CreateTableProducer(DS : TDataset) :TTableProducer;
  74. Procedure DefaultTableFromQuery(Qry,ALink : String; IncludeRecordCount : Boolean);
  75. Procedure ComboBoxFromQuery(Const ComboName,Qry : String);
  76. Procedure ComboBoxFromQuery(Const ComboName,Qry,Value : String);
  77. Function GetSingleTon(Const Qry : String) : String;
  78. Function GetOSName(ID : String) : String;
  79. Function GetCPUName(ID : String) : String;
  80. Function GetVersionName(ID : String) : String;
  81. Function GetCategoryName(ID : String) : String;
  82. Function GetTestFileName(ID : String) : String;
  83. Function GetPreviousRunID(RunID : String) : String;
  84. Function GetNextRunID(RunID : String) : String;
  85. Function GetFailCount(RunID : longint) : string;
  86. Function InitCGIVars : Integer;
  87. Procedure DoRun; override;
  88. Procedure EmitDocType;
  89. Procedure EmitOverviewForm;
  90. Procedure EmitHistoryForm;
  91. Procedure ShowRunResults;
  92. Procedure ShowRunComparison;
  93. Procedure ShowOneTest;
  94. Procedure ShowHistory;
  95. Function ConnectToDB : Boolean;
  96. procedure DisconnectFromDB;
  97. Procedure EmitTitle(ATitle : String);
  98. Procedure EmitEnd;
  99. Procedure ShowRunOverview;
  100. Procedure CreateRunPie;
  101. Function ShowRunData : Boolean;
  102. Procedure LDump(Const St : String);
  103. Procedure LDumpLn(Const St : String);
  104. end;
  105. implementation
  106. uses
  107. wformat,
  108. dateutils;
  109. Const
  110. {$i utests.cfg}
  111. { if utests.cfg is missed, create one with the following contents:
  112. DefDatabase = 'TESTSUITE';
  113. DefHost = '';
  114. DefDBUser = ''; // fill this in when compiling.
  115. DefPassword = ''; // fill this in, too.
  116. }
  117. Const
  118. OldTestResultsTableName = 'OLDTESTRESULTS';
  119. NewTestResultsTableName = 'TESTRESULTS';
  120. LastOldTestRun = 91178;
  121. MaxLimit = 1000;
  122. const
  123. faction_show_overview = 0;
  124. faction_show_run_results = 1;
  125. faction_show_run_pie = 2;
  126. faction_show_one_test = 3;
  127. faction_show_history = 4;
  128. faction_compare_with_previous = 5;
  129. faction_compare_with_next = 6;
  130. faction_compare2_with_previous = 7;
  131. faction_compare2_with_next = 8;
  132. Function TestResultsTableName(const RunId : String) : string;
  133. var
  134. RunIDVal : qword;
  135. Error : word;
  136. begin
  137. system.val (RunId,RunIdVal,error);
  138. if (error<>0) then
  139. result:='ErrorTable'
  140. else if (RunIdVal <= LastOldTestRun) then
  141. result:=OldTestResultsTableName
  142. else
  143. result:=NewTestResultsTableName;
  144. end;
  145. Var
  146. SDetailsURL : string;
  147. type
  148. known_versions = (
  149. ver_unknown,
  150. ver_1_0_10,
  151. ver_2_0_0,
  152. ver_2_0_1,
  153. ver_2_0_2,
  154. ver_2_0_3,
  155. ver_2_0_4,
  156. ver_2_0_5,
  157. ver_2_1_2,
  158. ver_2_1_4,
  159. ver_2_2_0,
  160. ver_2_2_1,
  161. ver_2_2_2,
  162. ver_2_2_3,
  163. ver_2_2_4,
  164. ver_2_2_5,
  165. ver_2_3_1,
  166. ver_2_4_0,
  167. ver_2_4_1,
  168. ver_2_4_2,
  169. ver_2_4_3,
  170. ver_2_4_4,
  171. ver_2_4_5,
  172. ver_2_5_1,
  173. ver_2_6_0,
  174. ver_2_6_1,
  175. ver_2_6_2,
  176. ver_2_6_3,
  177. ver_2_7_1);
  178. const
  179. ver_trunk = high (known_versions);
  180. const
  181. ver_string : array[known_versions] of string =
  182. (
  183. 'unknown',
  184. '1.0.10',
  185. '2.0.0',
  186. '2.0.1',
  187. '2.0.2',
  188. '2.0.3',
  189. '2.0.4',
  190. '2.0.5',
  191. '2.1.2',
  192. '2.1.4',
  193. '2.2.0',
  194. '2.2.1',
  195. '2.2.2',
  196. '2.2.3',
  197. '2.2.4',
  198. '2.2.5',
  199. '2.3.1',
  200. '2.4.0',
  201. '2.4.1',
  202. '2.4.2',
  203. '2.4.3',
  204. '2.4.4',
  205. '2.4.5',
  206. '2.5.1',
  207. '2.6.0',
  208. '2.6.1',
  209. '2.6.2',
  210. '2.6.3',
  211. '2.7.1'
  212. );
  213. ver_branch : array [known_versions] of string =
  214. (
  215. '',
  216. '',
  217. 'tags/release_2_0_0',
  218. 'branches/fixes_2_0',
  219. 'tags/release_2_0_2',
  220. 'branches/fixes_2_0',
  221. 'tags/release_2_0_4',
  222. 'branches/fixes_2_0',
  223. 'tags/release_2_1_2',
  224. 'tags/release_2_1_4',
  225. 'tags/release_2_2_0',
  226. 'branches/fixes_2_2',
  227. 'tags/release_2_2_2',
  228. 'branches/fixes_2_2',
  229. 'tags/release_2_2_4',
  230. 'branches/fixes_2_2',
  231. 'tags/release_2_4_0',
  232. 'tags/release_2_4_0',
  233. 'tags/release_2_4_2',
  234. 'tags/release_2_4_2',
  235. 'tags/release_2_4_4',
  236. 'tags/release_2_4_4',
  237. 'branches/fixes_2_4',
  238. 'tags/release_2_6_0',
  239. 'tags/release_2_6_0',
  240. 'tags/release_2_6_2',
  241. 'tags/release_2_6_2',
  242. 'branches/fixes_2_6',
  243. 'trunk'
  244. );
  245. Procedure TTestSuite.DoRun;
  246. begin
  247. Try
  248. Try
  249. Case InitCGIVars of
  250. faction_show_overview : EmitOverviewForm;
  251. faction_show_run_results :
  252. if Length(FCompareRunID) = 0 then
  253. ShowRunResults
  254. else
  255. ShowRunComparison;
  256. faction_show_run_pie : CreateRunPie;
  257. faction_show_one_test : ShowOneTest;
  258. faction_show_history : ShowHistory;
  259. faction_compare_with_previous :
  260. begin
  261. FCompareRunID:=FRunID;
  262. FRunID:=FPreviousRunID;
  263. ShowRunComparison;
  264. end;
  265. faction_compare_with_next :
  266. begin
  267. FCompareRunID:=FNextRunID;
  268. ShowRunComparison;
  269. end;
  270. faction_compare2_with_previous :
  271. begin
  272. FRunID:=FPrevious2RunID;
  273. ShowRunComparison;
  274. end;
  275. faction_compare2_with_next :
  276. begin
  277. FRunID:=FCompareRunID;
  278. FCompareRunID:=FNext2RunID;
  279. ShowRunComparison;
  280. end;
  281. {$ifdef TEST}
  282. 98 :
  283. begin
  284. ///EmitOverviewForm;
  285. system.Writeln(stdout,'<PRE>');
  286. system.Writeln(stdout,'paramstr(0) is ',paramstr(0));
  287. system.FreeMem(pointer($ffffffff));
  288. system.Writeln(stdout,'</PRE>');
  289. system.Flush(stdout);
  290. end;
  291. 99 :
  292. begin
  293. EmitOverviewForm;
  294. system.Writeln(stdout,'<PRE>');
  295. system.Dump_stack(stdout,get_frame);
  296. system.Writeln(stdout,'</PRE>');
  297. system.Flush(stdout);
  298. end;
  299. {$endif TEST}
  300. end;
  301. finally
  302. EmitEnd;
  303. DisConnectFromDB;
  304. end;
  305. Finally
  306. Terminate;
  307. end;
  308. end;
  309. Function TTestSuite.InitCGIVars : Integer;
  310. Var
  311. S : String;
  312. begin
  313. FHtmlWriter:=THTMLWriter.Create(Response);
  314. FComboBoxProducer:=TComboBoxProducer.Create(Self);
  315. DateSeparator:='/';
  316. Result:=0;
  317. S:=RequestVariables['action'];
  318. if Length(S) = 0 then
  319. S:=RequestVariables['TESTACTION'];
  320. if S='View_history' then
  321. FAction:=faction_show_history
  322. else if S='Show/Compare' then
  323. FAction:=faction_show_run_results
  324. else if S='Compare_to_previous' then
  325. FAction:=faction_compare_with_previous
  326. else if S='Compare_to_next' then
  327. FAction:=faction_compare_with_next
  328. else if S='Compare_right_to_previous' then
  329. FAction:=faction_compare2_with_previous
  330. else if S='Compare_right_to_next' then
  331. FAction:=faction_compare2_with_next
  332. else
  333. FAction:=StrToIntDef(S,0);
  334. S:=RequestVariables['limit'];
  335. if Length(S) = 0 then
  336. S:=RequestVariables['TESTLIMIT'];
  337. FLimit:=StrToIntDef(S,50);
  338. if FLimit > MaxLimit then
  339. FLimit:=MaxLimit;
  340. FVersion:=RequestVariables['version'];
  341. if Length(FVersion) = 0 then
  342. FVersion:=RequestVariables['TESTVERSION'];
  343. FOS:=RequestVariables['os'];
  344. if Length(FOS) = 0 then
  345. FOS:=RequestVariables['TESTOS'];
  346. FCPU:=RequestVariables['cpu'];
  347. if Length(FCPU) = 0 then
  348. FCPU:=RequestVariables['TESTCPU'];
  349. FCategory:=RequestVariables['category'];
  350. if Length(FCategory) = 0 then
  351. FCategory:=RequestVariables['TESTCATEGORY'];
  352. FCond:=RequestVariables['cond'];
  353. if Length(FCond) = 0 then
  354. FCond:=RequestVariables['TESTCOND'];
  355. FComment:=RequestVariables['comment'];
  356. if Length(FComment) = 0 then
  357. FComment:=RequestVariables['TESTCOMMENT'];
  358. FSubmitter:=RequestVariables['submitter'];
  359. if Length(FSubmitter) = 0 then
  360. FSubmitter:=RequestVariables['TESTSUBMITTER'];
  361. FMachine:=RequestVariables['machine'];
  362. if Length(FMachine) = 0 then
  363. FMachine:=RequestVariables['TESTMACHINE'];
  364. FRunID:=RequestVariables['run1id'];
  365. if Length(FRunID) = 0 then
  366. FRunID:=RequestVariables['TESTRUN'];
  367. S:=RequestVariables['lastdays'];
  368. if Length(S) = 0 then
  369. S:=RequestVariables['TESTLASTDAYS'];
  370. FTestLastDays:=StrToIntDef(S,31);
  371. S:=RequestVariables['date'];
  372. if Length(S) = 0 then
  373. S:=RequestVariables['TESTDATE'];
  374. if Length(S) > 0 then
  375. try
  376. FDate:=StrToDate(S);
  377. except
  378. FDate:=0;
  379. end;
  380. S:=RequestVariables['failedonly'];
  381. if Length(S) = 0 then
  382. S:=RequestVariables['TESTFAILEDONLY'];
  383. FOnlyFailed:=(S='1');
  384. S:=RequestVariables['noskipped'];
  385. if Length(S) = 0 then
  386. S:=RequestVariables['TESTNOSKIPPED'];
  387. FNoSkipped:=(S='1');
  388. FCompareRunID:=RequestVariables['run2id'];
  389. FPreviousRunID:=RequestVariables['previousrunid'];
  390. FNextRunID:=RequestVariables['nextrunid'];
  391. FPrevious2RunID:=RequestVariables['previous2runid'];
  392. FNext2RunID:=RequestVariables['next2runid'];
  393. FTestFileID:=RequestVariables['testfileid'];
  394. FTestFileName:=RequestVariables['testfilename'];
  395. FRunCount:=StrToIntDef(RequestVariables['PIETOTAL'],0);
  396. FRunSkipCount:=StrToIntDef(RequestVariables['PIESKIPPED'],0);
  397. FRunFailedCount:=StrToIntDef(RequestVariables['PIEFAILED'],0);
  398. S:=RequestVariables['DEBUGCGI'];
  399. FDebug:=(S='1');
  400. S:=RequestVariables['listall'];
  401. FListAll:=(S='1');
  402. Result:=FAction;
  403. end;
  404. Function TTestSuite.ConnectToDB : Boolean;
  405. begin
  406. Result:=False;
  407. FDB:=TMySQl55Connection.Create(Self);
  408. FDB.HostName:=DefHost;
  409. FDB.DatabaseName:=DefDatabase;
  410. FDB.UserName:=DefDBUser;
  411. FDB.Password:=DefPassword;
  412. FTrans := TSQLTransaction.Create(nil);
  413. FTrans.DataBase := FDB;
  414. FDB.Transaction := FTrans;
  415. FDB.Connected:=True;
  416. Result:=True;
  417. end;
  418. procedure TTestsuite.LDump(Const St : String);
  419. var
  420. S : String;
  421. ShortS : ShortString;
  422. i,p : longint;
  423. begin
  424. i:=length(St);
  425. p:=1;
  426. while (i>255) do
  427. begin
  428. ShortS:=copy(St,p,255);
  429. inc(p,255);
  430. dec(i,255);
  431. FHTMLWriter.Dump(ShortS);
  432. end;
  433. ShortS:=Copy(St,p,255);
  434. FHTMLWriter.Dump(ShortS);
  435. end;
  436. procedure TTestsuite.LDumpLn(Const St : String);
  437. begin
  438. LDump(St);
  439. LDump(LineFeed);
  440. end;
  441. procedure TTestSuite.DisconnectFromDB;
  442. begin
  443. If Assigned(FDB) then
  444. begin
  445. if (FDB.Connected) then
  446. FDB.Connected:=False;
  447. FreeAndNil(FDB);
  448. FreeAndNil(FTrans);
  449. end;
  450. end;
  451. Procedure TTestSuite.ComboBoxFromQuery(Const ComboName,Qry: String);
  452. begin
  453. ComboBoxFromQuery(ComboName,Qry,'')
  454. end;
  455. Procedure TTestSuite.ComboBoxFromQuery(Const ComboName,Qry,Value : String);
  456. Var
  457. Q : TSQLQuery;
  458. begin
  459. Q:=TSQLQuery.Create(Self);
  460. try
  461. Q.Database:=FDB;
  462. Q.Transaction:=FTrans;
  463. Q.SQL.Text:=Qry;
  464. Q.Open;
  465. FComboboxProducer.Dataset:=Q;
  466. FComboBoxProducer.ValueField:=Q.Fields[0].FieldName;
  467. FComboBoxProducer.DataField:=Q.Fields[1].FieldName;
  468. FComboBoxProducer.Value:=Value;
  469. FComboBoxProducer.InputName:=ComboName;
  470. FComboBoxProducer.CreateComboBox(Response);
  471. Finally
  472. Q.Free;
  473. end;
  474. end;
  475. Function TTestSuite.GetSingleton(Const Qry : String) : String;
  476. Var
  477. Q : TSQLQuery;
  478. begin
  479. Result:='';
  480. if FDEbug then
  481. begin
  482. system.Writeln('Query=',Qry);
  483. system.flush(output);
  484. end;
  485. Q:=TSQLQuery.Create(Self);
  486. try
  487. Q.Database:=FDB;
  488. Q.Transaction:=FTrans;
  489. Q.SQL.Text:=Qry;
  490. Q.Open;
  491. Try
  492. if FDebug and (Q.FieldCount<>1) then
  493. begin
  494. system.Writeln('GetSingleton number of fields is not 1, but ',
  495. Q.FieldCount);
  496. system.flush(output);
  497. end;
  498. If Not (Q.EOF and Q.BOF) then
  499. Result:=Q.Fields[0].AsString;
  500. Finally
  501. Q.Close;
  502. end;
  503. finally
  504. Q.Free;
  505. end;
  506. end;
  507. Procedure TTestSuite.EmitTitle(ATitle : String);
  508. begin
  509. AddResponseLn('<HTML>');
  510. AddResponseLn('<TITLE>'+ATitle+'</TITLE>');
  511. AddResponseLn('<BODY>');
  512. FNeedEnd:=true;
  513. end;
  514. Procedure TTestSuite.EmitDocType;
  515. begin
  516. AddResponseLn('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" '+
  517. '"http://www.w3.org/TR/html4/loose.dtd">');
  518. end;
  519. Procedure TTestSuite.EmitOverviewForm;
  520. begin
  521. ConnectToDB;
  522. ContentType:='text/html';
  523. EmitContentType;
  524. EmitDocType;
  525. EmitTitle(Title);
  526. With FHTMLWriter do
  527. begin
  528. HeaderStart(1);
  529. DumpLn('View Test suite results');
  530. HeaderEnd(1);
  531. DumpLn('Please specify search criteria:');
  532. ParagraphStart;
  533. FormStart(TestsuiteCGIURL,'');
  534. if FDebug then
  535. EmitHiddenVar('DEBUGCGI', '1');
  536. TableStart(2,true);
  537. RowStart;
  538. CellStart;
  539. DumpLn('Operating system:');
  540. CellNext;
  541. ComboBoxFromQuery('os','SELECT TO_ID,TO_NAME FROM TESTOS ORDER BY TO_NAME',FOS);
  542. CellEnd;
  543. RowNext;
  544. CellStart;
  545. DumpLn('Processor:');
  546. CellNext;
  547. ComboBoxFromQuery('cpu','SELECT TC_ID,TC_NAME FROM TESTCPU ORDER BY TC_NAME',FCPU);
  548. CellEnd;
  549. RowNext;
  550. CellStart;
  551. DumpLn('Version');
  552. CellNext;
  553. ComboBoxFromQuery('version','SELECT TV_ID,TV_VERSION FROM TESTVERSION ORDER BY TV_VERSION DESC',FVERSION);
  554. CellEnd;
  555. RowNext;
  556. CellStart;
  557. DumpLn('Date');
  558. CellNext;
  559. If (FDate=0) then
  560. EmitInput('date','')
  561. else
  562. EmitInput('date',DateToStr(FDate));
  563. CellEnd;
  564. //if FDebug then
  565. begin
  566. RowNext;
  567. CellStart;
  568. DumpLn('Submitter');
  569. CellNext;
  570. If (FSubmitter='') then
  571. EmitInput('submitter','')
  572. else
  573. EmitInput('submitter',FSubmitter);
  574. CellEnd;
  575. RowNext;
  576. CellStart;
  577. DumpLn('Machine');
  578. CellNext;
  579. If (FMachine='') then
  580. EmitInput('machine','')
  581. else
  582. EmitInput('machine',FMachine);
  583. CellEnd;
  584. RowNext;
  585. CellStart;
  586. DumpLn('Comment');
  587. CellNext;
  588. If (FComment='') then
  589. EmitInput('comment','')
  590. else
  591. EmitInput('comment',FComment);
  592. CellEnd;
  593. RowNext;
  594. CellStart;
  595. DumpLn('Cond');
  596. CellNext;
  597. If (FCond='') then
  598. EmitInput('cond','')
  599. else
  600. EmitInput('cond',FCond);
  601. CellEnd;
  602. end;
  603. RowNext;
  604. CellStart;
  605. DumpLn('Category');
  606. CellNext;
  607. ComboBoxFromQuery('Category','SELECT TCAT_ID,TCAT_NAME FROM TESTCATEGORY ORDER BY TCAT_NAME',FCategory);
  608. CellEnd;
  609. RowNext;
  610. CellStart;
  611. DumpLn('Only failed tests');
  612. CellNext;
  613. EmitCheckBox('failedonly','1',FonlyFailed);
  614. CellEnd;
  615. RowNext;
  616. CellStart;
  617. DumpLn('Hide skipped tests');
  618. CellNext;
  619. EmitCheckBox('noskipped','1',FNoSkipped);
  620. CellEnd;
  621. RowEnd;
  622. TableEnd;
  623. ParaGraphStart;
  624. EmitSubmitButton('','Search');
  625. EmitSubmitButton('action','View history');
  626. EmitResetButton('','Reset form');
  627. FormEnd;
  628. end;
  629. ShowRunOverview;
  630. end;
  631. Procedure TTestSuite.EmitHistoryForm;
  632. begin
  633. ConnectToDB;
  634. ContentType:='text/html';
  635. EmitContentType;
  636. EmitDocType;
  637. EmitTitle(Title);
  638. With FHTMLWriter do
  639. begin
  640. HeaderStart(1);
  641. DumpLn('View Test suite results');
  642. HeaderEnd(1);
  643. DumpLn('Please specify search criteria:');
  644. ParagraphStart;
  645. FormStart(TestsuiteCGIURL,'');
  646. if FDebug then
  647. EmitHiddenVar('DEBUGCGI', '1');
  648. EmitHiddenVar('action',IntToStr(faction_show_history));
  649. TableStart(2,true);
  650. RowStart;
  651. CellStart;
  652. DumpLn('File:');
  653. CellNext;
  654. EmitInput('testfilename',FTestfilename);
  655. CellEnd;
  656. RowNext;
  657. (* CellStart;
  658. DumpLn('FileID:');
  659. CellNext;
  660. EmitInput('testfileid',FTestfileid);
  661. CellEnd;
  662. RowNext; *)
  663. CellStart;
  664. DumpLn('Operating system:');
  665. CellNext;
  666. ComboBoxFromQuery('os','SELECT TO_ID,TO_NAME FROM TESTOS ORDER BY TO_NAME',FOS);
  667. CellEnd;
  668. RowNext;
  669. CellStart;
  670. DumpLn('Processor:');
  671. CellNext;
  672. ComboBoxFromQuery('cpu','SELECT TC_ID,TC_NAME FROM TESTCPU ORDER BY TC_NAME',FCPU);
  673. CellEnd;
  674. RowNext;
  675. CellStart;
  676. DumpLn('Version');
  677. CellNext;
  678. ComboBoxFromQuery('version','SELECT TV_ID,TV_VERSION FROM TESTVERSION ORDER BY TV_VERSION DESC',FVERSION);
  679. CellEnd;
  680. RowNext;
  681. CellStart;
  682. DumpLn('Date');
  683. CellNext;
  684. If (FDate=0) then
  685. EmitInput('date','')
  686. else
  687. EmitInput('date',DateToStr(FDate));
  688. CellEnd;
  689. RowNext;
  690. CellStart;
  691. DumpLn('Submitter');
  692. CellNext;
  693. If (FSubmitter='') then
  694. EmitInput('submitter','')
  695. else
  696. EmitInput('submitter',FSubmitter);
  697. CellEnd;
  698. RowNext;
  699. CellStart;
  700. DumpLn('Machine');
  701. CellNext;
  702. If (FMachine='') then
  703. EmitInput('machine','')
  704. else
  705. EmitInput('machine',FMachine);
  706. CellEnd;
  707. RowNext;
  708. CellStart;
  709. DumpLn('Comment');
  710. CellNext;
  711. If (FComment='') then
  712. EmitInput('comment','')
  713. else
  714. EmitInput('comment',FComment);
  715. CellEnd;
  716. RowNext;
  717. CellStart;
  718. DumpLn('Limit');
  719. CellNext;
  720. EmitInput('limit',IntToStr(FLimit));
  721. CellEnd;
  722. RowNext;
  723. CellStart;
  724. DumpLn('Cond');
  725. CellNext;
  726. If (FCond='') then
  727. EmitInput('cond','')
  728. else
  729. EmitInput('cond',FCond);
  730. CellEnd;
  731. RowNext;
  732. CellStart;
  733. DumpLn('Category');
  734. CellNext;
  735. ComboBoxFromQuery('Category','SELECT TCAT_ID,TCAT_NAME FROM TESTCATEGORY ORDER BY TCAT_NAME',FCategory);
  736. CellEnd;
  737. RowNext;
  738. CellStart;
  739. DumpLn('Only failed tests');
  740. CellNext;
  741. EmitCheckBox('failedonly','1',FonlyFailed);
  742. CellEnd;
  743. RowNext;
  744. CellStart;
  745. DumpLn('Hide skipped tests');
  746. CellNext;
  747. EmitCheckBox('noskipped','1',FNoSkipped);
  748. CellEnd;
  749. RowNext;
  750. CellStart;
  751. DumpLn('List all tests');
  752. CellNext;
  753. EmitCheckBox('listall','1',FListAll);
  754. CellEnd;
  755. RowEnd;
  756. TableEnd;
  757. ParaGraphStart;
  758. if FDebug then
  759. EmitHiddenVar('DEBUGCGI', '1');
  760. EmitSubmitButton('','Search');
  761. EmitResetButton('','Reset form');
  762. FormEnd;
  763. end;
  764. end;
  765. procedure TTestSuite.EmitEnd;
  766. begin
  767. if not FNeedEnd then
  768. exit;
  769. AddResponseLn('</BODY>');
  770. AddResponseLn('</HTML>');
  771. end;
  772. procedure TTestSuite.GetOverviewRowAttr(Sender: TObject; var BGColor: String;
  773. var Align: THTMLAlign; var VAlign: THTMLValign; var CustomAttr: String);
  774. begin
  775. If ((Sender as TTAbleProducer).CurrentRow mod 2=0) then
  776. BGColor:='#EEEEEE'
  777. end;
  778. Function TTestSuite.CreateDataset(Qry : String) : TSQLQuery;
  779. begin
  780. Result:=TSQLQuery.Create(Self);
  781. With Result do
  782. begin
  783. Database:=FDB;
  784. Transaction := FTrans;
  785. SQL.Text:=Qry;
  786. end;
  787. end;
  788. Function TTestSuite.CreateTableProducer(DS : TDataset) :TTableProducer;
  789. begin
  790. Result:=TTableProducer.Create(Self);
  791. Result.Dataset:=DS;
  792. end;
  793. Procedure TTestSuite.DefaultTableFromQuery(Qry,Alink : String; IncludeRecordCount : Boolean);
  794. Var
  795. Q : TSQLQuery;
  796. begin
  797. If FDebug then
  798. Writeln('Query : '+Qry);
  799. Q:=CreateDataset(Qry);
  800. With Q do
  801. try
  802. Open;
  803. Try
  804. With CreateTableProducer(Q) do
  805. Try
  806. Border:=True;
  807. If (Alink<>'') then
  808. begin
  809. CreateColumns(Nil);
  810. If TableColumns.Count>0 then
  811. (TableColumns.Items[0] as TTableColumn).ActionURL:=ALink;
  812. end;
  813. CreateTable(Response);
  814. Finally
  815. Free;
  816. end;
  817. If IncludeRecordCount then
  818. FHTMLWriter.DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
  819. Finally
  820. Close;
  821. end;
  822. finally
  823. Free;
  824. end;
  825. end;
  826. Procedure TTestSuite.ShowRunOverview;
  827. Const
  828. SOverview = 'SELECT TU_ID as ID,TU_DATE as Date,TC_NAME as CPU,TO_NAME as OS,'+
  829. 'TV_VERSION as Version,count(*) as Count,'+
  830. 'TU_SVNCOMPILERREVISION as SvnCompRev,'+
  831. 'TU_SVNRTLREVISION as SvnRTLRev,'+
  832. 'TU_SVNPACKAGESREVISION as SvnPackRev,TU_SVNTESTSREVISION as SvnTestsRev,'+
  833. '(TU_SUCCESSFULLYFAILED+TU_SUCCESFULLYCOMPILED+TU_SUCCESSFULLYRUN) AS OK,'+
  834. '(TU_FAILEDTOCOMPILE+TU_FAILEDTORUN+TU_FAILEDTOFAIL) as Failed,'+
  835. '(TU_SUCCESSFULLYFAILED+TU_SUCCESFULLYCOMPILED+TU_SUCCESSFULLYRUN+'+
  836. 'TU_FAILEDTOCOMPILE+TU_FAILEDTORUN+TU_FAILEDTOFAIL) as Total,'+
  837. 'TU_SUBMITTER as Submitter, TU_MACHINE as Machine, TU_COMMENT as Comment %s '+
  838. 'FROM TESTRUN left join TESTCPU on (TC_ID=TU_CPU_FK) left join TESTOS on (TO_ID=TU_OS_FK) '+
  839. 'left join TESTVERSION on (TV_ID=TU_VERSION_FK) left join TESTCATEGORY on (TCAT_ID=TU_CATEGORY_FK) '+
  840. 'left join TESTRESULTS on (TR_TESTRUN_FK=TU_ID) '+
  841. '%s'+
  842. 'GROUP BY TU_ID '+
  843. 'ORDER BY TU_ID DESC LIMIT %d';
  844. Var
  845. SC,S,A,Qry : String;
  846. Q : TSQLQuery;
  847. begin
  848. S:='';
  849. If (FCPU<>'') and (GetCPUName(FCPU)<>'All') then
  850. S:=S+' AND (TU_CPU_FK='+FCPU+')';
  851. If (FCategory<>'') and (GetCategoryName(FCategory)<>'All') then
  852. S:=S+' AND (TU_CATEGORY_FK='+FCategory+')';
  853. If (FVersion<>'') and (GetVersionName(FVersion)<>'All') then
  854. S:=S+' AND (TU_VERSION_FK='+FVERSION+')';
  855. if (FOS<>'') and (GetOSName(FOS)<>'All') then
  856. S:=S+' AND (TU_OS_FK='+FOS+')';
  857. If (Round(FDate)<>0) then
  858. S:=S+' AND (TU_DATE LIKE '''+FormatDateTime('YYYY-MM-DD',FDate)+'%'')';
  859. If FSubmitter<>'' then
  860. S:=S+' AND (TU_SUBMITTER='''+FSubmitter+''')';
  861. If FMachine<>'' then
  862. S:=S+' AND (TU_MACHINE='''+FMachine+''')';
  863. If FComment<>'' then
  864. S:=S+' AND (TU_COMMENT LIKE '''+Fcomment+''')';
  865. If FCond<>'' then
  866. S:=S+' AND ('+FCond+')';
  867. If FOnlyFailed then
  868. S:=S+' AND (TR_OK="-")';
  869. If GetCategoryName(FCategory)<>'DB' then
  870. SC:=', CONCAT(TU_SVNCOMPILERREVISION,"/",TU_SVNRTLREVISION,"/", '+
  871. 'TU_SVNPACKAGESREVISION,"/",TU_SVNTESTSREVISION) as svnrev'
  872. else
  873. SC:='';
  874. If (FCategory='') or (GetCategoryName(FCategory)='All') then
  875. SC:=SC+', TCAT_NAME as Cat';
  876. A:=SDetailsURL;
  877. If FOnlyFailed then
  878. A:=A+'&amp;failedonly=1';
  879. If FNoSkipped then
  880. A:=A+'&amp;noskipped=1';
  881. if S <> '' then
  882. begin
  883. Delete(S, 1, 4);
  884. S:='WHERE '+ S + ' ';
  885. end;
  886. Qry:=Format(SOverview,[SC,S,FLimit]);
  887. If FDebug then
  888. Writeln('Query : '+Qry);
  889. Q:=CreateDataset(Qry);
  890. With Q do
  891. try
  892. Open;
  893. Try
  894. With CreateTableProducer(Q) do
  895. Try
  896. Border:=True;
  897. OnGetRowAttributes:=@GetOverViewRowAttr;
  898. CreateColumns(Nil);
  899. TableColumns.ColumnByName('ID').ActionURL:=A;
  900. TableColumns.ColumnByNAme('Failed').OnGetCellContents:=@FormatFailedOverview;
  901. TableColumns.ColumnByNAme('svnrev').OnGetCellContents:=@FormatSVN;
  902. CreateTable(Response);
  903. Finally
  904. Free;
  905. end;
  906. FHTMLWriter.DumpLn(Format('<p>Record count: %d</p>',[Q.RecordCount]));
  907. Finally
  908. Close;
  909. end;
  910. finally
  911. Free;
  912. end;
  913. end;
  914. Function TTestSuite.GetOSName(ID : String) : String;
  915. begin
  916. if (ID<>'') then
  917. Result:=GetSingleTon('SELECT TO_NAME FROM TESTOS WHERE TO_ID='+ID)
  918. else
  919. Result:='';
  920. end;
  921. Function TTestSuite.GetTestFileName(ID : String) : String;
  922. begin
  923. if (ID<>'') then
  924. Result:=GetSingleTon('SELECT T_NAME FROM TESTS WHERE T_ID='+ID)
  925. else
  926. Result:='';
  927. end;
  928. Function TTestsuite.GetFailCount(RunID : longint) : string;
  929. begin
  930. if RunID<>0 then
  931. Result:=GetSingleTon('SELECT (TU_FAILEDTOCOMPILE + TU_FAILEDTOFAIL + TU_FAILEDTORUN) FROM TESTRUN WHERE TU_ID='+IntToStr(RunID))
  932. else
  933. Result:='';
  934. end;
  935. Function TTestSuite.GetCPUName(ID : String) : String;
  936. begin
  937. if (ID<>'') then
  938. Result:=GetSingleTon('SELECT TC_NAME FROM TESTCPU WHERE TC_ID='+ID)
  939. else
  940. Result:='';
  941. end;
  942. Function TTestSuite.GetVersionName(ID : String) : String;
  943. begin
  944. if (ID<>'') then
  945. Result:=GetSingleton('SELECT TV_VERSION FROM TESTVERSION WHERE TV_ID='+ID)
  946. else
  947. Result:='';
  948. end;
  949. Function TTestSuite.GetCategoryName(ID : String) : String;
  950. begin
  951. if (ID<>'') then
  952. Result:=GetSingleton('SELECT TCAT_NAME FROM TESTCATEGORY WHERE TCAT_ID='+ID)
  953. else
  954. Result:='';
  955. end;
  956. Function TTestSuite.GetPreviousRunID(RunID : String) : String;
  957. begin
  958. if (RunID<>'') then
  959. Result:=GetSingleton('SELECT TH_PREVIOUS_FK FROM TESTRUNHISTORY WHERE TH_ID_FK='+RunID)
  960. else
  961. Result:='';
  962. end;
  963. Function TTestSuite.GetNextRunID(RunID : String) : String;
  964. begin
  965. if (RunID<>'') then
  966. Result:=GetSingleton('SELECT TH_ID_FK FROM TESTRUNHISTORY WHERE TH_PREVIOUS_FK='+RunID)
  967. else
  968. Result:='';
  969. end;
  970. Function TTestSuite.ShowRunData : Boolean;
  971. Const
  972. SGetRunData = 'SELECT TU_ID,TU_DATE,TC_NAME,TO_NAME,' +
  973. 'TU_SUBMITTER,TU_MACHINE,TU_COMMENT,TV_VERSION,'+
  974. 'TU_CATEGORY_FK,TU_SVNCOMPILERREVISION,TU_SVNRTLREVISION,'+
  975. 'TU_COMPILERDATE,'+
  976. 'TU_SVNPACKAGESREVISION,TU_SVNTESTSREVISION,'+
  977. '(TU_SUCCESSFULLYFAILED+TU_SUCCESFULLYCOMPILED+TU_SUCCESSFULLYRUN) AS OK,'+
  978. '(TU_FAILEDTOCOMPILE+TU_FAILEDTORUN+TU_FAILEDTOFAIL) as Failed,'+
  979. '(TU_SUCCESSFULLYFAILED+TU_SUCCESFULLYCOMPILED+TU_SUCCESSFULLYRUN+'+
  980. 'TU_FAILEDTOCOMPILE+TU_FAILEDTORUN+TU_FAILEDTOFAIL) as Total'+
  981. ' %s FROM TESTRUN,TESTCPU,TESTOS,TESTVERSION '+
  982. 'WHERE '+
  983. ' (TC_ID=TU_CPU_FK) AND '+
  984. ' (TO_ID=TU_OS_FK) AND '+
  985. ' (TV_ID=TU_VERSION_FK) AND '+
  986. ' (TU_ID=%s)';
  987. Var
  988. Q1,Q2 : TSQLQuery;
  989. F : TField;
  990. SC : string;
  991. Date1, Date2: TDateTime;
  992. AddNewPar : boolean;
  993. CompilerDate1, CompilerDate2: TDateTime;
  994. begin
  995. Result:=(FRunID<>'');
  996. If Result then
  997. begin
  998. If GetCategoryName(FCategory)<>'DB' then
  999. SC:=', CONCAT(TU_SVNCOMPILERREVISION,"/",TU_SVNRTLREVISION,"/", '+
  1000. 'TU_SVNPACKAGESREVISION,"/",TU_SVNTESTSREVISION) as svnrev'
  1001. else
  1002. SC:='';
  1003. If GetCategoryName(FCategory)='All' then
  1004. SC:=SC+', TCAT_NAME as Cat';
  1005. Q1:=CreateDataset(Format(SGetRunData,[SC,FRunID]));
  1006. if Length(FCompareRunID) > 0 then
  1007. Q2:=CreateDataset(Format(SGetRunData,[SC,FCompareRunID]))
  1008. else
  1009. Q2:=nil;
  1010. Try
  1011. Q1.Open;
  1012. if Q2 <> nil then
  1013. Q2.Open;
  1014. Result:=Not (Q1.EOF and Q1.BOF);
  1015. If Result then
  1016. With FHTMLWriter do
  1017. begin
  1018. FormStart(TestsuiteCGIURL,'get');
  1019. TableStart(3,true);
  1020. RowStart;
  1021. CellStart;
  1022. DumpLn('Run ID:');
  1023. CellNext;
  1024. EmitInput('run1id',FRunID);
  1025. CellNext;
  1026. EmitInput('run2id',FCompareRunID);
  1027. CellEnd;
  1028. RowNext;
  1029. CellStart;
  1030. DumpLn('Operating system:');
  1031. CellNext;
  1032. DumpLn(Q1.FieldByName('TO_NAME').AsString);
  1033. CellNext;
  1034. if Q2 <> nil then
  1035. DumpLn(Q2.FieldByName('TO_NAME').AsString);
  1036. CellEnd;
  1037. RowNext;
  1038. CellStart;
  1039. DumpLn('Processor:');
  1040. CellNext;
  1041. DumpLn(Q1.FieldByName('TC_NAME').AsString);
  1042. CellNext;
  1043. if Q2 <> nil then
  1044. DumpLn(Q2.FieldByName('TC_NAME').AsString);
  1045. CellEnd;
  1046. RowNext;
  1047. CellStart;
  1048. DumpLn('Version:');
  1049. CellNext;
  1050. DumpLn(Q1.FieldByNAme('TV_VERSION').AsString);
  1051. CellNext;
  1052. if Q2 <> nil then
  1053. DumpLn(Q2.FieldByNAme('TV_VERSION').AsString);
  1054. CellEnd;
  1055. RowNext;
  1056. CellStart;
  1057. DumpLn('Fails/OK/Total:');
  1058. CellNext;
  1059. Dump(Q1.FieldByName('Failed').AsString);
  1060. Dump('/'+Q1.FieldByName('OK').AsString);
  1061. DumpLn('/'+Q1.FieldByName('Total').AsString);
  1062. CellNext;
  1063. if Q2 <> nil then
  1064. begin
  1065. Dump(Q2.FieldByName('Failed').AsString);
  1066. Dump('/'+Q2.FieldByName('Ok').AsString);
  1067. DumpLn('/'+Q2.FieldByName('Total').AsString);
  1068. end;
  1069. CellEnd;
  1070. RowNext;
  1071. CellStart;
  1072. DumpLn('Comment:');
  1073. CellNext;
  1074. DumpLn(Q1.FieldByName('TU_COMMENT').AsString);
  1075. CellNext;
  1076. if Q2 <> nil then
  1077. DumpLn(Q2.FieldByName('TU_COMMENT').AsString);
  1078. CellEnd;
  1079. RowNext;
  1080. CellStart;
  1081. DumpLn('Machine:');
  1082. CellNext;
  1083. DumpLn(Q1.FieldByName('TU_MACHINE').AsString);
  1084. CellNext;
  1085. if Q2 <> nil then
  1086. DumpLn(Q2.FieldByName('TU_MACHINE').AsString);
  1087. CellEnd;
  1088. if GetCategoryName(FCategory)<>'All' then
  1089. begin
  1090. RowNext;
  1091. CellStart;
  1092. DumpLn('Category:');
  1093. CellNext;
  1094. DumpLn(GetCategoryName(Q1.FieldByName('TU_CATEGORY_FK').AsString));
  1095. CellNext;
  1096. if Q2 <> nil then
  1097. DumpLn(GetCategoryName(Q2.FieldByName('TU_CATEGORY_FK').AsString));
  1098. CellEnd;
  1099. end;
  1100. If GetCategoryName(FCategory)<>'DB' then
  1101. begin
  1102. RowNext;
  1103. CellStart;
  1104. DumpLn('SVN Revisions:');
  1105. CellNext;
  1106. SC:=Q1.FieldByName('svnrev').AsString;
  1107. FormatSVNData(SC);
  1108. LDumpLn(SC);
  1109. CellNext;
  1110. if Q2 <> nil then
  1111. begin
  1112. SC:=Q2.FieldByName('svnrev').AsString;
  1113. FormatSVNData(SC);
  1114. LDumpLn(SC);
  1115. end;
  1116. CellEnd;
  1117. end;
  1118. RowNext;
  1119. CellStart;
  1120. DumpLn('Submitter:');
  1121. CellNext;
  1122. DumpLn(Q1.FieldByName('TU_SUBMITTER').AsString);
  1123. CellNext;
  1124. if Q2 <> nil then
  1125. DumpLn(Q2.FieldByName('TU_SUBMITTER').AsString);
  1126. CellEnd;
  1127. RowNext;
  1128. CellStart;
  1129. DumpLn('Date:');
  1130. CellNext;
  1131. F := Q1.FieldByName('TU_DATE');
  1132. Date1 := F.AsDateTime;
  1133. DumpLn(F.AsString);
  1134. F := Q1.FieldByName('TU_COMPILERDATE');
  1135. Try
  1136. CompilerDate1 := F.AsDateTime;
  1137. if not SameDate(Date1,CompilerDate1) then
  1138. DumpLn(' <> '+F.AsString);
  1139. Except
  1140. { Not a valid date, do nothing }
  1141. end;
  1142. CellNext;
  1143. if Q2 <> nil then
  1144. begin
  1145. F := Q2.FieldByName('TU_DATE');
  1146. Date2 := F.AsDateTime;
  1147. DumpLn(F.AsString);
  1148. F := Q2.FieldByName('TU_COMPILERDATE');
  1149. Try
  1150. CompilerDate2 := F.AsDateTime;
  1151. if not SameDate(Date2,CompilerDate2) then
  1152. DumpLn(' <> '+F.AsString);
  1153. Except
  1154. { Not a valid date, do nothing }
  1155. end;
  1156. end;
  1157. CellEnd;
  1158. RowNext;
  1159. CellStart;
  1160. DumpLn('Previous run:');
  1161. CellNext;
  1162. FPreviousRunID:=GetPreviousRunID(FRunID);
  1163. if FPreviousRunID<>'' then
  1164. EmitHiddenVar('previousrunid',FPreviousRunID);
  1165. DumpLn(FPreviousRunID);
  1166. CellNext;
  1167. if (FCompareRunID<>'') then
  1168. begin
  1169. FPrevious2RunID:=GetPreviousRunID(FCompareRunID);
  1170. DumpLn(FPrevious2RunID);
  1171. if FPrevious2RunID <> '' then
  1172. EmitHiddenVar('previous2runid',FPrevious2RunID);
  1173. end;
  1174. CellEnd;
  1175. RowNext;
  1176. CellStart;
  1177. DumpLn('Next run:');
  1178. CellNext;
  1179. FNextRunID:=GetNextRunID(FRunID);
  1180. if FNextRunID<>'' then
  1181. EmitHiddenVar('nextrunid',FNextRunID);
  1182. DumpLn(FNextRunID);
  1183. CellNext;
  1184. if (FCompareRunID<>'') then
  1185. begin
  1186. FNext2RunID:=GetNextRunID(FCompareRunID);
  1187. DumpLn(FNext2RunID);
  1188. if FNext2RunID <> '' then
  1189. EmitHiddenVar('next2runid',FNext2RunID);
  1190. end;
  1191. CellEnd;
  1192. RowEnd;
  1193. TableEnd;
  1194. ParagraphStart;
  1195. if FDebug then
  1196. EmitHiddenVar('DEBUGCGI', '1');
  1197. EmitCheckBox('noskipped','1',FNoSkipped);
  1198. DumpLn(' Hide skipped tests');
  1199. ParagraphEnd;
  1200. ParagraphStart;
  1201. EmitCheckBox('failedonly','1',FonlyFailed);
  1202. DumpLn(' Hide successful tests');
  1203. ParagraphEnd;
  1204. ParaGraphStart;
  1205. AddNewPar:=false;
  1206. if FPreviousRunID<>'' then
  1207. begin
  1208. EmitSubmitButton('action','Compare_to_previous');
  1209. AddNewPar:=true;
  1210. end;
  1211. if (FNextRunID<>'') and (FNextRunID <> FCompareRunID) then
  1212. begin
  1213. EmitSubmitButton('action','Compare_to_next');
  1214. AddNewPar:=true;
  1215. end;
  1216. if (FPrevious2RunID<>'') and (FPrevious2RunID <> FRunID) then
  1217. begin
  1218. EmitSubmitButton('action','Compare_right_to_previous');
  1219. AddNewPar:=true;
  1220. end;
  1221. if FNext2RunID<>'' then
  1222. begin
  1223. EmitSubmitButton('action','Compare_right_to_next');
  1224. AddNewPar:=true;
  1225. end;
  1226. if AddNewPar then
  1227. begin
  1228. ParagraphEnd;
  1229. ParaGraphStart;
  1230. end;
  1231. EmitSubmitButton('action','Show/Compare');
  1232. if FTestFileID<>'' then
  1233. EmitSubmitButton('action','View_history');
  1234. EmitResetButton('','Reset form');
  1235. ParagraphEnd;
  1236. FormEnd;
  1237. { give warning if dates reversed }
  1238. if (Q2 <> nil) and (Date1 > Date2) then
  1239. begin
  1240. ParagraphStart;
  1241. DumpLn('Warning: testruns are not compared in chronological order.');
  1242. ParagraphEnd;
  1243. end;
  1244. end;
  1245. Finally
  1246. Q1.Close;
  1247. Q1.Free;
  1248. if Q2 <> nil then
  1249. begin
  1250. Q2.Close;
  1251. Q2.Free;
  1252. end;
  1253. end;
  1254. end;
  1255. end;
  1256. Procedure TTestSuite.ShowRunResults;
  1257. Var
  1258. S : String;
  1259. Qry : String;
  1260. Q : TSQLQuery;
  1261. FL : String;
  1262. begin
  1263. ConnectToDB;
  1264. ContentType:='text/html';
  1265. EmitContentType;
  1266. EmitDocType;
  1267. EmitTitle(Title+' : Search Results');
  1268. With FHTMLWriter do
  1269. begin
  1270. HeaderStart(1);
  1271. DumpLn('Test suite results for run '+FRunID);
  1272. HeaderEnd(1);
  1273. HeaderStart(2);
  1274. DumpLn('Test run data : ');
  1275. HeaderEnd(2);
  1276. If ShowRunData then
  1277. begin
  1278. HeaderStart(2);
  1279. DumpLn('Detailed test run results:');
  1280. FL:='';
  1281. If FOnlyFailed or FNoSkipped then
  1282. begin
  1283. FL:='';
  1284. If FOnlyFailed then
  1285. FL:='successful';
  1286. if FNoSkipped then
  1287. begin
  1288. If (FL<>'') then
  1289. FL:=FL+' and ';
  1290. FL:=FL+'skipped';
  1291. end;
  1292. DumpLn(' ('+FL+' tests are hidden)');
  1293. end;
  1294. HeaderEnd(2);
  1295. S:='SELECT T_ID as Id,T_NAME as Filename,TR_SKIP as Skipped'
  1296. +',TR_OK as OK,TR_RESULT as Result'
  1297. +' FROM '+TESTRESULTSTableName(FRunID)+',TESTS'
  1298. +' WHERE (TR_TEST_FK=T_ID) AND (TR_TESTRUN_FK='+FRunID+') ';
  1299. If FOnlyFailed then
  1300. S:=S+' AND (TR_OK="-")';
  1301. If FNoSkipped then
  1302. S:=S+' AND (TR_SKIP="-")';
  1303. S:=S+' ORDER BY TR_ID ';
  1304. Qry:=S;
  1305. If FDebug then
  1306. begin
  1307. ParaGraphStart;
  1308. Dumpln('Query : '+Qry);
  1309. ParaGraphEnd;
  1310. end;
  1311. FRunCount:=0;
  1312. FRunSkipCount:=0;
  1313. FRunFailedCount:=0;
  1314. Q:=CreateDataset(Qry);
  1315. With Q do
  1316. try
  1317. Open;
  1318. while not EOF do
  1319. Next;
  1320. RecNo:=0;
  1321. DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
  1322. Try
  1323. With CreateTableProducer(Q) do
  1324. Try
  1325. Border:=True;
  1326. FL:='Id,Filename';
  1327. If Not FNoSkipped then
  1328. FL:=FL+',Skipped';
  1329. If Not FOnlyFailed then
  1330. FL:=FL+',OK';
  1331. FL:=FL+',Result';
  1332. CreateColumns(FL);
  1333. OnGetRowAttributes:=@GetRunRowAttr;
  1334. TableColumns.ColumnByNAme('Id').OnGetCellContents:=
  1335. @FormatFileIDDetails;
  1336. TableColumns.ColumnByNAme('Filename').OnGetCellContents:=
  1337. @FormatFileDetails;
  1338. TableColumns.ColumnByNAme('Result').OnGetCellContents:=
  1339. @FormatTestResult;
  1340. //(TableColumns.Items[0] as TTableColumn).ActionURL:=ALink;
  1341. CreateTable(Response);
  1342. Finally
  1343. Free;
  1344. end;
  1345. Finally
  1346. Close;
  1347. end;
  1348. finally
  1349. Free;
  1350. end;
  1351. If Not (FRunCount=0) and not (FNoSkipped or FOnlyFailed) then
  1352. begin
  1353. ParaGraphStart;
  1354. TagStart('IMG',Format('Src="'+TestsuiteCGIURL+
  1355. '?action=2&amp;pietotal=%d&amp;piefailed=%d&amp;pieskipped=%d"'+
  1356. ' ALT="total=%d, failed=%d, skipped=%d"',
  1357. [FRunCount,FRunFailedCount,FRunSkipCount,
  1358. FRunCount,FRunFailedCount,FRunSkipCount
  1359. ]));
  1360. end;
  1361. end
  1362. else
  1363. DumpLn('No data for test run with ID: '+FRunID);
  1364. end;
  1365. end;
  1366. Procedure TTestSuite.ShowOneTest;
  1367. Var
  1368. S,S2 : String;
  1369. Qry : String;
  1370. Base, Category : string;
  1371. Q : TSQLQuery;
  1372. i : longint;
  1373. FieldName,FieldValue,
  1374. LLog,Source : String;
  1375. Res : Boolean;
  1376. ver : known_versions;
  1377. begin
  1378. ConnectToDB;
  1379. ContentType:='text/html';
  1380. EmitContentType;
  1381. EmitDocType;
  1382. if FTestFileID='' then
  1383. FTestFileID:=GetSingleton('SELECT T_ID FROM TESTS WHERE T_NAME LIKE ''%'+
  1384. FTestFileName+'%''');
  1385. if FTestFileID<>'' then
  1386. FTestFileName:=GetTestFileName(FTestFileID);
  1387. EmitTitle(Title+' : File '+FTestFileName+' Results');
  1388. With FHTMLWriter do
  1389. begin
  1390. HeaderStart(1);
  1391. DumpLn('Test suite results for test file '+FTestFileName);
  1392. HeaderEnd(1);
  1393. HeaderStart(2);
  1394. DumpLn('Test run data : ');
  1395. HeaderEnd(2);
  1396. if FRunID<>'' then
  1397. begin
  1398. Res:=ShowRunData;
  1399. Res:=true;
  1400. end
  1401. else
  1402. begin
  1403. // This is useless as it is now
  1404. // It should be integrated into a form probably PM
  1405. DumpLn('Only failed tests');
  1406. EmitCheckBox('failedonly','1',FonlyFailed);
  1407. DumpLn('Hide skipped tests');
  1408. EmitCheckBox('noskipped','1',FNoSkipped);
  1409. Res:=true;
  1410. end;
  1411. If Res then
  1412. begin
  1413. HeaderStart(2);
  1414. DumpLn('Test file "'+FTestFileName+'" information:');
  1415. HeaderEnd(2);
  1416. ParaGraphStart;
  1417. if FTestFileID<>'' then
  1418. S:='SELECT * FROM TESTS WHERE T_ID='+FTestFileID
  1419. else
  1420. S:='SELECT * FROM TESTS WHERE T_NAME='+FTestFileName;
  1421. Q:=CreateDataSet(S);
  1422. With Q do
  1423. Try
  1424. Open;
  1425. Try
  1426. For i:=0 to FieldCount-1 do
  1427. begin
  1428. FieldValue:=Fields[i].AsString;
  1429. FieldName:=Fields[i].DisplayName;
  1430. if (FieldValue<>'') and (FieldValue<>'-') and
  1431. (FieldName<>'T_NAME') and (FieldName<>'T_SOURCE') then
  1432. begin
  1433. if (FieldValue='+') then
  1434. DumpLn('Flag ');
  1435. DumpLn(FieldName);
  1436. DumpLn(' ');
  1437. if FieldValue='+' then
  1438. DumpLn(' set')
  1439. else
  1440. DumpLn(FieldValue);
  1441. DumpLn('<BR>');
  1442. end;
  1443. end;
  1444. Finally
  1445. Close;
  1446. end;
  1447. Finally
  1448. Free;
  1449. end;
  1450. ParaGraphEnd;
  1451. HeaderStart(2);
  1452. DumpLn('Detailed test run results:');
  1453. HeaderEnd(2);
  1454. S:='SELECT TR_ID,TR_TESTRUN_FK AS RUN,TR_TEST_FK,TR_OK, TR_SKIP,TR_RESULT '
  1455. //S:='SELECT * '
  1456. +' FROM '+TESTRESULTSTableName(FRunID)
  1457. +' WHERE (TR_TEST_FK='+FTestFileID+')';
  1458. If FOnlyFailed then
  1459. S:=S+' AND (TR_OK="-")';
  1460. if Fcomparerunid<>'' then
  1461. begin
  1462. if TESTRESULTSTableName(FRunID)<>TESTRESULTSTableName(FCompareRunID) then
  1463. begin
  1464. S2:='SELECT TR_ID,TR_TESTRUN_FK AS RUN,TR_TEST_FK,TR_OK, TR_SKIP,TR_RESULT '
  1465. +' FROM '+TESTRESULTSTableName(FCompareRunID)
  1466. +' WHERE (TR_TEST_FK='+FTestFileID+')';
  1467. If FOnlyFailed then
  1468. S2:=S2+' AND (TR_OK="-")';
  1469. S:=S+' AND (TR_TESTRUN_FK='+Frunid+') UNION '+
  1470. S2+' AND (TR_TESTRUN_FK='+Fcomparerunid+')'
  1471. end
  1472. else
  1473. S:=S+' AND ((TR_TESTRUN_FK='+Frunid+') OR '+
  1474. '(TR_TESTRUN_FK='+Fcomparerunid+'))'
  1475. end
  1476. else if Frunid<>'' then
  1477. S:=S+' AND (TR_TESTRUN_FK='+Frunid+')'
  1478. else
  1479. S:=S+' ORDER BY TR_TESTRUN_FK DESC LIMIT '+IntToStr(FLimit);
  1480. Qry:=S;
  1481. If FDebug then
  1482. begin
  1483. ParaGraphStart;
  1484. Dumpln('Query : '+Qry);
  1485. ParaGraphEnd;
  1486. end;
  1487. FRunCount:=0;
  1488. FRunSkipCount:=0;
  1489. FRunFailedCount:=0;
  1490. Q:=CreateDataset(Qry);
  1491. With Q do
  1492. try
  1493. Open;
  1494. Try
  1495. With CreateTableProducer(Q) do
  1496. Try
  1497. Border:=True;
  1498. //FL:='TR_ID,TR_TESTRUN_FK,T_NAME,T_CPU,T_VERSION';
  1499. CreateColumns(Nil);
  1500. TableColumns.Delete(TableColumns.ColumnByName('TR_TEST_FK').Index);
  1501. TableColumns.ColumnByNAme('RUN').OnGetCellContents:=
  1502. @FormatTestRunOverview;
  1503. //OnGetRowAttributes:=@GetRunRowAttr;
  1504. TableColumns.ColumnByNAme('TR_RESULT').OnGetCellContents:=
  1505. @FormatTestResult;
  1506. //(TableColumns.Items[0] as TTableColumn).ActionURL:=ALink;
  1507. CreateTable(Response);
  1508. Finally
  1509. Free;
  1510. end;
  1511. ParaGraphStart;
  1512. DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
  1513. ParaGraphEnd;
  1514. Finally
  1515. Close;
  1516. end;
  1517. finally
  1518. Free;
  1519. end;
  1520. //If FDebug then
  1521. Category:='1';
  1522. if FRunId<>'' then
  1523. begin
  1524. Category:=getsingleton('select TU_CATEGORY_FK from TESTRUN where TU_ID='+FRunId);
  1525. FVersionBranch:=GetVersionName(getsingleton('select TU_VERSION_FK from TESTRUN where TU_ID='+fRunId));
  1526. LLog:='';
  1527. Try
  1528. LLog:=getsingleton('select TR_LOG from TESTRESULTS where (TR_TEST_FK='+ftestfileid
  1529. +') and (TR_TESTRUN_FK='+frunid+')');
  1530. if LLog<>'' then
  1531. begin
  1532. HeaderStart(2);
  1533. DumpLn('Log of '+FRunId+':');
  1534. HeaderEnd(2);
  1535. PreformatStart;
  1536. system.Write(LLog);
  1537. system.flush(output);
  1538. PreformatEnd;
  1539. end;
  1540. Finally
  1541. if LLog='' then
  1542. begin
  1543. HeaderStart(2);
  1544. DumpLn('No log of '+FRunId+'.');
  1545. HeaderEnd(2);
  1546. end;
  1547. end;
  1548. end;
  1549. if FCompareRunId<>'' then
  1550. begin
  1551. LLog:='';
  1552. Try
  1553. LLog:=getsingleton('select TR_LOG from TESTRESULTS where (TR_TEST_FK='+ftestfileid
  1554. +') and (TR_TESTRUN_FK='+fcomparerunid+')');
  1555. if LLog<>'' then
  1556. begin
  1557. HeaderStart(2);
  1558. DumpLn('Log of '+FCompareRunId+':');
  1559. HeaderEnd(2);
  1560. PreformatStart;
  1561. system.Write(LLog);
  1562. system.flush(output);
  1563. PreformatEnd;
  1564. end;
  1565. Finally
  1566. if LLog='' then
  1567. begin
  1568. HeaderStart(2);
  1569. DumpLn('No log of '+FCompareRunId+'.');
  1570. HeaderEnd(2);
  1571. end;
  1572. end;
  1573. end;
  1574. if FDebug then
  1575. DumpLn('After Log.');
  1576. Source:='';
  1577. Try
  1578. Source:=getsingleton('select T_SOURCE from TESTS where T_ID='+ftestfileid);
  1579. if Source<>'' then
  1580. begin
  1581. HeaderStart(2);
  1582. DumpLn('Source:');
  1583. HeaderEnd(2);
  1584. PreformatStart;
  1585. system.Write(Source);
  1586. system.flush(output);
  1587. PreformatEnd;
  1588. end;
  1589. Finally
  1590. Base:='trunk';
  1591. if FVersionBranch<>'' then
  1592. begin
  1593. // Test all but last version, which is assumed to be trunk
  1594. for ver:=low(known_versions) to pred(high(known_versions)) do
  1595. if VER_String[ver]=FVersionBranch then
  1596. begin
  1597. base:=ver_branch[ver];
  1598. break;
  1599. end;
  1600. end;
  1601. FViewVCURL:=ViewURL+Base;
  1602. if Category='1' then
  1603. FViewVCUrl:=FViewVCURL+TestsSubDir
  1604. else
  1605. begin
  1606. FViewVCUrl:=FViewVCURL+DataBaseSubDir;
  1607. // This assumes that type TAnyType is
  1608. // defined in anytype.pas source PM
  1609. if pos('/',FTestFileName)>0 then
  1610. FTestfilename:=lowercase(copy(FTestFilename,2,pos('/',FTestFilename)-2)+'.pas');
  1611. end;
  1612. if Source='' then
  1613. begin
  1614. HeaderStart(3);
  1615. DumpLn('<P>No Source in TestSuite DataBase.</P>');
  1616. DumpLn('Link to SVN view of '+
  1617. '<A HREF="'+FViewVCURL+FTestFileName+'?view=markup'+
  1618. '" TARGET="fpc_source"> '+FTestFileName+'</A> source. ');
  1619. HeaderEnd(3);
  1620. end
  1621. else
  1622. begin
  1623. HeaderStart(3);
  1624. DumpLn('Link to SVN view of '+
  1625. '<A HREF="'+FViewVCURL+FTestFileName+'?view=markup'+
  1626. '" TARGET="fpc_source"> '+FTestFileName+'</A> source. ');
  1627. HeaderEnd(3);
  1628. end;
  1629. end;
  1630. if FDebug then
  1631. DumpLn('After Source.');
  1632. end
  1633. else
  1634. DumpLn(Format('No data for test file with ID: %s',[FTestFileID]));
  1635. end;
  1636. end;
  1637. Procedure TTestSuite.ShowHistory;
  1638. Const
  1639. MaxCombo = 50;
  1640. Type
  1641. StatusLongintArray = Array [TTestStatus] of longint;
  1642. StatusDateTimeArray = Array [TTestStatus] of TDateTime;
  1643. AStatusLA = Array[1..MaxCombo] of StatusLongintArray;
  1644. AStatusDTA = Array[1..MaxCombo] of StatusDateTimeArray;
  1645. PStatusLA = ^AStatusLA;
  1646. PStatusDTA = ^AStatusDTA;
  1647. Var
  1648. S,SS,FL,cpu,version,os : String;
  1649. date : TDateTime;
  1650. Qry : String;
  1651. Base, Category : string;
  1652. Q : TSQLQuery;
  1653. i,run_id,os_id,version_id,cpu_id : longint;
  1654. run_ind,os_ind,version_ind,cpu_ind,
  1655. ok_ind,skip_ind,result_ind,date_ind : longint;
  1656. os_size, cpu_size, version_size : longint;
  1657. os_last, cpu_last, version_last : longint;
  1658. error : word;
  1659. OK_count, not_OK_count,resi,
  1660. total_count, skip_count, not_skip_count : longint;
  1661. TS : TTestStatus;
  1662. result_count : StatusLongintArray;
  1663. os_count,cpu_count,version_count: PStatusLA;
  1664. first_date, last_date : array[TTestStatus] of TDateTime;
  1665. first_date_id, last_date_id : array[TTestStatus] of longint;
  1666. os_first_date, os_last_date,
  1667. cpu_first_date, cpu_last_date,
  1668. version_first_date, version_last_date : PStatusDTA;
  1669. os_first_date_id, os_last_date_id,
  1670. cpu_first_date_id, cpu_last_date_id,
  1671. version_first_date_id, version_last_date_id : PStatusLA;
  1672. FieldName,FieldValue,
  1673. LLog,Source : String;
  1674. Res : Boolean;
  1675. ver : known_versions;
  1676. begin
  1677. Res:=False;
  1678. os_count:=nil;
  1679. cpu_count:=nil;
  1680. version_count:=nil;
  1681. ConnectToDB;
  1682. ContentType:='text/html';
  1683. EmitContentType;
  1684. EmitDocType;
  1685. if (FTestFileID='') and (FTestFileName<>'') then
  1686. begin
  1687. FTestFileID:=GetSingleton('SELECT T_ID FROM TESTS WHERE T_NAME LIKE ''%'+
  1688. FTestFileName+'%''');
  1689. end;
  1690. if FTestFileID<>'' then
  1691. FTestFileName:=GetTestFileName(FTestFileID);
  1692. if FTestFileName<>'' then
  1693. EmitTitle(Title+' : File '+FTestFileName+' Results')
  1694. else
  1695. EmitTitle(Title+' : History overview');
  1696. With FHTMLWriter do
  1697. begin
  1698. if FTestFileName<>'' then
  1699. begin
  1700. HeaderStart(1);
  1701. DumpLn('Test suite results for test file '+FTestFileName);
  1702. HeaderEnd(1);
  1703. HeaderStart(2);
  1704. DumpLn('Test run data : ');
  1705. HeaderEnd(2);
  1706. end;
  1707. if FRunID<>'' then
  1708. begin
  1709. Res:=ShowRunData;
  1710. Res:=true;
  1711. end
  1712. else
  1713. begin
  1714. // This is useless as it is now
  1715. // It should be integrated into a form probably PM
  1716. //DumpLn('Only failed tests');
  1717. //EmitCheckBox('failedonly','1',FonlyFailed);
  1718. //DumpLn('Hide skipped tests');
  1719. //EmitCheckBox('noskipped','1',FNoSkipped);
  1720. Res:=true;
  1721. EmitHistoryForm;
  1722. if FTestFileID = '' then
  1723. with FHTMLWriter do begin
  1724. HeaderStart(2);
  1725. if Trim(FTestFileName) <> '' then
  1726. DumpLn(Format('Error: No test files matching "%s" found.', [FTestFileName]))
  1727. else
  1728. DumpLn('Error: Please specify a test file.');
  1729. HeaderEnd(2);
  1730. Res:=False;
  1731. end;
  1732. end;
  1733. If Res then
  1734. begin
  1735. if (FTestFileName<>'') then
  1736. begin
  1737. HeaderStart(2);
  1738. DumpLn('Test file "'+FTestFileName+'" information:');
  1739. HeaderEnd(2);
  1740. ParaGraphStart;
  1741. S:='SELECT * FROM TESTS WHERE T_ID='+FTestFileID;
  1742. Q:=CreateDataSet(S);
  1743. With Q do
  1744. Try
  1745. Open;
  1746. Try
  1747. For i:=0 to FieldCount-1 do
  1748. begin
  1749. FieldValue:=Fields[i].AsString;
  1750. FieldName:=Fields[i].DisplayName;
  1751. if (FieldValue<>'') and (FieldValue<>'-') and
  1752. (FieldName<>'T_NAME') and (FieldName<>'T_SOURCE') then
  1753. begin
  1754. if (FieldValue='+') then
  1755. DumpLn('Flag ');
  1756. DumpLn(FieldName);
  1757. DumpLn(' ');
  1758. if FieldValue='+' then
  1759. DumpLn(' set')
  1760. else
  1761. DumpLn(FieldValue);
  1762. DumpLn('<BR>');
  1763. end;
  1764. end;
  1765. Finally
  1766. Close;
  1767. end;
  1768. Finally
  1769. Free;
  1770. end;
  1771. ParaGraphEnd;
  1772. HeaderStart(2);
  1773. DumpLn('Detailed test run results:');
  1774. end;
  1775. HeaderEnd(2);
  1776. ParaGraphStart;
  1777. SS:='SELECT TR_ID,TR_TESTRUN_FK AS Run,TR_TEST_FK,TR_OK AS OK'
  1778. +', TR_SKIP As Skip,TR_RESULT As Result'
  1779. //S:='SELECT * '
  1780. +',TC_NAME AS CPU, TV_VERSION AS Version, TO_NAME AS OS'
  1781. +',TU_ID,TU_DATE AS Date,TU_SUBMITTER AS Submitter'
  1782. +',(TU_FAILEDTOCOMPILE + TU_FAILEDTOFAIL + TU_FAILEDTORUN) AS Fails'
  1783. +',TU_MACHINE AS Machine,TU_COMMENT AS Comment'
  1784. +',TU_COMPILERDATE As CompDate'
  1785. +',TU_SVNTESTSREVISION AS Tests_rev'
  1786. +',TU_SVNRTLREVISION AS RTL_rev'
  1787. +',TU_SVNCOMPILERREVISION AS Compiler_rev'
  1788. +',TU_SVNPACKAGESREVISION AS Packages_rev'
  1789. +',TO_ID,TC_ID,TV_ID'
  1790. +' FROM TESTRESULTS '
  1791. +' LEFT JOIN TESTRUN ON (TR_TESTRUN_FK=TU_ID)'
  1792. +' LEFT JOIN TESTOS ON (TU_OS_FK=TO_ID)'
  1793. +' LEFT JOIN TESTCPU ON (TU_CPU_FK=TC_ID)'
  1794. +' LEFT JOIN TESTVERSION ON (TU_VERSION_FK=TV_ID)';
  1795. S:='';
  1796. if FTestFileID<>'' then
  1797. S:=S+' AND (TR_TEST_FK='+FTestFileID+')';
  1798. if FRunID<>'' then
  1799. S:=S+' AND (TR_TESTRUN_FK='+FRunID+')';
  1800. If FOnlyFailed then
  1801. S:=S+' AND (TR_OK="-")';
  1802. If FNoSkipped then
  1803. S:=S+' AND (TR_SKIP="-")';
  1804. If FCond<>'' then
  1805. S:=S+' AND ('+FCond+')';
  1806. If (FCPU<>'') and (GetCPUName(FCPU)<>'All') then
  1807. begin
  1808. S:=S+' AND (TU_CPU_FK='+FCPU+')';
  1809. cpu_size:=0;
  1810. end
  1811. else
  1812. begin
  1813. cpu_last:=StrToInt(GetSingleton('SELECT COUNT(*) FROM TESTCPU'));
  1814. cpu_size:=Sizeof(StatusLongintArray)*(1+cpu_last);
  1815. cpu_count:=GetMem(cpu_size);
  1816. FillChar(cpu_count^,cpu_size,#0);
  1817. cpu_first_date_id:=GetMem(cpu_size);
  1818. FillChar(cpu_first_date_id^,cpu_size,#0);
  1819. cpu_last_date_id:=GetMem(cpu_size);
  1820. FillChar(cpu_last_date_id^,cpu_size,#0);
  1821. cpu_first_date:=GetMem(cpu_last*SizeOf(StatusDateTimeArray));
  1822. FillChar(cpu_first_date^,cpu_last*Sizeof(StatusDateTimeArray),#0);
  1823. cpu_last_date:=GetMem(cpu_last*SizeOf(StatusDateTimeArray));
  1824. FillChar(cpu_last_date^,cpu_last*Sizeof(StatusDateTimeArray),#0);
  1825. end;
  1826. If (FVersion<>'') and (GetVersionName(FVersion)<>'All') then
  1827. begin
  1828. S:=S+' AND (TU_VERSION_FK='+FVERSION+')';
  1829. version_size:=0;
  1830. end
  1831. else
  1832. begin
  1833. version_last:=StrToInt(GetSingleton('SELECT COUNT(*) FROM TESTVERSION'));
  1834. version_size:=Sizeof(StatusLongintArray)*(1+version_last);
  1835. version_count:=GetMem(version_size);
  1836. FillChar(version_count^,version_size,#0);
  1837. version_first_date_id:=GetMem(version_size);
  1838. FillChar(version_first_date_id^,version_size,#0);
  1839. version_last_date_id:=GetMem(version_size);
  1840. FillChar(version_last_date_id^,version_size,#0);
  1841. version_first_date:=GetMem(version_last*SizeOf(StatusDateTimeArray));
  1842. FillChar(version_first_date^,version_last*Sizeof(StatusDateTimeArray),#0);
  1843. version_last_date:=GetMem(version_last*SizeOf(StatusDateTimeArray));
  1844. FillChar(version_last_date^,version_last*Sizeof(StatusDateTimeArray),#0);
  1845. end;
  1846. if (FOS<>'') and (GetOSName(FOS)<>'All') then
  1847. begin
  1848. S:=S+' AND (TU_OS_FK='+FOS+')';
  1849. os_size:=0;
  1850. end
  1851. else
  1852. begin
  1853. os_last:=StrToInt(GetSingleton('SELECT COUNT(*) FROM TESTOS'));
  1854. os_size:=Sizeof(StatusLongintArray)*(1+os_last);
  1855. os_count:=GetMem(os_size);
  1856. FillChar(os_count^,os_size,#0);
  1857. os_first_date_id:=GetMem(os_size);
  1858. FillChar(os_first_date_id^,os_size,#0);
  1859. os_last_date_id:=GetMem(os_size);
  1860. FillChar(os_last_date_id^,os_size,#0);
  1861. os_first_date:=GetMem(os_last*SizeOf(StatusDateTimeArray));
  1862. FillChar(os_first_date^,os_last*Sizeof(StatusDateTimeArray),#0);
  1863. os_last_date:=GetMem(os_last*SizeOf(StatusDateTimeArray));
  1864. FillChar(os_last_date^,os_last*Sizeof(StatusDateTimeArray),#0);
  1865. end;
  1866. If FSubmitter<>'' then
  1867. S:=S+' AND (TU_SUBMITTER='''+FSubmitter+''')';
  1868. If FMachine<>'' then
  1869. S:=S+' AND (TU_MACHINE='''+FMachine+''')';
  1870. If FComment<>'' then
  1871. S:=S+' AND (TU_COMMENT LIKE '''+FComment+''')';
  1872. if FDATE<>0 then
  1873. S:=S+' AND (TU_DATE >= '''+FormatDateTime('YYYY-MM-DD',FDate)+''')';
  1874. if S <> '' then
  1875. begin
  1876. Delete(S, 1, 4);
  1877. S:=SS + ' WHERE '+ S;
  1878. end
  1879. else
  1880. S:=SS;
  1881. S:=S+' ORDER BY TR_ID DESC';
  1882. if FDATE=0 then
  1883. S:=S+' LIMIT '+IntToStr(FLimit)
  1884. else
  1885. S:=S+' LIMIT '+IntToStr(MaxLimit);
  1886. Qry:=S;
  1887. If FDebug then
  1888. begin
  1889. Writeln(system.stdout,'Query : '+Qry);
  1890. system.Flush(system.stdout);
  1891. end;
  1892. FRunCount:=0;
  1893. FRunSkipCount:=0;
  1894. FRunFailedCount:=0;
  1895. Q:=CreateDataset(Qry);
  1896. With Q do
  1897. try
  1898. Open;
  1899. while not EOF do
  1900. Next;
  1901. DumpLn(Format('<p>Record count: %d </p>',[Q.RecordCount]));
  1902. if RecordCount>0 then
  1903. RecNo:=0;
  1904. Try
  1905. { if FDebug then
  1906. begin
  1907. Writeln(stdout,'FieldKind=',Fields[0].FieldKind);
  1908. Writeln(stdout,'DataType=',Fields[0].DataType);
  1909. system.flush(stdout);
  1910. end; }
  1911. total_count:=0;
  1912. OK_count:=0;
  1913. not_OK_count:=0;
  1914. skip_count:=0;
  1915. not_skip_count:=0;
  1916. fillchar(Result_Count,Sizeof(Result_count),#0);
  1917. ok_ind:=FieldByName('OK').Index;
  1918. skip_ind:=FieldBYName('SKIP').Index;
  1919. result_ind:=FieldByName('Result').Index;
  1920. cpu_ind:=FieldByName('TC_ID').Index;
  1921. os_ind:=FieldByName('TO_ID').Index;
  1922. version_ind:=FieldByName('TV_ID').Index;
  1923. date_ind:=FieldByName('Date').Index;
  1924. run_ind:=FieldByName('TU_ID').Index;
  1925. For i:=0 to Q.RecordCount-1 do
  1926. begin
  1927. Q.RecNo:=i;
  1928. inc(total_count);
  1929. S:=Fields[ok_ind].AsString;
  1930. if S='+' then
  1931. inc(OK_count)
  1932. else
  1933. inc(not_OK_count);
  1934. S:=Fields[skip_ind].AsString;
  1935. if S='+' then
  1936. inc(skip_count)
  1937. else
  1938. inc(not_skip_count);
  1939. S:=Fields[result_ind].AsString;
  1940. cpu:=Fields[cpu_ind].ASString;
  1941. version:=Fields[version_ind].AsString;
  1942. os:=Fields[os_ind].AsString;
  1943. date:=Fields[date_ind].ASDateTime;
  1944. os_id:=Fields[os_ind].AsLongint;
  1945. cpu_id:=Fields[cpu_ind].AsLongint;
  1946. version_id:=Fields[version_ind].AsLongint;
  1947. system.val(S,resi,error);
  1948. run_id:=Fields[run_ind].ASLongint;
  1949. if (error=0) and (Resi>=longint(FirstStatus)) and
  1950. (Resi<=longint(LastStatus)) then
  1951. begin
  1952. TS:=TTestStatus(Resi);
  1953. if Result_count[TS]=0 then
  1954. begin
  1955. first_date[TS]:=date;
  1956. last_date[TS]:=date;
  1957. first_date_id[TS]:=run_id;
  1958. last_date_id[TS]:=run_id;
  1959. end
  1960. else
  1961. begin
  1962. if (date>last_date[TS]) then
  1963. begin
  1964. last_date[TS]:=date;
  1965. last_date_id[TS]:=run_id;
  1966. end;
  1967. if date<first_date[TS] then
  1968. begin
  1969. first_date[TS]:=date;
  1970. first_date_id[TS]:=run_id;
  1971. end;
  1972. end;
  1973. inc(Result_count[TS]);
  1974. if assigned(cpu_count) and (cpu_id<=cpu_last) then
  1975. begin
  1976. if cpu_count^[cpu_id,TS]=0 then
  1977. begin
  1978. cpu_first_date^[cpu_id,TS]:=date;
  1979. cpu_last_date^[cpu_id,TS]:=date;
  1980. cpu_first_date_id^[cpu_id,TS]:=run_id;
  1981. cpu_last_date_id^[cpu_id,TS]:=run_id;
  1982. end
  1983. else
  1984. begin
  1985. if (date>cpu_last_date^[cpu_id,TS]) then
  1986. begin
  1987. cpu_last_date^[cpu_id,TS]:=date;
  1988. cpu_last_date_id^[cpu_id,TS]:=run_id;
  1989. end;
  1990. if date<cpu_first_date^[cpu_id,TS] then
  1991. begin
  1992. cpu_first_date^[cpu_id,TS]:=date;
  1993. cpu_first_date_id^[cpu_id,TS]:=run_id;
  1994. end;
  1995. end;
  1996. inc(cpu_count^[cpu_id,TS]);
  1997. end;
  1998. if assigned(os_count) and (os_id<=os_last) then
  1999. begin
  2000. if os_count^[os_id,TS]=0 then
  2001. begin
  2002. os_first_date^[os_id,TS]:=date;
  2003. os_last_date^[os_id,TS]:=date;
  2004. os_first_date_id^[os_id,TS]:=run_id;
  2005. os_last_date_id^[os_id,TS]:=run_id;
  2006. end
  2007. else
  2008. begin
  2009. if (date>os_last_date^[os_id,TS]) then
  2010. begin
  2011. os_last_date^[os_id,TS]:=date;
  2012. os_last_date_id^[os_id,TS]:=run_id;
  2013. end;
  2014. if date<os_first_date^[os_id,TS] then
  2015. begin
  2016. os_first_date^[os_id,TS]:=date;
  2017. os_first_date_id^[os_id,TS]:=run_id;
  2018. end;
  2019. end;
  2020. inc(os_count^[os_id,TS]);
  2021. end;
  2022. if assigned(version_count) and (version_id<=version_last) then
  2023. begin
  2024. if version_count^[version_id,TS]=0 then
  2025. begin
  2026. version_first_date^[version_id,TS]:=date;
  2027. version_last_date^[version_id,TS]:=date;
  2028. version_first_date_id^[version_id,TS]:=run_id;
  2029. version_last_date_id^[version_id,TS]:=run_id;
  2030. end
  2031. else
  2032. begin
  2033. if (date>version_last_date^[version_id,TS]) then
  2034. begin
  2035. version_last_date^[version_id,TS]:=date;
  2036. version_last_date_id^[version_id,TS]:=run_id;
  2037. end;
  2038. if date<version_first_date^[version_id,TS] then
  2039. begin
  2040. version_first_date^[version_id,TS]:=date;
  2041. version_first_date_id^[version_id,TS]:=run_id;
  2042. end;
  2043. end;
  2044. inc(version_count^[version_id,TS]);
  2045. end;
  2046. end
  2047. else if Fdebug then
  2048. writeln(stdout,'Error for Result, S=',S);
  2049. end;
  2050. DumpLn(Format('<p>Total = %d </p>',[total_count]));
  2051. if Total_count > 0 then
  2052. DumpLn(Format('<p>OK=%d Percentage= %3.2f </p>',[OK_count,OK_count*100/total_count]));
  2053. if Skip_count > 0 then
  2054. DumpLn(Format('<p>Skipped=%d Percentage= %3.2f </p>',[Skip_count,Skip_count*100/total_count]));
  2055. if total_count>0 then
  2056. begin
  2057. TableStart(5,True);
  2058. RowStart;
  2059. CellStart;
  2060. DumpLn('Result type');
  2061. CellNext;
  2062. DumpLn('Cat.');
  2063. CellNext;
  2064. DumpLn('Count');
  2065. CellNext;
  2066. DumpLn('Percentage');
  2067. CellNext;
  2068. DumpLn('First date');
  2069. CellNext;
  2070. DumpLn('Last Date');
  2071. CellEnd;
  2072. end;
  2073. For TS:=FirstStatus to LastStatus do
  2074. if Result_count[TS]>0 then
  2075. begin
  2076. RowNext;
  2077. CellStart;
  2078. DumpLn(StatusText[TS]);
  2079. CellNext;
  2080. CellNext;
  2081. DumpLn(Format('%d',[Result_count[TS]]));
  2082. CellNext;
  2083. DumpLn(Format('%3.1f',[Result_count[TS]*100/total_count]));
  2084. CellNext;
  2085. DumpLn(FormatDetailURL(IntToStr(first_date_id[TS]),
  2086. DateTimeToStr(first_date[TS])));
  2087. DumpLn(' '+GetFailCount(first_date_id[TS]));
  2088. CellNext;
  2089. DumpLn(FormatDetailURL(IntToStr(last_date_id[TS]),
  2090. DateTimeToStr(last_date[TS])));
  2091. DumpLn(' '+GetFailCount(last_date_id[TS]));
  2092. CellEnd;
  2093. if assigned(cpu_count) then
  2094. begin
  2095. for i:=1 to cpu_last do
  2096. if cpu_count^[i,TS]>0 then
  2097. begin
  2098. RowNext;
  2099. CellStart;
  2100. CellNext;
  2101. DumpLn(GetSingleton('SELECT TC_NAME FROM TESTCPU WHERE TC_ID='+IntToStr(i)));
  2102. CellNext;
  2103. DumpLn(Format('%d',[cpu_count^[i,TS]]));
  2104. CellNext;
  2105. DumpLn(Format('%3.1f',[cpu_count^[i,TS]*100/result_count[TS]]));
  2106. CellNext;
  2107. DumpLn(FormatDetailURL(IntToStr(cpu_first_date_id^[i,TS]),
  2108. DateTimeToStr(cpu_first_date^[i,TS])));
  2109. DumpLn(' '+GetFailCount(cpu_first_date_id^[i,TS]));
  2110. CellNext;
  2111. DumpLn(FormatDetailURL(IntToStr(cpu_last_date_id^[i,TS]),
  2112. DateTimeToStr(cpu_last_date^[i,TS])));
  2113. DumpLn(' '+GetFailCount(cpu_last_date_id^[i,TS]));
  2114. CellEnd;
  2115. end;
  2116. end;
  2117. if assigned(os_count) then
  2118. begin
  2119. for i:=1 to os_last do
  2120. if os_count^[i,TS]>0 then
  2121. begin
  2122. RowNext;
  2123. CellStart;
  2124. CellNext;
  2125. DumpLn(GetSingleton('SELECT TO_NAME FROM TESTOS WHERE TO_ID='+IntToStr(i)));
  2126. CellNext;
  2127. DumpLn(Format('%d',[os_count^[i,TS]]));
  2128. CellNext;
  2129. DumpLn(Format('%3.1f',[os_count^[i,TS]*100/result_count[TS]]));
  2130. CellNext;
  2131. DumpLn(FormatDetailURL(IntToStr(os_first_date_id^[i,TS]),
  2132. DateTimeToStr(os_first_date^[i,TS])));
  2133. DumpLn(' '+GetFailCount(os_first_date_id^[i,TS]));
  2134. CellNext;
  2135. DumpLn(FormatDetailURL(IntToStr(os_last_date_id^[i,TS]),
  2136. DateTimeToStr(os_last_date^[i,TS])));
  2137. DumpLn(' '+GetFailCount(os_last_date_id^[i,TS]));
  2138. CellEnd;
  2139. end;
  2140. end;
  2141. if assigned(version_count) then
  2142. begin
  2143. for i:=1 to version_last do
  2144. if version_count^[i,TS]>0 then
  2145. begin
  2146. RowNext;
  2147. CellStart;
  2148. CellNext;
  2149. DumpLn(GetSingleton('SELECT TV_VERSION FROM TESTVERSION WHERE TV_ID='+IntToStr(i)));
  2150. CellNext;
  2151. DumpLn(Format('%d',[version_count^[i,TS]]));
  2152. CellNext;
  2153. DumpLn(Format('%3.1f',[version_count^[i,TS]*100/result_count[TS]]));
  2154. CellNext;
  2155. DumpLn(FormatDetailURL(IntToStr(version_first_date_id^[i,TS]),
  2156. DateTimeToStr(version_first_date^[i,TS])));
  2157. DumpLn(' '+GetFailCount(version_first_date_id^[i,TS]));
  2158. CellNext;
  2159. DumpLn(FormatDetailURL(IntToStr(version_last_date_id^[i,TS]),
  2160. DateTimeToStr(version_last_date^[i,TS])));
  2161. DumpLn(' '+GetFailCount(version_last_date_id^[i,TS]));
  2162. CellEnd;
  2163. end;
  2164. end;
  2165. end;
  2166. if total_count>0 then
  2167. begin
  2168. TableEnd;
  2169. RecNo:=0;
  2170. end;
  2171. If FDebug or FListAll then
  2172. begin
  2173. With CreateTableProducer(Q) do
  2174. Try
  2175. Border:=True;
  2176. FL:='RUN,Date,OK,SKIP,Result';
  2177. if FSubmitter='' then
  2178. FL:=FL+',Submitter';
  2179. if FMachine='' then
  2180. FL:=FL+',Machine';
  2181. if Fcomment='' then
  2182. FL:=FL+',Comment';
  2183. if (FOS='') or (GetOSName(FOS)='All') then
  2184. FL:=FL+',OS';
  2185. if (FCPU='') or (GetCPUName(FCPU)='All') then
  2186. FL:=FL+',CPU';
  2187. if (FVersion='') or (GetVersionName(FVersion)='All') then
  2188. FL:=FL+',Version';
  2189. FL:=FL+',Fails,CompDate';
  2190. FL:=FL+',Tests_rev,RTL_rev,Compiler_rev,Packages_rev';
  2191. CreateColumns(FL);
  2192. //TableColumns.Delete(TableColumns.ColumnByName('TR_TEST_FK').Index);
  2193. TableColumns.ColumnByNAme('RUN').OnGetCellContents:=
  2194. @FormatTestRunOverview;
  2195. //OnGetRowAttributes:=@GetRunRowAttr;
  2196. TableColumns.ColumnByNAme('Result').OnGetCellContents:=
  2197. @FormatTestResult;
  2198. //(TableColumns.Items[0] as TTableColumn).ActionURL:=ALink;
  2199. CreateTable(Response);
  2200. Finally
  2201. Free;
  2202. end;
  2203. end;
  2204. Finally
  2205. Close;
  2206. end;
  2207. finally
  2208. Free;
  2209. end;
  2210. //If FDebug then
  2211. Category:='1';
  2212. if FRunId<>'' then
  2213. begin
  2214. Category:=getsingleton('select TU_CATEGORY_FK from TESTRUN where TU_ID='+FRunId);
  2215. FVersionBranch:=GetVersionName(getsingleton('select TU_VERSION_FK from TESTRUN where TU_ID='+fRunId));
  2216. LLog:='';
  2217. Try
  2218. LLog:=getsingleton('select TR_LOG from TESTRESULTS where (TR_TEST_FK='+ftestfileid
  2219. +') and (TR_TESTRUN_FK='+frunid+')');
  2220. if LLog<>'' then
  2221. begin
  2222. HeaderStart(2);
  2223. DumpLn('LLog of '+FRunId+':');
  2224. HeaderEnd(2);
  2225. PreformatStart;
  2226. system.Write(LLog);
  2227. system.flush(output);
  2228. PreformatEnd;
  2229. end;
  2230. Finally
  2231. if LLog='' then
  2232. begin
  2233. HeaderStart(2);
  2234. DumpLn('No log of '+FRunId+'.');
  2235. HeaderEnd(2);
  2236. end;
  2237. end;
  2238. end;
  2239. if FCompareRunId<>'' then
  2240. begin
  2241. LLog:='';
  2242. Try
  2243. LLog:=getsingleton('select TR_LOG from TESTRESULTS where (TR_TEST_FK='+ftestfileid
  2244. +') and (TR_TESTRUN_FK='+fcomparerunid+')');
  2245. if LLog<>'' then
  2246. begin
  2247. HeaderStart(2);
  2248. DumpLn('Log of '+FCompareRunId+':');
  2249. HeaderEnd(2);
  2250. PreformatStart;
  2251. system.Write(LLog);
  2252. system.flush(output);
  2253. PreformatEnd;
  2254. end;
  2255. Finally
  2256. if LLog='' then
  2257. begin
  2258. HeaderStart(2);
  2259. DumpLn('No log of '+FCompareRunId+'.');
  2260. HeaderEnd(2);
  2261. end;
  2262. end;
  2263. end;
  2264. if FDebug then
  2265. DumpLn('After log.');
  2266. Source:='';
  2267. Try
  2268. if ftestfileid <> '' then
  2269. begin
  2270. Source:=getsingleton('select T_SOURCE from TESTS where T_ID='+ftestfileid);
  2271. if Source<>'' then
  2272. begin
  2273. HeaderStart(2);
  2274. DumpLn('Source:');
  2275. HeaderEnd(2);
  2276. PreformatStart;
  2277. system.Write(Source);
  2278. system.flush(output);
  2279. PreformatEnd;
  2280. end;
  2281. end;
  2282. Finally
  2283. Base:='trunk';
  2284. if FVersionBranch<>'' then
  2285. begin
  2286. // Test all but last version, which is assumed to be trunk
  2287. for ver:=low(known_versions) to pred(high(known_versions)) do
  2288. if ver_string[ver]=FVersionBranch then
  2289. begin
  2290. base:=ver_branch[ver];
  2291. break;
  2292. end;
  2293. end;
  2294. FViewVCURL:=ViewURL+Base;
  2295. if Category='1' then
  2296. FViewVCUrl:=FViewVCURL+TestsSubDir
  2297. else
  2298. begin
  2299. FViewVCUrl:=FViewVCURL+DataBaseSubDir;
  2300. // This assumes that type TAnyType is
  2301. // defined in anytype.pas source PM
  2302. if pos('/',FTestFileName)>0 then
  2303. FTestfilename:=lowercase(copy(FTestFilename,2,pos('/',FTestFilename)-2)+'.pas');
  2304. end;
  2305. if Source='' then
  2306. begin
  2307. HeaderStart(3);
  2308. DumpLn('<P>No Source in TestSuite DataBase.</P>');
  2309. DumpLn('Link to SVN view of '+
  2310. '<A HREF="'+FViewVCURL+FTestFileName+'?view=markup'+
  2311. '" TARGET="fpc_source"> '+FTestFileName+'</A> source. ');
  2312. HeaderEnd(3);
  2313. end
  2314. else
  2315. begin
  2316. HeaderStart(3);
  2317. DumpLn('Link to SVN view of '+
  2318. '<A HREF="'+FViewVCURL+FTestFileName+'?view=markup'+
  2319. '" TARGET="fpc_source"> '+FTestFileName+'</A> source. ');
  2320. HeaderEnd(3);
  2321. end;
  2322. end;
  2323. if FDebug then
  2324. DumpLn('After Source.');
  2325. end;
  2326. end;
  2327. if assigned(os_count) then
  2328. begin
  2329. FreeMem(os_count);
  2330. FreeMem(os_first_date);
  2331. FreeMem(os_first_date_id);
  2332. FreeMem(os_last_date);
  2333. FreeMem(os_last_date_id);
  2334. end;
  2335. if assigned(cpu_count) then
  2336. begin
  2337. FreeMem(cpu_count);
  2338. FreeMem(cpu_first_date);
  2339. FreeMem(cpu_first_date_id);
  2340. FreeMem(cpu_last_date);
  2341. FreeMem(cpu_last_date_id);
  2342. end;
  2343. if assigned(version_count) then
  2344. begin
  2345. FreeMem(version_count);
  2346. FreeMem(version_first_date);
  2347. FreeMem(version_first_date_id);
  2348. FreeMem(version_last_date);
  2349. FreeMem(version_last_date_id);
  2350. end;
  2351. end;
  2352. Procedure TTestSuite.ShowRunComparison;
  2353. Var
  2354. S : String;
  2355. Qry : String;
  2356. Q : TSQLQuery;
  2357. FL : String;
  2358. begin
  2359. ConnectToDB;
  2360. ContentType:='text/html';
  2361. EmitContentType;
  2362. EmitDocType;
  2363. EmitTitle(Title+' : Compare 2 runs');
  2364. With FHTMLWriter do
  2365. begin
  2366. HeaderStart(1);
  2367. DumpLn('Test suite results for run '+FRunID+' vs. '+FCompareRunID);
  2368. HeaderEnd(1);
  2369. HeaderStart(2);
  2370. DumpLn('Test run data: ');
  2371. HeaderEnd(2);
  2372. If ShowRunData then
  2373. begin
  2374. HeaderStart(2);
  2375. DumpLn('Detailed test run results:');
  2376. FL:='';
  2377. If FOnlyFailed or FNoSkipped then
  2378. begin
  2379. FL:='';
  2380. If FOnlyFailed then
  2381. FL:='successful';
  2382. if FNoSkipped then
  2383. begin
  2384. If (FL<>'') then
  2385. FL:=FL+' and ';
  2386. FL:=FL+'skipped';
  2387. end;
  2388. DumpLn(' ('+FL+' tests are hidden)');
  2389. end;
  2390. HeaderEnd(2);
  2391. ParaGraphStart;
  2392. Q:=CreateDataset('');
  2393. Q.SQL.Text:='CREATE TEMPORARY TABLE tr1 like TESTRESULTS;';
  2394. Q.ExecSQL;
  2395. Q.SQL.Text:='CREATE TEMPORARY TABLE tr2 like TESTRESULTS;';
  2396. Q.ExecSQL;
  2397. Q.SQL.Text:='INSERT INTO tr1 SELECT * FROM '+TESTRESULTSTableName(FRunId)+
  2398. ' WHERE TR_TESTRUN_FK='+FRunID+';';
  2399. Q.ExecSQL;
  2400. Q.SQL.Text:='INSERT INTO tr2 SELECT * FROM '+TESTRESULTSTableName(FCompareRunId)+
  2401. ' WHERE TR_TESTRUN_FK='+FCompareRunID+';';
  2402. Q.ExecSQL;
  2403. S:='SELECT T_ID as Id,T_NAME as Filename,tr1.TR_SKIP as Run1_Skipped,'
  2404. +'tr2.TR_SKIP as Run2_Skipped,tr1.TR_OK as Run1_OK,'
  2405. +'tr2.TR_OK as Run2_OK, tr1.TR_Result as Run1_Result,'
  2406. +'tr2.TR_RESULT as Run2_Result '
  2407. +'FROM TESTS, tr2 LEFT JOIN tr1 USING (TR_TEST_FK) '
  2408. +'WHERE ((tr1.TR_SKIP IS NULL) or'
  2409. +' (tr2.TR_SKIP IS NULL) or '
  2410. +' (%s (tr1.TR_Result<>tr2.TR_Result)))'
  2411. +'and (T_ID=tr2.TR_TEST_FK)';
  2412. If FNoSkipped then
  2413. begin
  2414. Qry:='(((tr1.TR_SKIP="+") and (tr2.TR_OK="-") and (tr2.TR_SKIP="-")) or '
  2415. +'((tr1.TR_OK="-") and (tr1.TR_SKIP="-") and (tr2.TR_SKIP="+")) or '
  2416. +'((tr1.TR_SKIP="-") and (tr2.TR_SKIP="-"))) and ';
  2417. end
  2418. else
  2419. Qry:='';
  2420. Qry:=Format(S,[Qry]);
  2421. If FDebug then
  2422. begin
  2423. system.WriteLn('Query: '+Qry);
  2424. system.Flush(stdout);
  2425. end;
  2426. FRunCount:=0;
  2427. FRunSkipCount:=0;
  2428. FRunFailedCount:=0;
  2429. Q.SQL.Text:=Qry;
  2430. With Q do
  2431. try
  2432. Open;
  2433. Try
  2434. With CreateTableProducer(Q) do
  2435. Try
  2436. Border:=True;
  2437. FL:='Id,Filename,Run1_OK,Run2_OK';
  2438. If Not FNoSkipped then
  2439. FL:=FL+',Run1_Skipped,Run2_Skipped';
  2440. FL:=FL+',Run1_Result,Run2_Result';
  2441. CreateColumns(FL);
  2442. OnGetRowAttributes:=@GetRunRowAttr;
  2443. TableColumns.ColumnByNAme('Id').OnGetCellContents:=
  2444. @FormatFileIDDetails;
  2445. TableColumns.ColumnByNAme('Run1_Result').OnGetCellContents:=
  2446. @FormatTestResult;
  2447. TableColumns.ColumnByNAme('Run2_Result').OnGetCellContents:=
  2448. @FormatTestResult;
  2449. TableColumns.ColumnByNAme('Filename').OnGetCellContents:=
  2450. @FormatFileDetails;
  2451. //(TableColumns.Items[0] as TTableColumn).ActionURL:=ALink;
  2452. CreateTable(Response);
  2453. Finally
  2454. Free;
  2455. end;
  2456. DumpLn(format('<p>Record count: %d</P>',[Q.RecordCount]));
  2457. Finally
  2458. Close;
  2459. end;
  2460. finally
  2461. Free;
  2462. end;
  2463. If Not (FRunCount=0) and not (FNoSkipped or FOnlyFailed) then
  2464. begin
  2465. ParaGraphStart;
  2466. TagStart('IMG',Format('Src="'+TestsuiteCGIURL+
  2467. '?action=2&amp;pietotal=%d&amp;piefailed=%d&amp;pieskipped=%d"'+
  2468. ' ALT="total=%d, failed=%d, skipped=%d"',
  2469. [FRunCount,FRunFailedCount,FRunSkipCount,
  2470. FRunCount,FRunFailedCount,FRunSkipCount
  2471. ]));
  2472. end;
  2473. end
  2474. else
  2475. DumpLn('No data for test run with ID: '+FRunID);
  2476. end;
  2477. end;
  2478. procedure TTestSuite.GetRunRowAttr(Sender: TObject; var BGColor: String;
  2479. var Align: THTMLAlign; var VAlign: THTMLValign; var CustomAttr: String);
  2480. Var
  2481. P : TTableProducer;
  2482. Skip1Field, Skip2Field, Run1Field, Run2Field : TField;
  2483. begin
  2484. P:=(Sender as TTAbleProducer);
  2485. Inc(FRunCount);
  2486. If (FOnlyFailed and FNoSkipped) then
  2487. begin
  2488. If (P.CurrentRow Mod 2)=0 then
  2489. BGColor:='#EEEEEE'
  2490. end
  2491. else
  2492. begin
  2493. Skip1Field := P.Dataset.FindField('Skipped');
  2494. if Skip1Field = nil then
  2495. begin
  2496. Skip1Field := P.Dataset.FindField('Run1_Skipped');
  2497. Skip2Field := P.Dataset.FindField('Run2_Skipped');
  2498. end
  2499. else
  2500. Skip2Field := nil;
  2501. Run1Field := P.Dataset.FindField('OK');
  2502. if Run1Field = nil then
  2503. Run1Field := P.Dataset.FindField('Run1_OK');
  2504. Run2Field := P.Dataset.FindField('OK');
  2505. if Run2Field = nil then
  2506. Run2Field := P.Dataset.FindField('Run2_OK');
  2507. If (not FNoSkipped) and ((Skip1Field.AsString='+')
  2508. or ((Skip2Field <> nil) and (Skip2Field.AsString = '+'))) then
  2509. begin
  2510. Inc(FRunSkipCount);
  2511. BGColor:='yellow'; // Yellow
  2512. end
  2513. else If Run2Field.AsString='+' then
  2514. begin
  2515. if Run1Field.AsString='' then
  2516. BGColor:='#68DFB8'
  2517. else if Run1Field.ASString<>'+' then
  2518. BGColor:='#98FB98'; // pale Green
  2519. end
  2520. else if Run2Field.AsString='-' then
  2521. begin
  2522. Inc(FRunFailedCount);
  2523. if Run1Field.AsString='' then
  2524. BGColor:='#FF82AB' // Light red
  2525. else if Run1Field.AsString<>'-' then
  2526. BGColor:='#FF225B';
  2527. end;
  2528. end;
  2529. end;
  2530. procedure TTestSuite.FormatFailedOverview(Sender: TObject; var CellData: String);
  2531. Var
  2532. S: String;
  2533. P : TTableProducer;
  2534. begin
  2535. P:=(Sender as TTableProducer);
  2536. S:=Format(SDetailsURL,[P.DataSet.FieldByName('ID').AsString]);
  2537. S:=S+'&amp;failedonly=1&amp;noskipped=1';
  2538. CellData:=Format('<A HREF="%s">%s</A>',[S,CellData]);
  2539. end;
  2540. function TTestSuite.FormatDetailURL(const RunIdStr, CellData : String) : string;
  2541. Var
  2542. S : String;
  2543. begin
  2544. S:=Format(SDetailsURL,[RunIdStr]);
  2545. if FOnlyFailed then
  2546. S:=S+'&amp;failedonly=1';
  2547. if FNoSkipped then
  2548. S:=S+'&amp;noskipped=1';
  2549. FormatDetailURL:=Format('<A HREF="%s">%s</A>',[S,CellData]);
  2550. end;
  2551. procedure TTestSuite.FormatTestRunOverview(Sender: TObject; var CellData: String);
  2552. Var
  2553. S: String;
  2554. P : TTableProducer;
  2555. begin
  2556. P:=(Sender as TTableProducer);
  2557. S:=Format(SDetailsURL,[P.DataSet.FieldByName('RUN').AsString]);
  2558. if FOnlyFailed then
  2559. S:=S+'&amp;failedonly=1';
  2560. if FNoSkipped then
  2561. S:=S+'&amp;noskipped=1';
  2562. CellData:=Format('<A HREF="%s">%s</A>',[S,CellData]);
  2563. end;
  2564. procedure TTestSuite.FormatSVN(Sender: TObject; var CellData: String);
  2565. begin
  2566. FormatSVNData(CellData);
  2567. end;
  2568. procedure TTestSuite.FormatSVNData(var CellData: String);
  2569. Var
  2570. S, Rev, SubStr, Remaining : String;
  2571. P : TTableProducer;
  2572. pos_colon, pos_sep : longint;
  2573. begin
  2574. pos_sep:=pos('/', CellData);
  2575. if pos_sep=0 then
  2576. begin
  2577. pos_colon:=pos(':',CellData);
  2578. S:=ViewRevURL+copy(CellData,pos_colon+1,length(CellData));
  2579. CellData:=Format('<A HREF="%s" target="_blank">%s</A>',[S,CellData]);
  2580. end
  2581. else
  2582. begin
  2583. SubStr:=Copy(CellData,1,pos_sep-1);
  2584. Remaining:=Copy(CellData,pos_sep+1,length(CellData));
  2585. CellData:='';
  2586. while SubStr<>'' do
  2587. begin
  2588. pos_colon:=pos(':',SubStr);
  2589. Rev:=copy(SubStr,pos_colon+1,length(SubStr));
  2590. { Remove suffix like M for modified...}
  2591. while not (Rev[length(Rev)] in ['0'..'9']) do
  2592. Rev:=Copy(Rev,1,length(Rev)-1);
  2593. S:=ViewRevURL+Rev;
  2594. CellData:=CellData+Format('<A HREF="%s" target="_blank">%s</A>',[S,SubStr]);
  2595. if Remaining='' then
  2596. SubStr:=''
  2597. else
  2598. begin
  2599. pos_sep:=pos('/',Remaining);
  2600. if pos_sep=0 then
  2601. pos_sep:=length(Remaining)+1;
  2602. CellData:=CellData+':';
  2603. SubStr:=Copy(Remaining,1,pos_sep-1);
  2604. Remaining:=Copy(Remaining,pos_sep+1,length(Remaining));
  2605. end;
  2606. end;
  2607. end;
  2608. end;
  2609. procedure TTestSuite.FormatFileIDDetails(Sender: TObject; var CellData: String);
  2610. Var
  2611. S: String;
  2612. P : TTableProducer;
  2613. begin
  2614. P:=(Sender as TTableProducer);
  2615. if FVersion<>'' then
  2616. S:=Format(TestSuiteCGIURL + '?action=%d&amp;version=%s&amp;testfileid=%s',
  2617. [faction_show_history,FVersion,P.DataSet.FieldByName('Id').AsString])
  2618. else
  2619. S:=Format(TestSuiteCGIURL + '?action=%d&amp;testfileid=%s',
  2620. [faction_show_history,P.DataSet.FieldByName('Id').AsString]);
  2621. CellData:=Format('<A HREF="%s">%s</A>',[S,CellData]);
  2622. end;
  2623. procedure TTestSuite.FormatFileDetails(Sender: TObject; var CellData: String);
  2624. Var
  2625. S: String;
  2626. P : TTableProducer;
  2627. begin
  2628. P:=(Sender as TTableProducer);
  2629. if FCompareRunID<>'' then
  2630. S:=Format(TestSuiteCGIURL + '?action=%d&amp;run1id=%s&amp;run2id=%s&amp;testfileid=%s',
  2631. [faction_show_one_test,FRunID,FCompareRunID,P.DataSet.FieldByName('Id').AsString])
  2632. else
  2633. S:=Format(TestSuiteCGIURL + '?action=%d&amp;run1id=%s&amp;testfileid=%s',
  2634. [faction_show_one_test,FRunID,P.DataSet.FieldByName('Id').AsString]);
  2635. CellData:=Format('<A HREF="%s">%s</A>',[S,CellData]);
  2636. end;
  2637. procedure TTestSuite.FormatTestResult(Sender: TObject; var CellData: String);
  2638. Var
  2639. Res : longint;
  2640. Error:word;
  2641. TS : TTestStatus;
  2642. begin
  2643. Val(CellData,Res,Error);
  2644. if (Error=0) and (Res>=longint(FirstStatus)) and
  2645. (Res<=longint(LastStatus)) then
  2646. begin
  2647. TS:=TTestStatus(Res);
  2648. CellData:=StatusText[TS];
  2649. end;
  2650. end;
  2651. Procedure TTestSuite.CreateRunPie;
  2652. Var
  2653. I : TFPMemoryImage;
  2654. M : TMemoryStream;
  2655. begin
  2656. ftFont.InitEngine;
  2657. FontMgr.SearchPath:='/usr/lib/X11/fonts/truetype';
  2658. I:=TFPMemoryImage.Create(320,320);
  2659. try
  2660. If FRunCount=0 Then
  2661. Raise Exception.Create('Invalid parameters passed to script: No total count');
  2662. DoDrawPie(I,FRunSkipCount,FRunFailedCount,FRunCount);
  2663. M:=TMemoryStream.Create;
  2664. Try
  2665. With TFPWriterPNG.Create do
  2666. try
  2667. UseAlpha:=True;
  2668. ImageWrite(M,I);
  2669. Finally
  2670. Free;
  2671. end;
  2672. ContentType:='image/png';
  2673. //EmitDocType;
  2674. EmitContentType;
  2675. M.Position:=0;
  2676. Response.CopyFrom(M,M.Size);
  2677. Finally
  2678. M.Free;
  2679. end;
  2680. Finally
  2681. I.Free;
  2682. end;
  2683. end;
  2684. Procedure TTestSuite.DoDrawPie(Img : TFPCustomImage; Skipped,Failed,Total : Integer);
  2685. Var
  2686. Cnv : TFPImageCanvas;
  2687. W,H,FH,CR,ra : Integer;
  2688. A1,A2,FR,SR,PR : Double;
  2689. R : TRect;
  2690. F : TFreeTypeFont;
  2691. Procedure AddPie(X,Y,R : Integer; AStart,AStop : Double; Col : TFPColor);
  2692. Var
  2693. DX,Dy : Integer;
  2694. begin
  2695. DX:=Round(R*Cos(A1));
  2696. DY:=Round(R*Sin(A1));
  2697. Cnv.Line(X,Y,X+DX,Y-DY);
  2698. DX:=Round(Ra*Cos(A2));
  2699. DY:=Round(Ra*Sin(A2));
  2700. Cnv.Line(X,Y,X+DX,Y-Dy);
  2701. DX:=Round(R/2*Cos((A1+A2)/2));
  2702. DY:=Round(R/2*Sin((A1+A2)/2));
  2703. Cnv.Brush.FpColor:=Col;
  2704. Cnv.FloodFill(X+DX,Y-DY);
  2705. end;
  2706. Function FractionAngle(F,T : Integer): Double;
  2707. begin
  2708. Result:=(2*Pi*(F/T))
  2709. end;
  2710. begin
  2711. F:=TFreeTypeFont.Create;
  2712. With F do
  2713. begin
  2714. Name:='arial';
  2715. FontIndex:=0;
  2716. Size:=12;
  2717. FPColor:=colred;
  2718. AntiAliased:=False;
  2719. Resolution:=96;
  2720. end;
  2721. if FDebug then
  2722. Writeln(stdout,'Creating image');
  2723. Cnv:=TFPImageCanvas.Create(Img);
  2724. if FDebug then
  2725. Writeln(stdout,'CNV=0x',hexstr(ptruint(cnv),16));
  2726. if FDebug then
  2727. Writeln(stdout,'Getting width and height');
  2728. W:=Img.Width;
  2729. H:=Img.Height;
  2730. if FDebug then
  2731. begin
  2732. Writeln(stdout,'width=',W,' height=',H);
  2733. //system.flush(stdout);
  2734. end;
  2735. // Writeln('Transparant');
  2736. cnv.Brush.Style:=bsSolid;
  2737. cnv.Brush.FPColor:=colTransparent;
  2738. cnv.Pen.FPColor:=colWhite;
  2739. Cnv.Rectangle(0,0,W,H);
  2740. if FDEbug then
  2741. Writeln(stdout,'Setting font');
  2742. Cnv.Font:=F;
  2743. if FDebug then
  2744. Writeln(stdout,'Getting textwidth ');
  2745. FH:=CNV.GetTextHeight('A');
  2746. If FH=0 then
  2747. FH:=14; // 3 * 14;
  2748. if FDebug then
  2749. writeln(stdout,'FH=',FH);
  2750. Inc(FH,3);
  2751. R.Top:=FH*4;
  2752. R.Left:=0;
  2753. R.Bottom:=H;
  2754. CR:=H-(FH*4);
  2755. If W>CR then
  2756. R.Right:=CR
  2757. else
  2758. R.Right:=W;
  2759. Ra:=CR div 2;
  2760. if FDEbug then
  2761. begin
  2762. Writeln(stdout,'Setting pen color');
  2763. system.flush(stdout);
  2764. end;
  2765. Cnv.Pen.FPColor:=colBlack;
  2766. if FDebug then
  2767. begin
  2768. Writeln(stdout,'Palette size : ',Img.Palette.Count);
  2769. Writeln(stdout,'Setting brush style');
  2770. system.flush(stdout);
  2771. end;
  2772. cnv.brush.FPColor:=colRed;
  2773. // cnv.pen.width:=1;
  2774. // Writeln('Drawing ellipse');
  2775. Cnv.Ellipse(R);
  2776. if FDebug then
  2777. begin
  2778. Writeln(stdout,'Setting text');
  2779. system.flush(stdout);
  2780. end;
  2781. Cnv.Textout(1,FH*2,Format('%d Skipped (%3.1f%%)',[Skipped,SR*100]));
  2782. A1:=(Pi*2*(failed/total));
  2783. A2:=A1+(Pi*2*(Skipped/Total));
  2784. AddPie(Ra,R.Top+Ra,Ra,A1,A2,ColYellow);
  2785. cnv.font.FPColor:=colGreen;
  2786. // Writeln('Palette size : ',Img.Palette.Count);
  2787. A1:=A2;
  2788. A2:=A1+(Pi*2*((Total-(Skipped+Failed))/Total));
  2789. Cnv.Textout(1,FH*3,Format('%d Passed (%3.1f%%',[Total-Skipped-Failed,PR*100]));
  2790. AddPie(Ra,R.Top+Ra,Ra,A1,A2,ColGreen);
  2791. // Writeln('Palette size : ',Img.Palette.Count);
  2792. // Writeln('All done');
  2793. end;
  2794. begin
  2795. if paramstr(0)<>'' then
  2796. TestsuiteCGIURL:=TestsuiteURLPrefix+'cgi-bin/'+extractfilename(paramstr(0))
  2797. else
  2798. TestsuiteCGIURL:=TestsuiteURLPrefix+'cgi-bin/'+TestsuiteBin;
  2799. SDetailsURL := TestsuiteCGIURL + '?action=1&amp;run1id=%s';
  2800. ShortDateFormat:='yyyy/mm/dd';
  2801. end.