Exemplo n.º 1
0
 /** End Element */
 public function endElement($parser, $name)
 {
     $parent = $this->getParent();
     // should be before endElement
     parent::endElement($parser, $name);
     if ($name == "STARTDATETIME" && $parent == 'COVERAGELOG') {
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $this->Build->ProjectId = $this->projectid;
         $this->BuildId = $this->Build->GetIdFromName($this->SubProjectName);
         if ($this->BuildId == 0) {
             $t = 'Cannot add a coverage log to a build that does not exist';
             $f = 'CoverageLogHandler::endElement';
             add_log($t, $f, LOG_ERR, $this->projectid);
         }
     } else {
         if ($name == 'LINE') {
             $this->CoverageFile->File .= '<br>';
             // cannot be <br/> for backward compatibility
         } else {
             if ($name == 'FILE') {
                 if ($this->BuildId != 0) {
                     $this->CoverageFile->Update($this->BuildId);
                     $this->CoverageFileLog->BuildId = $this->BuildId;
                     $this->CoverageFileLog->FileId = $this->CoverageFile->Id;
                     $this->CoverageFileLog->Insert();
                 }
                 unset($this->CoverageFile);
                 unset($this->CoverageFileLog);
             }
         }
     }
 }
Exemplo n.º 2
0
 /** endElement function */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'NOTE') {
         $this->Build->ProjectId = $this->projectid;
         $this->Build->GetIdFromName($this->SubProjectName);
         $this->Build->RemoveIfDone();
         // If the build doesn't exist we add it.
         if ($this->Build->Id == 0) {
             $this->Build->SetSubProject($this->SubProjectName);
             // Since we only have precision in minutes (not seconds) here,
             // set the start time at the end of the minute so it can be overridden
             // by any more precise XML file received later.
             $start_time = gmdate(FMT_DATETIME, strtotime($this->Note->Time) + 59);
             $this->Build->StartTime = $start_time;
             $this->Build->EndTime = $this->Note->Time;
             $this->Build->SubmitTime = gmdate(FMT_DATETIME);
             $this->Build->InsertErrors = false;
             add_build($this->Build, $this->scheduleid);
         }
         if ($this->Build->Id > 0) {
             // Insert the note
             $this->Note->BuildId = $this->Build->Id;
             $this->Note->Insert();
         } else {
             add_log('Trying to add a note to a nonexistent build', 'note_handler.php', LOG_ERR);
         }
     }
 }
Exemplo n.º 3
0
 /** End element */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'SITE') {
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $this->Build->ProjectId = $this->projectid;
         $this->Build->StartTime = $start_time;
         $this->Build->EndTime = $end_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->InsertErrors = false;
             add_build($this->Build, $this->scheduleid);
         } else {
             // Otherwise make sure that it's up-to-date.
             $this->Build->UpdateBuild($this->Build->Id, -1, -1);
         }
         $GLOBALS['PHP_ERROR_BUILD_ID'] = $this->Build->Id;
         $this->CoverageSummary->BuildId = $this->Build->Id;
         // Insert coverage summary
         $this->CoverageSummary->Insert(true);
         $this->CoverageSummary->ComputeDifference();
     } elseif ($name == 'FILE') {
         $this->CoverageSummary->AddCoverage($this->Coverage);
     } elseif ($name == 'LABEL') {
         if (isset($this->Coverage)) {
             $this->Coverage->AddLabel($this->Label);
         }
     }
 }
Exemplo n.º 4
0
 /** End element */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'SITE') {
         $this->Site->Insert();
     } elseif ($name == 'UPDATE') {
         $this->Build->SiteId = $this->Site->Id;
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $submit_time = gmdate(FMT_DATETIME);
         $this->Build->StartTime = $start_time;
         $this->Build->EndTime = $end_time;
         $this->Build->SubmitTime = $submit_time;
         $this->Build->ProjectId = $this->projectid;
         $this->Build->GetIdFromName($this->SubProjectName);
         // Update.xml doesn't include SubProject information.
         // Check if GetIdFromName returned a child build, and
         // if so, change our buildid to point at the parent instead.
         $parentid = $this->Build->LookupParentBuildId();
         if ($parentid > 0) {
             $this->Build->Id = $parentid;
         }
         $this->Build->RemoveIfDone();
         // If the build doesn't exist we add it
         if ($this->Build->Id == 0) {
             $this->Build->SetSubProject($this->SubProjectName);
             $this->Build->Append = $this->Append;
             $this->Build->InsertErrors = false;
             add_build($this->Build, $this->scheduleid);
         } else {
             // Otherwise make sure that it's up-to-date.
             $this->Build->UpdateBuild($this->Build->Id, -1, -1);
         }
         $GLOBALS['PHP_ERROR_BUILD_ID'] = $this->Build->Id;
         $this->Update->BuildId = $this->Build->Id;
         $this->Update->StartTime = $start_time;
         $this->Update->EndTime = $end_time;
         // Insert the update
         $this->Update->Insert();
         global $CDASH_ENABLE_FEED;
         if ($CDASH_ENABLE_FEED) {
             // We need to work the magic here to have a good description
             $this->Feed->InsertUpdate($this->projectid, $this->Build->Id);
         }
         if ($this->Update->Command === '') {
             // If the UpdateCommand was not set, then this was a
             // "version only" update.  This means that CTest only told us
             // what version of the code is being built, not what changed
             // since last time.  In this case we need to query the remote
             // repository to figure out what changed.
             perform_version_only_diff($this->Update, $this->projectid);
         }
         // Compute the update statistics
         $this->Build->ComputeUpdateStatistics();
     } elseif ($name == 'UPDATED' || $name == 'CONFLICTING' || $name == 'MODIFIED') {
         $this->Update->AddFile($this->UpdateFile);
         unset($this->UpdateFile);
     }
 }
