utests.pp 89 KB

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