utests.pp 90 KB

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