utests.pp 89 KB

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