Exemplo n.º 5
0
 /** endElement function */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'NOTE') {
         if ($this->BuildId > 0) {
             // Insert the note
             $this->Note->BuildId = $this->BuildId;
             $this->Note->Insert();
         } else {
             add_log("note_handler.php", "Trying to add a note to an unexisting build");
         }
     }
 }
Exemplo n.º 6
0
 /** End element */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'SITE') {
         $this->Site->Insert();
     } else {
         if ($name == 'UPDATE') {
             $this->Build->SiteId = $this->Site->Id;
             $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
             $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
             $submit_time = gmdate(FMT_DATETIME);
             $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 = $end_time;
                 $this->Build->SubmitTime = $submit_time;
                 $this->Build->InsertErrors = false;
                 add_build($this->Build, $this->scheduleid);
                 $buildid = $this->Build->Id;
             } else {
                 $this->Build->Id = $buildid;
                 $this->Build->ProjectId = $this->projectid;
                 $this->Build->StartTime = $start_time;
                 $this->Build->EndTime = $end_time;
                 $this->Build->SubmitTime = $submit_time;
             }
             $GLOBALS['PHP_ERROR_BUILD_ID'] = $buildid;
             $this->Update->BuildId = $buildid;
             $this->Update->StartTime = $start_time;
             $this->Update->EndTime = $end_time;
             // Insert the update
             $this->Update->Insert();
             global $CDASH_ENABLE_FEED;
             if ($CDASH_ENABLE_FEED) {
                 // We need to work the magic here to have a good description
                 $this->Feed->InsertUpdate($this->projectid, $buildid);
             }
             // Compute the update statistics
             $this->Build->ComputeUpdateStatistics();
         } else {
             if ($name == 'UPDATED' || $name == 'CONFLICTING' || $name == 'MODIFIED') {
                 $this->Update->AddFile($this->UpdateFile);
                 unset($this->UpdateFile);
             }
         }
     }
 }
Exemplo n.º 7
0
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'CONFIGURE') {
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $this->Build->ProjectId = $this->projectid;
         $this->Build->ProjectId = $this->projectid;
         $this->Build->StartTime = $start_time;
         $this->Build->EndTime = $end_time;
         $this->Build->SubmitTime = gmdate(FMT_DATETIME);
         $this->Build->SetSubProject($this->SubProjectName);
         $this->Build->InsertErrors = false;
         $this->Build->GetIdFromName($this->SubProjectName);
         $this->Build->RemoveIfDone();
         if ($this->Build->Id == 0) {
             // If the build doesn't exist we add it
             add_build($this->Build, $this->scheduleid);
         } else {
             // Otherwise we make sure that it's up-to-date.
             $this->Build->UpdateBuild($this->Build->Id, -1, -1);
         }
         $GLOBALS['PHP_ERROR_BUILD_ID'] = $this->Build->Id;
         $this->Configure->BuildId = $this->Build->Id;
         $this->Configure->StartTime = $start_time;
         $this->Configure->EndTime = $end_time;
         // Insert the configure
         if ($this->Configure->Exists()) {
             $this->Configure->Delete();
         }
         $this->Configure->Insert();
         // Insert errors from the log file
         $this->Configure->ComputeWarnings();
         $this->Configure->ComputeErrors();
         $this->Build->ComputeConfigureDifferences();
         // Record the number of warnings & errors with the build.
         $this->Build->SetNumberOfConfigureWarnings($this->Configure->NumberOfWarnings);
         $this->Build->SetNumberOfConfigureErrors($this->Configure->NumberOfErrors);
         // Record configure duration with the build.
         $this->Build->SetConfigureDuration($this->EndTimeStamp - $this->StartTimeStamp);
         // Update the tally of warnings & errors in the parent build,
         // if applicable.
         $this->Build->UpdateParentConfigureNumbers($this->Configure->NumberOfWarnings, $this->Configure->NumberOfErrors);
     } elseif ($name == 'LABEL') {
         if (isset($this->Configure)) {
             $this->Configure->AddLabel($this->Label);
         }
     }
 }
