77 * Copyright 2012-2013 Kamil Hornicek (kamil.hornicek@reactos.org)
88 */
99
10+ define ("MY_LOGFILE " , "/tmp/WineTest_Writer.log " );
11+
1012 class WineTest_Writer
1113 {
1214 // Member Variables
@@ -16,6 +18,8 @@ class WineTest_Writer
1618 // Public Functions
1719 public function __construct ($ source_id , $ password )
1820 {
21+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": __construct( $ source_id, $ password) \n" , FILE_APPEND );
22+
1923 // Connect to the database.
2024 $ this ->_dbh = new PDO ("mysql:host= " . TESTMAN_DB_HOST . ";dbname= " . TESTMAN_DB_NAME , TESTMAN_DB_USER , TESTMAN_DB_PASS );
2125 $ this ->_dbh ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
@@ -34,39 +38,52 @@ public function __construct($source_id, $password)
3438
3539 public function getTestId ($ revision , $ platform , $ comment )
3640 {
41+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": getTestId( $ revision, $ platform, $ comment) \n" , FILE_APPEND );
42+
3743 // Add a new Test ID with the given information.
3844 $ stmt = $ this ->_dbh ->prepare ("INSERT INTO winetest_runs (source_id, revision, platform, comment) VALUES (:sourceid, :revision, :platform, :comment) " );
3945 $ stmt ->bindValue (":sourceid " , (int )$ this ->_source_id , PDO ::PARAM_INT );
4046 $ stmt ->bindParam (":revision " , $ revision );
4147 $ stmt ->bindParam (":platform " , $ platform );
4248 $ stmt ->bindParam (":comment " , $ comment );
4349 $ stmt ->execute ();
50+ $ id = (int )$ this ->_dbh ->lastInsertId ();
4451
45- return (int )$ this ->_dbh ->lastInsertId ();
52+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": --> new Test ID $ id \n" , FILE_APPEND );
53+ return $ id ;
4654 }
4755
4856 public function getSuiteId ($ module , $ test )
4957 {
58+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": getSuiteId( $ module, $ test) \n" , FILE_APPEND );
59+
5060 // Determine whether we already have a suite ID for this combination.
5161 $ stmt = $ this ->_dbh ->prepare ("SELECT id FROM winetest_suites WHERE module = :module AND test = :test " );
5262 $ stmt ->bindParam (":module " , $ module );
5363 $ stmt ->bindParam (":test " , $ test );
5464 $ stmt ->execute ();
55- $ id = $ stmt ->fetchColumn ();
65+ $ id = ( int ) $ stmt ->fetchColumn ();
5666 if ($ id )
57- return (int )$ id ;
67+ {
68+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": --> existing Suite ID $ id \n" , FILE_APPEND );
69+ return $ id ;
70+ }
5871
5972 // Add this combination to the table and return the ID for it.
6073 $ stmt = $ this ->_dbh ->prepare ("INSERT INTO winetest_suites (module, test) VALUES (:module, :test) " );
6174 $ stmt ->bindParam (":module " , $ module );
6275 $ stmt ->bindParam (":test " , $ test );
6376 $ stmt ->execute ();
77+ $ id = (int )$ this ->_dbh ->lastInsertId ();
6478
65- return (int )$ this ->_dbh ->lastInsertId ();
79+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": --> new Suite ID $ id \n" , FILE_APPEND );
80+ return $ id ;
6681 }
6782
6883 public function getModuleAndTestForSuiteId ($ suite_id , &$ module , &$ test )
6984 {
85+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": getModuleAndTestForSuiteId( $ suite_id) \n" , FILE_APPEND );
86+
7087 $ stmt = $ this ->_dbh ->prepare ("SELECT module, test FROM winetest_suites WHERE id = :id " );
7188 $ stmt ->bindValue (":id " , (int )$ suite_id , PDO ::PARAM_INT );
7289 $ stmt ->execute ();
@@ -75,23 +92,29 @@ public function getModuleAndTestForSuiteId($suite_id, &$module, &$test)
7592 {
7693 $ module = $ row ["module " ];
7794 $ test = $ row ["test " ];
95+
96+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": --> Module and Test: ( $ module, $ test) \n" , FILE_APPEND );
7897 return true ;
7998 }
8099 else
81100 {
101+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": --> No Module and Test for Suite ID \n" , FILE_APPEND );
82102 return false ;
83103 }
84104 }
85105
86106 public function submit ($ test_id , $ suite_id , $ log )
87107 {
108+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": submit( $ test_id, $ suite_id, log...) \n" , FILE_APPEND );
109+
88110 // Make sure that we may add information to the test with this Test ID
89111 $ stmt = $ this ->_dbh ->prepare ("SELECT COUNT(*) FROM winetest_runs WHERE id = :testid AND finished = 0 AND source_id = :sourceid " );
90112 $ stmt ->bindValue (":testid " , (int )$ test_id , PDO ::PARAM_INT );
91113 $ stmt ->bindValue (":sourceid " , (int )$ this ->_source_id , PDO ::PARAM_INT );
92114 $ stmt ->execute ();
93115 if (!$ stmt ->fetchColumn ())
94116 {
117+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": !!! Test ID {$ test_id } for Source ID {$ this ->_source_id } could not be found or accessed in the database! \n" , FILE_APPEND );
95118 throw new RuntimeException ("Test ID {$ test_id } for Source ID {$ this ->_source_id } could not be found or accessed in the database! " );
96119 }
97120
@@ -100,14 +123,17 @@ public function submit($test_id, $suite_id, $log)
100123 $ stmt ->bindValue (":testid " , (int )$ test_id , PDO ::PARAM_INT );
101124 $ stmt ->bindValue (":suiteid " , (int )$ suite_id , PDO ::PARAM_INT );
102125 $ stmt ->execute ();
126+ $ count = $ stmt ->fetchColumn ();
127+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": --> count = $ count \n" , FILE_APPEND );
103128
104- if ($ stmt -> fetchColumn () > 0 )
129+ if ($ count > 0 )
105130 {
106131 $ module = "" ;
107132 $ test = "" ;
108133
109134 if ($ this ->getModuleAndTestForSuiteId ($ suite_id , $ module , $ test ))
110135 {
136+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": !!! Duplicate result for test suite {$ module }: {$ test } in this test run! \n" , FILE_APPEND );
111137 throw new RuntimeException ("Duplicate result for test suite {$ module }: {$ test } in this test run! " );
112138 }
113139 else
@@ -188,6 +214,8 @@ public function submit($test_id, $suite_id, $log)
188214
189215 public function finish ($ test_id , $ performance )
190216 {
217+ file_put_contents (MY_LOGFILE , date ("Y-m-d H:i:s " ) . ": finish( $ test_id, performance...) \n" , FILE_APPEND );
218+
191219 // Sum up all results and mark this test as finished, so no more results can be submitted for it
192220 $ stmt = $ this ->_dbh ->prepare (
193221 "UPDATE winetest_runs
0 commit comments