public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; if (array_key_exists('APPEND', $attributes)) { if (strtolower($attributes['APPEND']) == "true") { $this->Append = true; } } else { $this->Append = false; } } else { if ($name == 'WARNING') { $this->Error = new BuildError(); $this->Error->Type = 1; } else { if ($name == 'ERROR') { $this->Error = new BuildError(); $this->Error->Type = 0; } else { if ($name == 'FAILURE') { $this->Error = new BuildFailure(); $this->Error->Type = 0; if ($attributes['TYPE'] == "Error") { $this->Error->Type = 0; } else { if ($attributes['TYPE'] == "Warning") { $this->Error->Type = 1; } } } else { if ($name == 'LABEL') { $this->Label = new Label(); } } } } } }
public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = '(empty)'; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { if ($key === 'CHANGEID') { $this->Build->SetPullRequest($value); continue; } $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = '(empty)'; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } elseif ($name == 'LABEL') { $this->Label = new Label(); } }
/** startElement function */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = '(empty)'; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = '(empty)'; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } elseif ($name == 'NOTE') { $this->Note = new BuildNote(); $this->Note->Name = isset($attributes['NAME']) ? $attributes['NAME'] : ''; } }
/** Start element */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } else { if ($name == 'DYNAMICANALYSIS') { $this->Checker = $attributes['CHECKER']; } else { if ($name == 'TEST' && isset($attributes['STATUS'])) { $this->DynamicAnalysis = new DynamicAnalysis(); $this->DynamicAnalysis->Checker = $this->Checker; $this->DynamicAnalysis->Status = $attributes['STATUS']; } else { if ($name == 'DEFECT') { $this->DynamicAnalysisDefect = new DynamicAnalysisDefect(); $this->DynamicAnalysisDefect->Type = $attributes['TYPE']; } else { if ($name == 'LABEL') { $this->Label = new Label(); } else { if ($name == 'LOG') { $this->DynamicAnalysis->LogCompression = isset($attributes['COMPRESSION']) ? $attributes['COMPRESSION'] : ''; $this->DynamicAnalysis->LogEncoding = isset($attributes['ENCODING']) ? $attributes['ENCODING'] : ''; } } } } } } }
/** startElement */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } else { if ($name == 'FILE') { $this->CoverageFile = new CoverageFile(); $this->Coverage = new Coverage(); $this->CoverageFile->FullPath = $attributes['FULLPATH']; if ($attributes['COVERED'] == 1 || $attributes['COVERED'] == "true") { $this->Coverage->Covered = 1; } else { $this->Coverage->Covered = 0; } $this->Coverage->CoverageFile = $this->CoverageFile; } else { if ($name == 'LABEL') { $this->Label = new Label(); } } } }
/** startElement function */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } else { if ($name == 'NOTE') { $this->Note = new BuildNote(); $this->Note->Name = isset($attributes['NAME']) ? $attributes['NAME'] : ''; } else { if ($name == 'NOTES') { // We need a build to add notes (and cannot create one from the information) $this->Build->ProjectId = $this->projectid; $buildid = $this->Build->GetIdFromName($this->SubProjectName); $this->BuildId = $buildid; } } } }
/** Start Element */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); $parent = $this->getParent(); // should be before endElement if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = '(empty)'; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { if ($key === 'CHANGEID') { $this->Build->SetPullRequest($value); continue; } $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = '(empty)'; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; if (array_key_exists('APPEND', $attributes)) { $this->Append = $attributes['APPEND']; } else { $this->Append = false; } } elseif ($name == 'TEST' && count($attributes) > 0) { $this->Test = new Test(); $this->Test->ProjectId = $this->projectid; $this->BuildTest = new BuildTest(); $this->BuildTest->Status = $attributes['STATUS']; if ($attributes['STATUS'] == 'passed') { $this->NumberTestsPassed++; } elseif ($attributes['STATUS'] == 'failed') { $this->NumberTestsFailed++; } elseif ($attributes['STATUS'] == 'notrun') { $this->NumberTestsNotRun++; } } elseif ($name == 'NAMEDMEASUREMENT') { $this->TestMeasurement = new TestMeasurement(); if ($attributes['TYPE'] == 'file') { $this->TestMeasurement->Name = $attributes['FILENAME']; } else { $this->TestMeasurement->Name = $attributes['NAME']; } $this->TestMeasurement->Type = $attributes['TYPE']; } elseif ($name == 'VALUE' && $parent == 'MEASUREMENT') { if (isset($attributes['COMPRESSION']) && $attributes['COMPRESSION'] == 'gzip') { $this->Test->CompressedOutput = true; } } elseif ($name == 'LABEL' && $parent == 'LABELS') { $this->Label = new Label(); } elseif ($name == 'TESTLIST' && $parent == 'TESTING') { $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp); $this->Build->ProjectId = $this->projectid; $this->Build->StartTime = $start_time; // EndTimeStamp hasn't been parsed yet. $this->Build->EndTime = $start_time; $this->Build->SubmitTime = gmdate(FMT_DATETIME); $this->Build->SetSubProject($this->SubProjectName); $this->Build->GetIdFromName($this->SubProjectName); $this->Build->RemoveIfDone(); // If the build doesn't exist we add it if ($this->Build->Id == 0) { $this->Build->Append = $this->Append; $this->Build->InsertErrors = false; add_build($this->Build, $this->scheduleid); } else { // Otherwise make sure that the build is up-to-date. $this->Build->UpdateBuild($this->Build->Id, -1, -1); // If the build already exists factor the number of tests // that have already been run into our running total. $this->NumberTestsFailed += $this->Build->GetNumberOfFailedTests(); $this->NumberTestsNotRun += $this->Build->GetNumberOfNotRunTests(); $this->NumberTestsPassed += $this->Build->GetNumberOfPassedTests(); } $GLOBALS['PHP_ERROR_BUILD_ID'] = $this->Build->Id; } }
/** Start Element */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); $parent = $this->getParent(); // should be before endElement if ($name == 'SITE') { $this->HasSiteTag = true; $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; if (array_key_exists('APPEND', $attributes)) { $this->Append = $attributes['APPEND']; } else { $this->Append = false; } } else { if ($name == "TEST-CASE" && count($attributes) > 0) { $this->Test = new Test(); $this->Test->ProjectId = $this->projectid; $this->BuildTest = new BuildTest(); $teststatus = "notrun"; if ($attributes['RESULT'] == "Success") { $teststatus = "passed"; } else { if ($attributes['RESULT'] == "Failure") { $teststatus = "failed"; } } $this->BuildTest->Status = $teststatus; if ($teststatus == "passed") { $this->NumberTestsPassed++; } else { if ($teststatus == "failed") { $this->NumberTestsFailed++; } else { if ($teststatus == "notrun") { $this->NumberTestsNotRun++; } } } if (isset($attributes['TIME'])) { $this->BuildTest->Time = $attributes['TIME']; } if (isset($attributes['ASSERTS'])) { $this->Test->Details = $attributes['ASSERTS']; } $this->Test->Name = $attributes['NAME']; $this->Test->Path = $attributes['NAME']; $this->Test->Command = $attributes['NAME']; } else { if ($name == "TEST-RESULTS") { $this->StartTimeStamp = strtotime($attributes['DATE'] . ' ' . $attributes['TIME']); $this->EndTimeStamp = $this->StartTimeStamp; } else { if ($this->HasSiteTag == false && $name == "ENVIRONMENT") { // If the XML file doesn't have a <Site> tag then we use the information // provided by the testsuite. // buildname is 'name' // sitename is 'hostname' // timestamp is 'timestamp' $this->Site->Name = $attributes['MACHINE-NAME']; $this->Site->Insert(); $buildInformation = new BuildInformation(); $buildInformation->OSName = $attributes['PLATFORM']; $buildInformation->OSVersion = $attributes['OS-VERSION']; $buildInformation->CompilerName = 'CLR'; $buildInformation->CompilerVersion = $attributes['CLR-VERSION']; $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['PLATFORM']; // Construct a CMake-Like build stamp // We assume Nightly $stamp = date("Ymd-Hi", $this->StartTimeStamp) . '-Nightly'; $this->Build->SetStamp($stamp); $this->Build->Information = $buildInformation; $this->Append = false; } else { if ($this->BuildAdded == false && $name == "TEST-SUITE") { $this->Build->SaveTotalTestsTime(0); $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp); $this->Build->ProjectId = $this->projectid; $buildid = $this->Build->GetIdFromName($this->SubProjectName); // If the build doesn't exist we add it if ($buildid == 0) { $this->Build->ProjectId = $this->projectid; $this->Build->StartTime = $start_time; $this->Build->EndTime = $start_time; $this->Build->SubmitTime = gmdate(FMT_DATETIME); $this->Build->SetSubProject($this->SubProjectName); $this->Build->Append = $this->Append; $this->Build->InsertErrors = false; add_build($this->Build, $this->scheduleid); $this->UpdateEndTime = true; $buildid = $this->Build->Id; } else { $this->Build->Id = $buildid; //if the build already exists factor the number of tests that have //already been run into our running total $this->NumberTestsFailed += $this->Build->GetNumberOfFailedTests(); $this->NumberTestsNotRun += $this->Build->GetNumberOfNotRunTests(); $this->NumberTestsPassed += $this->Build->GetNumberOfPassedTests(); } $GLOBALS['PHP_ERROR_BUILD_ID'] = $buildid; $this->BuildId = $buildid; $this->BuildAdded = true; } } } } } }
/** startElement */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); $parent = $this->getParent(); if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } else { if ($name == 'SOURCEFILE') { $this->CoverageFile = new CoverageFile(); $this->Coverage = new Coverage(); $this->CoverageFile->FullPath = $attributes['NAME']; $this->Coverage->Covered = 1; $this->Coverage->CoverageFile = $this->CoverageFile; } else { if ($name == 'LABEL') { $this->Label = new Label(); } else { if ($parent == 'REPORT' && $name == 'SESSIONINFO') { // timestamp are in miliseconds $this->StartTimeStamp = substr($attributes['START'], 0, -3); $this->EndTimeStamp = substr($attributes['DUMP'], 0, -3); } else { if ($parent == 'REPORT' && $name == 'COUNTER') { switch ($attributes['TYPE']) { case 'LINE': $this->CoverageSummary->LocTested = intval($attributes['COVERED']); $this->CoverageSummary->LocUntested = intval($attributes['MISSED']); break; case 'COMPLEXITY': $this->CoverageSummary->BranchesTested = intval($attributes['COVERED']); $this->CoverageSummary->BranchesUntested = intval($attributes['MISSED']); break; case 'METHOD': $this->CoverageSummary->FunctionsTested = intval($attributes['COVERED']); $this->CoverageSummary->FunctionsUntested = intval($attributes['MISSED']); break; } } else { if ($parent == 'SOURCEFILE' && $name == 'COUNTER') { switch ($attributes['TYPE']) { case 'LINE': $this->Coverage->LocTested = intval($attributes['COVERED']); $this->Coverage->LocUntested = intval($attributes['MISSED']); break; case 'COMPLEXITY': $this->Coverage->BranchesTested = intval($attributes['COVERED']); $this->Coverage->BranchesUntested = intval($attributes['MISSED']); break; case 'METHOD': $this->Coverage->FunctionsTested = intval($attributes['COVERED']); $this->Coverage->FunctionsUntested = intval($attributes['MISSED']); break; } } } } } } } }
/** Start Element */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); $parent = $this->getParent(); // should be before endElement if ($name == 'SITE') { $this->HasSiteTag = true; $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; if (array_key_exists('APPEND', $attributes)) { $this->Append = $attributes['APPEND']; } else { $this->Append = false; } } else { if ($name == "FAILURE") { $this->Test->Details = $attributes['TYPE']; } else { if ($name == "PROPERTY" && $parent == "PROPERTIES") { $this->TestProperties .= $attributes['NAME'] . '=' . $attributes['VALUE'] . "\n"; if ($this->HasSiteTag == false) { switch ($attributes['NAME']) { case 'os.name': $this->Build->Information->OSName = $attributes['VALUE']; break; case 'os.version': $this->Build->Information->OSVersion = $attributes['VALUE']; break; case 'java.vm.name': $this->Build->Information->CompilerName = $attributes['VALUE']; break; case 'java.vm.version': $this->Build->Information->CompilerVersion = $attributes['VALUE']; break; case 'hostname': if (empty($this->Site->Name)) { $this->Site->Name = $attributes['VALUE']; $this->Site->Insert(); $this->Build->SiteId = $this->Site->Id; } break; } } } else { if ($name == "TESTCASE" && count($attributes) > 0) { if ($this->BuildAdded == false) { $this->Build->SaveTotalTestsTime(0); $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp); $this->Build->ProjectId = $this->projectid; $buildid = $this->Build->GetIdFromName($this->SubProjectName); // If the build doesn't exist we add it if ($buildid == 0) { $this->Build->ProjectId = $this->projectid; $this->Build->StartTime = $start_time; $this->Build->EndTime = $start_time; $this->Build->SubmitTime = gmdate(FMT_DATETIME); $this->Build->SetSubProject($this->SubProjectName); $this->Build->Append = $this->Append; $this->Build->InsertErrors = false; add_build($this->Build, $this->scheduleid); $this->UpdateEndTime = true; $buildid = $this->Build->Id; } else { $this->Build->Id = $buildid; //if the build already exists factor the number of tests that have //already been run into our running total $this->NumberTestsFailed += $this->Build->GetNumberOfFailedTests(); $this->NumberTestsNotRun += $this->Build->GetNumberOfNotRunTests(); $this->NumberTestsPassed += $this->Build->GetNumberOfPassedTests(); } $GLOBALS['PHP_ERROR_BUILD_ID'] = $buildid; $this->BuildId = $buildid; $this->BuildAdded = true; } $this->Test = new Test(); $this->Test->Command = $this->TestProperties; $this->Test->ProjectId = $this->projectid; $this->BuildTest = new BuildTest(); if (isset($attributes['TIME'])) { $this->BuildTest->Time = $attributes['TIME']; } // Default is that the test passes unless there is a <failure> tag $this->BuildTest->Status = "passed"; $this->Test->Name = $attributes['NAME']; $this->Test->Path = $attributes['CLASSNAME']; } else { if ($name == "TESTSUITE") { // If the XML file doesn't have a <Site> tag then we use the information // provided by the testsuite. // buildname is 'name' // sitename is 'hostname' // timestamp is 'timestamp' if ($this->HasSiteTag == false) { // Hostname is not necessarily defined if (!empty($attributes['HOSTNAME'])) { $this->Site->Name = $attributes['HOSTNAME']; $this->Site->Insert(); $this->Build->SiteId = $this->Site->Id; } $this->Build->Information = new BuildInformation(); $this->Build->Name = $attributes['NAME']; // Construct a CMake-Like build stamp // We assume Nightly // If the TIMESTAMP attribute is not defined we take the current timestamp if (!isset($attributes['TIMESTAMP'])) { $timestamp = time(); } else { $timestamp = strtotime($attributes['TIMESTAMP']); } $stamp = date("Ymd-Hi", $timestamp) . '-Nightly'; $this->Build->SetStamp($stamp); $this->Append = false; } else { if (!isset($attributes['TIMESTAMP'])) { $stamp = $this->Build->GetStamp(); $timestamp = mktime(substr($stamp, 9, 2), substr($stamp, 11, 2), 0, substr($stamp, 6, 2), substr($stamp, 4, 2), substr($stamp, 0, 4)); } } $this->StartTimeStamp = $timestamp; $this->EndTimeStamp = $this->StartTimeStamp + $attributes['TIME']; $this->Build->SaveTotalTestsTime($attributes['TIME']); } } } } } }
/** Start element */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($this->UploadError) { return; } if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = "(empty)"; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = "(empty)"; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } else { if ($name == 'UPLOAD') { $this->Build->ProjectId = $this->projectid; $buildid = $this->Build->GetIdFromName($this->SubProjectName); // If the build doesn't exist we add it if ($buildid == 0) { $this->Build->ProjectId = $this->projectid; $this->Build->StartTime = gmdate(FMT_DATETIME); $this->Build->EndTime = gmdate(FMT_DATETIME); $this->Build->SubmitTime = gmdate(FMT_DATETIME); $this->Build->SetSubProject($this->SubProjectName); $this->Build->Append = false; $this->Build->InsertErrors = false; add_build($this->Build, $this->scheduleid); $this->UpdateEndTime = true; $buildid = $this->Build->Id; } else { $this->Build->Id = $buildid; } $GLOBALS['PHP_ERROR_BUILD_ID'] = $buildid; $this->BuildId = $buildid; } else { if ($name == 'FILE') { $this->UploadFile = new UploadFile(); $this->UploadFile->Filename = $attributes['FILENAME']; } else { if ($name == 'CONTENT') { $fileEncoding = isset($attributes['ENCODING']) ? $attributes['ENCODING'] : 'base64'; if (strcmp($fileEncoding, 'base64') != 0) { // Only base64 encoding is supported for file upload add_log("upload_handler: Only 'base64' encoding is supported", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); $this->UploadError = true; return; } // Create tmp file $this->TmpFilename = tempnam($GLOBALS['CDASH_UPLOAD_DIRECTORY'], 'tmp'); // TODO Handle error if (empty($this->TmpFilename)) { add_log("Failed to create temporary filename", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); $this->UploadError = true; return; } $this->Base64TmpFilename = $this->TmpFilename . '-base64'; // Open base64 temporary file for writting $this->Base64TmpFileWriteHandle = fopen($this->Base64TmpFilename, 'w'); if (!$this->Base64TmpFileWriteHandle) { add_log("Failed to open file '" . $this->Base64TmpFilename . "' for writting", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); $this->UploadError = true; return; } } } } } }
/** Start element */ public function startElement($parser, $name, $attributes) { parent::startElement($parser, $name, $attributes); if ($this->UploadError) { return; } if ($name == 'SITE') { $this->Site->Name = $attributes['NAME']; if (empty($this->Site->Name)) { $this->Site->Name = '(empty)'; } $this->Site->Insert(); $siteInformation = new SiteInformation(); $buildInformation = new BuildInformation(); // Fill in the attribute foreach ($attributes as $key => $value) { $siteInformation->SetValue($key, $value); $buildInformation->SetValue($key, $value); } $this->Site->SetInformation($siteInformation); $this->Build->SiteId = $this->Site->Id; $this->Build->Name = $attributes['BUILDNAME']; if (empty($this->Build->Name)) { $this->Build->Name = '(empty)'; } $this->Build->SetStamp($attributes['BUILDSTAMP']); $this->Build->Generator = $attributes['GENERATOR']; $this->Build->Information = $buildInformation; } elseif ($name == 'UPLOAD') { // Setting start time and end time is tricky here, since all // we have is the build stamp. The strategy we take here is: // Set the start time as late as possible, and set the end time // as early as possible. // This way we don't override any existing values for these fields // when we call UpdateBuild() below. // // For end time, we use the start of the testing day. // For start time, we use either the submit time (now) or // one second before the start time of the *next* testing day // (whichever is earlier). // Yes, this means the build finished before it began. // // This associates the build with the correct day if it is only // an upload. Otherwise we defer to the values set by the // other handlers. $row = pdo_single_row_query("SELECT nightlytime FROM project where id='{$this->projectid}'"); $nightly_time = $row['nightlytime']; $build_date = extract_date_from_buildstamp($this->Build->GetStamp()); list($prev, $nightly_start_time, $next) = get_dates($build_date, $nightly_time); // If the nightly start time is after noon (server time) // and this buildstamp is on or after the nightly start time // then this build belongs to the next testing day. if (date(FMT_TIME, $nightly_start_time) > '12:00:00') { $build_timestamp = strtotime($build_date); $next_timestamp = strtotime($next); if (strtotime(date(FMT_TIME, $build_timestamp), $next_timestamp) >= strtotime(date(FMT_TIME, $nightly_start_time), $next_timestamp)) { $nightly_start_time += 3600 * 24; } } $this->Build->EndTime = gmdate(FMT_DATETIME, $nightly_start_time); $now = time(); $one_second_before_tomorrow = strtotime('+1 day -1 second', $nightly_start_time); if ($one_second_before_tomorrow < time()) { $this->Build->StartTime = gmdate(FMT_DATETIME, $one_second_before_tomorrow); } else { $this->Build->StartTime = gmdate(FMT_DATETIME, $now); } $this->Build->SubmitTime = gmdate(FMT_DATETIME, $now); $this->Build->ProjectId = $this->projectid; $this->Build->SetSubProject($this->SubProjectName); $this->Build->GetIdFromName($this->SubProjectName); $this->Build->RemoveIfDone(); // If the build doesn't exist we add it if ($this->Build->Id == 0) { $this->Build->Append = false; $this->Build->InsertErrors = false; add_build($this->Build, $this->scheduleid); $this->UpdateEndTime = true; } else { // Otherwise make sure that the build is up-to-date. $this->Build->UpdateBuild($this->Build->Id, -1, -1); } $GLOBALS['PHP_ERROR_BUILD_ID'] = $this->Build->Id; } elseif ($name == 'FILE') { $this->UploadFile = new UploadFile(); $this->UploadFile->Filename = $attributes['FILENAME']; } elseif ($name == 'CONTENT') { $fileEncoding = isset($attributes['ENCODING']) ? $attributes['ENCODING'] : 'base64'; if (strcmp($fileEncoding, 'base64') != 0) { // Only base64 encoding is supported for file upload add_log("upload_handler: Only 'base64' encoding is supported", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); $this->UploadError = true; return; } // Create tmp file $this->TmpFilename = tempnam($GLOBALS['CDASH_UPLOAD_DIRECTORY'], 'tmp'); // TODO Handle error if (empty($this->TmpFilename)) { add_log('Failed to create temporary filename', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); $this->UploadError = true; return; } $this->Base64TmpFilename = $this->TmpFilename . '-base64'; // Open base64 temporary file for writting $this->Base64TmpFileWriteHandle = fopen($this->Base64TmpFilename, 'w'); if (!$this->Base64TmpFileWriteHandle) { add_log("Failed to open file '" . $this->Base64TmpFilename . "' for writting", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); $this->UploadError = true; return; } } }