Exemplo n.º 8
0
 /** End Element */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name === 'SITE') {
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $this->Build->ProjectId = $this->projectid;
         $this->Build->StartTime = $start_time;
         $this->Build->EndTime = $end_time;
         $this->Build->SubmitTime = gmdate(FMT_DATETIME);
         $this->Build->SetSubProject($this->SubProjectName);
         $this->Build->GetIdFromName($this->SubProjectName);
         $this->Build->RemoveIfDone();
         if ($this->Build->Id == 0) {
             // If the build doesn't exist we add it.
             $this->Build->InsertErrors = false;
             add_build($this->Build, $this->scheduleid);
         } else {
             // Otherwise make sure that it's up-to-date.
             $this->Build->UpdateBuild($this->Build->Id, -1, -1);
         }
         // Record the coverage data that we parsed from this file.
         foreach ($this->CoverageFiles as $coverageInfo) {
             $coverageFile = $coverageInfo[0];
             $coverageFileLog = $coverageInfo[1];
             $coverageFile->TrimLastNewline();
             $coverageFile->Update($this->Build->Id);
             $coverageFileLog->BuildId = $this->Build->Id;
             $coverageFileLog->FileId = $coverageFile->Id;
             $coverageFileLog->Insert(true);
         }
     } elseif ($name == 'LINE') {
         $this->CurrentCoverageFile->File .= rtrim($this->CurrentLine);
         // Cannot be <br/> for backward compatibility.
         $this->CurrentCoverageFile->File .= '<br>';
     } elseif ($name == 'FILE') {
         // Store these objects to be inserted after we're guaranteed
         // to have a valid buildid.
         $this->CoverageFiles[] = array($this->CurrentCoverageFile, $this->CurrentCoverageFileLog);
     } elseif ($name == 'COVERAGELOG') {
         if (empty($this->CoverageFiles)) {
             // Store these objects to be inserted after we're guaranteed
             // to have a valid buildid.
             $this->CoverageFiles[] = array(new CoverageFile(), new CoverageFileLog());
         }
     }
 }
Exemplo n.º 9
0
 /** End element */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'SITE') {
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $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 = $end_time;
             $this->Build->SubmitTime = gmdate(FMT_DATETIME);
             $this->Build->InsertErrors = false;
             add_build($this->Build, $this->scheduleid);
             $buildid = $this->Build->Id;
         }
         // Remove any previous coverage information
         $GLOBALS['PHP_ERROR_BUILD_ID'] = $buildid;
         $this->CoverageSummary->BuildId = $buildid;
         $this->CoverageSummary->RemoveAll();
         // Insert coverage summary
         $this->CoverageSummary->Insert();
         $this->CoverageSummary->ComputeDifference();
     } else {
         if ($name == 'FILE') {
             $this->CoverageSummary->AddCoverage($this->Coverage);
         } else {
             if ($name == 'LABEL') {
                 if (isset($this->Coverage)) {
                     $this->Coverage->AddLabel($this->Label);
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
 /** Function endElement */
 public function endElement($parser, $name)
 {
     $parent = $this->getParent();
     // should be before endElement
     parent::endElement($parser, $name);
     if ($name == "STARTTESTTIME" && $parent == 'DYNAMICANALYSIS') {
         $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->InsertErrors = false;
             add_build($this->Build, $this->scheduleid);
             $this->UpdateEndTime = true;
             $buildid = $this->Build->Id;
         } else {
             // Remove all the previous analysis
             $this->DynamicAnalysis = new DynamicAnalysis();
             $this->DynamicAnalysis->BuildId = $buildid;
             $this->DynamicAnalysis->RemoveAll();
             unset($this->DynamicAnalysis);
         }
         $GLOBALS['PHP_ERROR_BUILD_ID'] = $buildid;
         $this->BuildId = $buildid;
     } else {
         if ($name == "TEST" && $parent == 'DYNAMICANALYSIS') {
             $this->DynamicAnalysis->BuildId = $this->BuildId;
             $this->DynamicAnalysis->Insert();
         } else {
             if ($name == 'DEFECT') {
                 $this->DynamicAnalysis->AddDefect($this->DynamicAnalysisDefect);
                 unset($this->DynamicAnalysisDefect);
             } else {
                 if ($name == "SITE") {
                     if ($this->UpdateEndTime) {
                         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
                         // The EndTimeStamp
                         $this->Build->UpdateEndTime($end_time);
                     }
                 } else {
                     if ($name == 'LABEL') {
                         if (isset($this->DynamicAnalysis)) {
                             $this->DynamicAnalysis->AddLabel($this->Label);
                         }
                     } else {
                         if ($name == 'DYNAMICANALYSIS') {
                             // If everything is perfect CTest doesn't send any <test>
                             // But we still want a line showing the current dynamic analysis
                             if (!isset($this->DynamicAnalysis)) {
                                 $this->DynamicAnalysis = new DynamicAnalysis();
                                 $this->DynamicAnalysis->BuildId = $this->BuildId;
                                 $this->DynamicAnalysis->Status = 'passed';
                                 $this->DynamicAnalysis->Checker = $this->Checker;
                                 $this->DynamicAnalysis->Insert();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'BUILD') {
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $submit_time = gmdate(FMT_DATETIME);
         $this->Build->ProjectId = $this->projectid;
         $this->Build->StartTime = $start_time;
         $this->Build->EndTime = $end_time;
         $this->Build->SubmitTime = $submit_time;
         $this->Build->SetSubProject($this->SubProjectName);
         $this->Build->Append = $this->Append;
         add_build($this->Build, $this->scheduleid);
         $this->Build->ComputeDifferences();
         global $CDASH_ENABLE_FEED;
         if ($CDASH_ENABLE_FEED) {
             // Insert the build into the feed
             $this->Feed->InsertBuild($this->projectid, $this->Build->Id);
         }
     } else {
         if ($name == 'WARNING' || $name == 'ERROR' || $name == 'FAILURE') {
             global $CDASH_LARGE_TEXT_LIMIT;
             $threshold = $CDASH_LARGE_TEXT_LIMIT;
             if ($threshold > 0 && isset($this->Error->StdOutput)) {
                 $outlen = strlen($this->Error->StdOutput);
                 if ($outlen > $threshold) {
                     $tmp = substr($this->Error->StdOutput, 0, $threshold);
                     unset($this->Error->StdOutput);
                     $this->Error->StdOutput = $tmp . "\n...\nCDash truncated output because it exceeded {$threshold} characters.\n";
                     $outlen = strlen($this->Error->StdOutput);
                     //add_log("truncated long out text", "build_handler", LOG_INFO);
                 }
                 $errlen = strlen($this->Error->StdError);
                 if ($errlen > $threshold) {
                     $tmp = substr($this->Error->StdError, 0, $threshold);
                     unset($this->Error->StdError);
                     $this->Error->StdError = $tmp . "\n...\nCDash truncated output because it exceeded {$threshold} characters.\n";
                     $errlen = strlen($this->Error->StdError);
                     //add_log("truncated long err text", "build_handler", LOG_INFO);
                 }
             }
             $this->Build->AddError($this->Error);
             unset($this->Error);
         } else {
             if ($name == 'LABEL') {
                 if (isset($this->Error)) {
                     $this->Error->AddLabel($this->Label);
                 } else {
                     if (isset($this->Build)) {
                         $this->Build->AddLabel($this->Label);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
 /** Function endElement */
 public function endElement($parser, $name)
 {
     $parent = $this->getParent();
     // should be before endElement
     parent::endElement($parser, $name);
     if ($this->UploadError) {
         return;
     }
     if ($name == 'FILE' && $parent == 'UPLOAD') {
         $this->UploadFile->BuildId = $this->BuildId;
         // Close base64 temporary file writing handler
         fclose($this->Base64TmpFileWriteHandle);
         unset($this->Base64TmpFileWriteHandle);
         // Decode file using 'read by chunk' approach to minimize memory footprint
         // Note: Using stream_filter_append/stream_copy_to_stream is more efficient but
         // return an "invalid byte sequence" on windows
         $rhandle = fopen($this->Base64TmpFilename, 'r');
         $whandle = fopen($this->TmpFilename, 'w+');
         $chunksize = 4096;
         while (!feof($rhandle)) {
             fwrite($whandle, base64_decode(fread($rhandle, $chunksize)));
         }
         fclose($rhandle);
         unset($rhandle);
         fclose($whandle);
         unset($whandle);
         // Delete base64 encoded file
         $success = cdash_unlink($this->Base64TmpFilename);
         if (!$success) {
             add_log("Failed to delete file '" . $this->Base64TmpFilename . "'", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING);
         }
         // Check file size against the upload quota
         $upload_file_size = filesize($this->TmpFilename);
         $Project = new Project();
         $Project->Id = $this->projectid;
         $Project->Fill();
         if ($upload_file_size > $Project->UploadQuota) {
             add_log("Size of uploaded file {$this->TmpFilename} is {$upload_file_size} bytes, which is greater " . "than the total upload quota for this project ({$Project->UploadQuota} bytes)", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
             $this->UploadError = true;
             cdash_unlink($this->TmpFilename);
             return;
         }
         // Compute SHA1 of decoded file
         $upload_file_sha1 = sha1_file($this->TmpFilename);
         // TODO Check if a file if same buildid, sha1 and name has already been uploaded
         $this->UploadFile->Sha1Sum = $upload_file_sha1;
         $this->UploadFile->Filesize = $upload_file_size;
         // Extension of the file indicates if it's a data file that should be hosted on CDash of if
         // an URL should just be considered. File having extension ".url" are expected to contain an URL.
         $path_parts = pathinfo($this->UploadFile->Filename);
         $ext = $path_parts['extension'];
         if ($ext == "url") {
             $this->UploadFile->IsUrl = true;
             // Read content of the file
             $url_length = 255;
             // max length of 'uploadfile.filename' field
             $this->UploadFile->Filename = trim(file_get_contents($this->TmpFilename, NULL, NULL, 0, $url_length));
             cdash_unlink($this->TmpFilename);
             //add_log("this->UploadFile->Filename '".$this->UploadFile->Filename."'", __FILE__.':'.__LINE__.' - '.__FUNCTION__, LOG_INFO);
         } else {
             $this->UploadFile->IsUrl = false;
             $upload_dir = realpath($GLOBALS['CDASH_UPLOAD_DIRECTORY']);
             if (!$upload_dir) {
                 add_log("realpath cannot resolve CDASH_UPLOAD_DIRECTORY '" . $GLOBALS['CDASH_UPLOAD_DIRECTORY'] . "' with cwd '" . getcwd() . "'", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING);
             }
             $upload_dir .= '/' . $this->UploadFile->Sha1Sum;
             $uploadfilepath = $upload_dir . '/' . $this->UploadFile->Sha1Sum;
             // Check if upload directory should be created
             if (!file_exists($upload_dir)) {
                 $success = mkdir($upload_dir);
                 if (!$success) {
                     add_log("Failed to create directory '" . $upload_dir . "'", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
                     $this->UploadError = true;
                     return;
                 }
             }
             // Check if file has already been referenced
             if (!file_exists($uploadfilepath)) {
                 $success = rename($this->TmpFilename, $uploadfilepath);
                 if (!$success) {
                     add_log("Failed to rename file '" . $this->TmpFilename . "' into '" . $uploadfilepath . "'", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
                     $this->UploadError = true;
                     return;
                 }
             } else {
                 // Delete decoded temporary file since it has already been addressed
                 $success = cdash_unlink($this->TmpFilename);
                 if (!$success) {
                     add_log("Failed to delete file '" . $this->TmpFilename . "'", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING);
                 }
             }
             // Generate symlink name
             $symlinkName = $path_parts['basename'];
             // Check if symlink should be created
             $createSymlink = !file_exists($upload_dir . '/' . $symlinkName);
             if ($createSymlink) {
                 // Create symlink
                 if (function_exists("symlink")) {
                     $success = symlink($uploadfilepath, $upload_dir . '/' . $symlinkName);
                 } else {
                     $success = 0;
                 }
                 if (!$success) {
                     // Log actual non-testing symlink failure as an error:
                     $level = LOG_ERR;
                     // But if testing, log as info only:
                     if ($GLOBALS['CDASH_TESTING_MODE']) {
                         $level = LOG_INFO;
                     }
                     add_log("Failed to create symlink [target:'" . $uploadfilepath . "', name: '" . $upload_dir . '/' . $symlinkName . "']", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, $level);
                     // Fall back to a full copy if symlink does not exist, or if it failed:
                     $success = copy($uploadfilepath, $upload_dir . '/' . $symlinkName);
                     if (!$success) {
                         add_log("Failed to copy file (symlink fallback) [target:'" . $uploadfilepath . "', name: '" . $upload_dir . '/' . $symlinkName . "']", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
                         $this->UploadError = true;
                         return;
                     }
                 }
             }
         }
         // Update model
         $success = $this->UploadFile->Insert();
         if (!$success) {
             add_log("UploadFile model - Failed to insert row associated with file: '" . $this->UploadFile->Filename . "'", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         }
         $Project->CullUploadedFiles();
         // Reset UploadError so that the handler could attempt to process following files
         $this->UploadError = false;
     }
 }
Exemplo n.º 13
0
 /** Function endElement */
 public function endElement($parser, $name)
 {
     $parent = $this->getParent();
     // should be before endElement
     parent::endElement($parser, $name);
     if ($name == 'STARTTESTTIME' && $parent == 'DYNAMICANALYSIS') {
         $this->Build->ProjectId = $this->projectid;
         $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
         $this->Build->StartTime = $start_time;
         // EndTimeStamp hasn't been parsed yet.  We update this value later.
         $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->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);
             // Remove all the previous analysis
             $this->DynamicAnalysis = new DynamicAnalysis();
             $this->DynamicAnalysis->BuildId = $this->Build->Id;
             $this->DynamicAnalysis->RemoveAll();
             unset($this->DynamicAnalysis);
         }
         $GLOBALS['PHP_ERROR_BUILD_ID'] = $this->Build->Id;
         $this->DynamicAnalysisSummary->BuildId = $this->Build->Id;
     } elseif ($name == 'TEST' && $parent == 'DYNAMICANALYSIS') {
         $this->DynamicAnalysis->BuildId = $this->Build->Id;
         $this->DynamicAnalysis->Insert();
     } elseif ($name == 'DEFECT') {
         $this->DynamicAnalysis->AddDefect($this->DynamicAnalysisDefect);
         $this->DynamicAnalysisSummary->AddDefects($this->DynamicAnalysisDefect->Value);
         unset($this->DynamicAnalysisDefect);
     } elseif ($name == 'LABEL') {
         if (isset($this->DynamicAnalysis)) {
             $this->DynamicAnalysis->AddLabel($this->Label);
         }
     } elseif ($name == 'DYNAMICANALYSIS') {
         // Update this build's end time if necessary.
         $this->Build->EndTime = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $this->Build->UpdateBuild($this->Build->Id, -1, -1);
         // If everything is perfect CTest doesn't send any <test>
         // But we still want a line showing the current dynamic analysis
         if (!isset($this->DynamicAnalysis)) {
             $this->DynamicAnalysis = new DynamicAnalysis();
             $this->DynamicAnalysis->BuildId = $this->Build->Id;
             $this->DynamicAnalysis->Status = 'passed';
             $this->DynamicAnalysis->Checker = $this->Checker;
             $this->DynamicAnalysis->Insert();
         }
         $this->DynamicAnalysisSummary->Insert();
         // If this is a child build append these defects to the parent's
         // summary.
         $parentid = $this->Build->LookupParentBuildId();
         if ($parentid > 0) {
             $this->DynamicAnalysisSummary->BuildId = $parentid;
             $this->DynamicAnalysisSummary->Insert(true);
         }
     }
 }
Exemplo n.º 14
0
 /** End Element */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if ($name == 'FAILURE') {
         $this->BuildTest->Status = 'failed';
     } elseif ($name == 'TESTCASE') {
         if ($this->BuildTest->Status == 'passed') {
             $this->NumberTestsPassed++;
         } elseif ($this->BuildTest->Status == 'failed') {
             $this->NumberTestsFailed++;
         }
         $this->Test->Insert();
         if ($this->Test->Id > 0) {
             $this->BuildTest->TestId = $this->Test->Id;
             $this->BuildTest->BuildId = $this->Build->Id;
             $this->BuildTest->Insert();
             $this->Test->InsertLabelAssociations($this->Build->Id);
         } else {
             add_log('Cannot insert test', 'Test XML parser', LOG_ERR, $this->projectid, $this->Build->Id);
         }
     } elseif ($name == 'SITE' || $this->HasSiteTag == false && $name == 'TESTSUITE') {
         if (strlen($this->EndTimeStamp) > 0 && $this->UpdateEndTime) {
             $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
             // The EndTimeStamp
             $this->Build->UpdateEndTime($end_time);
         }
         // Update the number of tests in the Build table
         $this->Build->UpdateTestNumbers($this->NumberTestsPassed, $this->NumberTestsFailed, $this->NumberTestsNotRun);
         $this->Build->ComputeTestTiming();
     }
 }
Exemplo n.º 15
0
 /** End Element */
 public function endElement($parser, $name)
 {
     //$parent = $this->getParent(); // should be before endElement
     parent::endElement($parser, $name);
     if ($name == "TEST-CASE") {
         $this->Test->Insert();
         if ($this->Test->Id > 0) {
             $this->BuildTest->TestId = $this->Test->Id;
             $this->BuildTest->BuildId = $this->BuildId;
             $this->BuildTest->Insert();
             $this->Test->InsertLabelAssociations($this->BuildId);
         } else {
             add_log("Cannot insert test", "Test XML parser", LOG_ERR, $this->projectid, $this->BuildId);
         }
     } else {
         if ($name == "SITE" || $this->HasSiteTag == false && $name == "TEST-RESULTS") {
             if (strlen($this->EndTimeStamp) > 0 && $this->UpdateEndTime) {
                 $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
                 // The EndTimeStamp
                 $this->Build->UpdateEndTime($end_time);
             }
             // Update the number of tests in the Build table
             $this->Build->UpdateTestNumbers($this->NumberTestsPassed, $this->NumberTestsFailed, $this->NumberTestsNotRun);
             $this->Build->ComputeTestTiming();
         }
     }
 }
Exemplo n.º 16
0
 /** End Element */
 public function endElement($parser, $name)
 {
     $parent = $this->getParent();
     // should be before endElement
     parent::endElement($parser, $name);
     if ($name == 'TEST' && $parent == 'TESTING') {
         $this->Test->Insert();
         if ($this->Test->Id > 0) {
             $this->BuildTest->TestId = $this->Test->Id;
             $this->BuildTest->BuildId = $this->Build->Id;
             $this->BuildTest->Insert();
             $this->Test->InsertLabelAssociations($this->Build->Id);
         } else {
             add_log('Cannot insert test', 'Test XML parser', LOG_ERR, $this->projectid, $this->Build->Id);
         }
     } elseif ($name == 'LABEL' && $parent == 'LABELS') {
         if (isset($this->Test)) {
             $this->Test->AddLabel($this->Label);
         }
     } elseif ($name == 'NAMEDMEASUREMENT') {
         if ($this->TestMeasurement->Name == 'Execution Time') {
             $this->BuildTest->Time = $this->TestMeasurement->Value;
         } elseif ($this->TestMeasurement->Name == 'Exit Code') {
             if (strlen($this->Test->Details) > 0) {
                 $this->Test->Details .= ' (' . $this->TestMeasurement->Value . ')';
             } else {
                 $this->Test->Details = $this->TestMeasurement->Value;
             }
         } elseif ($this->TestMeasurement->Name == 'Completion Status') {
             if (strlen($this->Test->Details) > 0) {
                 $this->Test->Details = $this->TestMeasurement->Value . ' (' . $this->Test->Details . ')';
             } else {
                 $this->Test->Details = $this->TestMeasurement->Value;
             }
         } elseif ($this->TestMeasurement->Name == 'Command Line') {
             // don't do anything since it should already be in the FullCommandLine
         } else {
             // explicit measurement
             // If it's an image we add it as an image
             if (strpos($this->TestMeasurement->Type, 'image') !== false) {
                 $image = new Image();
                 $image->Extension = $this->TestMeasurement->Type;
                 $image->Data = $this->TestMeasurement->Value;
                 $image->Name = $this->TestMeasurement->Name;
                 $this->Test->AddImage($image);
             } else {
                 $this->TestMeasurement->Value = trim($this->TestMeasurement->Value);
                 $this->Test->AddMeasurement($this->TestMeasurement);
             }
         }
     } elseif ($name == 'SITE') {
         // Update the number of tests in the Build table
         $this->Build->UpdateTestNumbers($this->NumberTestsPassed, $this->NumberTestsFailed, $this->NumberTestsNotRun);
         $this->Build->ComputeTestTiming();
         if ($this->StartTimeStamp > 0 && $this->EndTimeStamp > 0) {
             // Update test duration in the Build table.
             $this->Build->SaveTotalTestsTime($this->EndTimeStamp - $this->StartTimeStamp);
         }
         // Update the build's end time to extend through testing.
         $end_time = gmdate(FMT_DATETIME, $this->EndTimeStamp);
         $this->Build->EndTime = $end_time;
         $this->Build->UpdateBuild($this->Build->Id, -1, -1);
         global $CDASH_ENABLE_FEED;
         if ($CDASH_ENABLE_FEED) {
             // Insert the build into the feed
             $this->Feed->InsertTest($this->projectid, $this->Build->Id);
         }
     }
 }
Exemplo n.º 17
0
 /** endElement function */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     if (!$this->ProjectNameMatches) {
         return;
     }
     if ($name == 'PROJECT') {
         foreach ($this->SubProjects as $subproject) {
             // Remove dependencies that do not exist anymore, but only for those
             // relationships where both sides are present in $this->SubProjects.
             //
             $dependencyids = $subproject->GetDependencies();
             $removeids = array_diff($dependencyids, $this->Dependencies[$subproject->GetId()]);
             foreach ($removeids as $removeid) {
                 if (array_key_exists($removeid, $this->SubProjects)) {
                     $subproject->RemoveDependency($removeid);
                 } else {
                     $dep = pdo_get_field_value("SELECT name FROM subproject WHERE id='{$removeid}'", "name", "{$removeid}");
                     add_log("Not removing dependency {$dep}({$removeid}) from " . $subproject->GetName() . "because it is not a SubProject element in this Project.xml file", "ProjectHandler:endElement", LOG_WARNING, $this->projectid);
                 }
             }
             // Add dependencies that were queued up as we processed the DEPENDENCY
             // elements:
             //
             foreach ($this->Dependencies[$subproject->GetId()] as $addid) {
                 if (array_key_exists($addid, $this->SubProjects)) {
                     $subproject->AddDependency($addid);
                 } else {
                     add_log("impossible condition: should NEVER see this: unknown DEPENDENCY clause should prevent this case", "ProjectHandler:endElement", LOG_WARNING, $this->projectid);
                 }
             }
         }
         // Delete old subprojects that weren't included in this file.
         $previousSubProjectIds = $this->Project->GetSubProjects();
         foreach ($previousSubProjectIds as $previousId) {
             $found = false;
             foreach ($this->SubProjects as $subproject) {
                 if ($subproject->GetId() == $previousId) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $subProjectToRemove = new SubProject();
                 $subProjectToRemove->SetId($previousId);
                 $subProjectToRemove->Delete();
             }
         }
     }
 }
Exemplo n.º 18
0
 /**
  * Overrides endElement for data types. Tells the type
  * handler that processing the element had been finished so
  * handlers know they can perform actions that need to be
  * based on the data contained within the element.
  *
  * @param  string  the name of the XML element
  * @return void
  */
 function endElement($name)
 {
     $this->element->parsingComplete();
     parent::endElement($name);
 }
Exemplo n.º 19
0
 /** endElement function */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     global $CDASH_DELETE_OLD_SUBPROJECTS;
     if (!$this->ProjectNameMatches) {
         return;
     }
     if ($name == 'PROJECT') {
         foreach ($this->SubProjects as $subproject) {
             if ($CDASH_DELETE_OLD_SUBPROJECTS) {
                 // Remove dependencies that do not exist anymore,
                 // but only for those relationships where both sides
                 // are present in $this->SubProjects.
                 //
                 $dependencyids = $subproject->GetDependencies();
                 $removeids = array_diff($dependencyids, $this->Dependencies[$subproject->GetId()]);
                 foreach ($removeids as $removeid) {
                     if (array_key_exists($removeid, $this->SubProjects)) {
                         $subproject->RemoveDependency($removeid);
                     } else {
                         $dep = pdo_get_field_value("SELECT name FROM subproject WHERE id='{$removeid}'", 'name', "{$removeid}");
                         add_log("Not removing dependency {$dep}({$removeid}) from " . $subproject->GetName() . 'because it is not a SubProject element in this Project.xml file', 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
                     }
                 }
             }
             // Add dependencies that were queued up as we processed the DEPENDENCY
             // elements:
             //
             foreach ($this->Dependencies[$subproject->GetId()] as $addid) {
                 if (array_key_exists($addid, $this->SubProjects)) {
                     $subproject->AddDependency($addid);
                 } else {
                     add_log('impossible condition: should NEVER see this: unknown DEPENDENCY clause should prevent this case', 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
                 }
             }
         }
         if ($CDASH_DELETE_OLD_SUBPROJECTS) {
             // Delete old subprojects that weren't included in this file.
             $previousSubProjectIds = $this->Project->GetSubProjects();
             foreach ($previousSubProjectIds as $previousId) {
                 $found = false;
                 foreach ($this->SubProjects as $subproject) {
                     if ($subproject->GetId() == $previousId) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $subProjectToRemove = new SubProject();
                     $subProjectToRemove->SetId($previousId);
                     $subProjectToRemove->Delete();
                     add_log("Deleted " . $subProjectToRemove->GetName() . " because it was not mentioned in Project.xml", 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
                 }
             }
         }
     } elseif ($name == 'SUBPROJECT') {
         // Insert the SubProject.
         $this->SubProject->Save();
         // Insert the label.
         $Label = new Label();
         $Label->Text = $this->SubProject->GetName();
         $Label->Insert();
         $this->SubProjects[$this->SubProject->GetId()] = $this->SubProject;
         // Handle dependencies here too.
         $this->Dependencies[$this->SubProject->GetId()] = array();
         foreach ($this->CurrentDependencies as $dependencyid) {
             $added = false;
             if ($dependencyid !== false && is_numeric($dependencyid)) {
                 if (array_key_exists($dependencyid, $this->SubProjects)) {
                     $this->Dependencies[$this->SubProject->GetId()][] = $dependencyid;
                     $added = true;
                 }
             }
             if (!$added) {
                 add_log('Project.xml DEPENDENCY of ' . $this->SubProject->GetName() . ' not mentioned earlier in file.', 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
             }
         }
         // Check if the user is in the database.
         $User = new User();
         $posat = strpos($this->Email, '@');
         if ($posat !== false) {
             $User->FirstName = substr($this->Email, 0, $posat);
             $User->LastName = substr($this->Email, $posat + 1);
         } else {
             $User->FirstName = $this->Email;
             $User->LastName = $this->Email;
         }
         $User->Email = $this->Email;
         $User->Password = md5($this->Email);
         $User->Admin = 0;
         $userid = $User->GetIdFromEmail($this->Email);
         if (!$userid) {
             $User->Save();
             $userid = $User->Id;
         }
         // Insert into the UserProject
         $UserProject = new UserProject();
         $UserProject->EmailType = 3;
         // any build
         $UserProject->EmailCategory = 54;
         // everything except warnings
         $UserProject->UserId = $userid;
         $UserProject->ProjectId = $this->projectid;
         $UserProject->Save();
         // Insert the labels for this user
         $LabelEmail = new LabelEmail();
         $LabelEmail->UserId = $userid;
         $LabelEmail->ProjectId = $this->projectid;
         $Label = new Label();
         $Label->SetText($this->SubProject->GetName());
         $labelid = $Label->GetIdFromText();
         if (!empty($labelid)) {
             $LabelEmail->LabelId = $labelid;
             $LabelEmail->Insert();
         }
     }
 }