/** * Parse an individual .gcov file. **/ public function ParseGcovFile($fileinfo) { $coverageFileLog = new CoverageFileLog(); $coverageFileLog->AggregateBuildId = $this->AggregateBuildId; $coverageFileLog->PreviousAggregateParentId = $this->PreviousAggregateParentId; $coverageFile = new CoverageFile(); $coverage = new Coverage(); $coverage->CoverageFile = $coverageFile; // Begin parsing this file. // The first thing we look for is the full path to this source file. $file = new SplFileObject($fileinfo); $path = ''; while (!$file->eof()) { $gcovLine = $file->current(); $term = ':Source:'; $pos = strpos($gcovLine, $term); if ($pos !== false) { $path = substr($gcovLine, $pos + strlen($term)); break; } $file->next(); } if (empty($path)) { return; } // Check if this file belongs to a different SubProject. $buildid = $this->Build->Id; if (!empty($this->SubProjectPath) && strpos($path, $this->SubProjectPath) === false) { // Find the SubProject that corresponds to this path. $query = "SELECT id, name, path FROM subproject\n WHERE projectid = {$this->ProjectId} AND\n endtime = '1980-01-01 00:00:00' AND\n path != '' AND\n '{$path}' LIKE CONCAT('%',path,'%')"; $result = pdo_query($query); if (!$result || pdo_num_rows($result) == 0) { add_log("No SubProject found for '{$path}'", 'ParseGcovFile', LOG_INFO, $this->ProjectId, $this->Build->Id); return; } $row = pdo_fetch_array($result); $subprojectid = $row['id']; $subprojectname = $row['name']; $subprojectpath = $row['path']; // Find the sibling build that performed this SubProject. $siblingBuild = new Build(); $query = 'SELECT b.id FROM build AS b INNER JOIN subproject2build AS sp2b ON (sp2b.buildid=b.id) WHERE b.parentid= (SELECT parentid FROM build WHERE id=' . $this->Build->Id . ")\n AND sp2b.subprojectid={$subprojectid}"; $row = pdo_single_row_query($query); if ($row && array_key_exists('id', $row)) { $buildid = $row['id']; $siblingBuild->Id = $buildid; $siblingBuild->FillFromId($buildid); } else { // Build doesn't exist yet, add it here. $siblingBuild->Name = $this->Build->Name; $siblingBuild->ProjectId = $this->ProjectId; $siblingBuild->SiteId = $this->Build->SiteId; $siblingBuild->SetParentId($this->Build->GetParentId()); $siblingBuild->SetStamp($this->Build->GetStamp()); $siblingBuild->SetSubProject($subprojectname); $siblingBuild->StartTime = $this->Build->StartTime; $siblingBuild->EndTime = $this->Build->EndTime; $siblingBuild->SubmitTime = gmdate(FMT_DATETIME); add_build($siblingBuild, 0); $buildid = $siblingBuild->Id; } $coverageFileLog->Build = $siblingBuild; // Remove any part of the file path that comes before // the subproject path. $path = substr($path, strpos($path, $subprojectpath)); // Replace the subproject path with '.' $path = substr_replace($path, '.', 0, strlen($subprojectpath)); } else { // If this source file isn't from the source or binary directory // we shouldn't include it in our coverage report. if (!empty($this->SubProjectPath) && strpos($path, $this->SubProjectPath) !== false) { $path = substr($path, strpos($path, $this->SubProjectPath)); $path = substr_replace($path, '.', 0, strlen($this->SubProjectPath)); } elseif (strpos($path, $this->SourceDirectory) !== false) { $path = str_replace($this->SourceDirectory, '.', trim($path)); } elseif (strpos($path, $this->BinaryDirectory) !== false) { $path = str_replace($this->BinaryDirectory, '.', trim($path)); } else { return; } $coverageFileLog->Build = $this->Build; } // Get a reference to the coverage summary for this build. if ($buildid === $this->Build->Id) { $coverageSummary = $this->CoverageSummary; } else { if (!array_key_exists($buildid, $this->SubProjectSummaries)) { $coverageSummary = new CoverageSummary(); $coverageSummary->BuildId = $buildid; $this->SubProjectSummaries[$buildid] = $coverageSummary; } else { $coverageSummary = $this->SubProjectSummaries[$buildid]; } } // Use a regexp to resolve any /../ in this path. // We can't use realpath() because we're referencing a path that // doesn't exist on the server. // For a source file that contains: // #include "src/../include/foo.h" // CDash will report the covered file as include/foo.h $pattern = "#/[^/]*?/\\.\\./#"; while (strpos($path, "/../") !== false) { $path = preg_replace($pattern, "/", $path, 1); } $coverageFile->FullPath = trim($path); $lineNumber = 0; // The lack of rewind is intentional. while (!$file->eof()) { $gcovLine = $file->current(); // "Ordinary" entries in a .gcov file take the following format: // <lineNumber>: <timesHit>: <source code at that line> // So we check if this line matches the format & parse the // data out of it if so. $fields = explode(':', $gcovLine, 3); if (count($fields) > 2) { // Separate out delimited values from this line. $timesHit = trim($fields[0]); $lineNumber = trim($fields[1]); $sourceLine = rtrim($fields[2]); if ($lineNumber > 0) { $coverageFile->File .= $sourceLine; // cannot be <br/> for backward compatibility. $coverageFile->File .= '<br>'; } // This is how gcov indicates a line of unexecutable code. if ($timesHit === '-') { $file->next(); continue; } // This is how gcov indicates an uncovered line. if ($timesHit === '#####') { $timesHit = 0; } $coverageFileLog->AddLine($lineNumber - 1, $timesHit); $file->next(); } else { $coveredBranches = 0; $uncoveredBranches = 0; $throwBranches = 0; $fallthroughBranches = 0; while (count($fields) < 3 && !$file->eof()) { // Parse branch coverage here. if (substr($gcovLine, 0, 6) === 'branch') { // Figure out whether this branch was covered or not. if (strpos($gcovLine, 'taken 0%') !== false) { $uncoveredBranches += 1; } else { $coveredBranches += 1; } // Also keep track of the different types of branches encountered. if (strpos($gcovLine, '(throw)') !== false) { $throwBranches += 1; } elseif (strpos($gcovLine, '(fallthrough)') !== false) { $fallthroughBranches += 1; } } $file->next(); $gcovLine = $file->current(); $fields = explode(':', $gcovLine); } // Don't report branch coverage for this line if we only // encountered (throw) and (fallthrough) branches here. $totalBranches = $coveredBranches + $uncoveredBranches; if ($totalBranches > 0 && $totalBranches > $throwBranches + $fallthroughBranches) { $coverageFileLog->AddBranch($lineNumber - 1, $coveredBranches, $totalBranches); } } } // Save these models to the database. $coverageFile->TrimLastNewline(); $coverageFile->Update($buildid); $coverageFileLog->BuildId = $buildid; $coverageFileLog->FileId = $coverageFile->Id; $coverageFileLog->Insert(true); // Query the filelog to get how many lines & branches were covered. // We do this after inserting the filelog because we want to accurately // reflect the union of the current and previously existing results // (if any). $stats = $coverageFileLog->GetStats(); $coverage->LocUntested = $stats['locuntested']; $coverage->LocTested = $stats['loctested']; $coverage->Covered = 1; $coverage->BranchesUntested = $stats['branchesuntested']; $coverage->BranchesTested = $stats['branchestested']; // Add any labels. if (array_key_exists($path, $this->Labels)) { foreach ($this->Labels[$path] as $labelText) { $label = new Label(); $label->SetText($labelText); $coverage->AddLabel($label); } } // Add this Coverage to our summary. $coverageSummary->AddCoverage($coverage); }
/** Function to deal with the external tool mechanism */ function post_submit() { include "models/buildfile.php"; // We expect POST to contain the following values. $vars = array('project', 'build', 'stamp', 'site', 'track', 'type', 'starttime', 'endtime', 'datafilesmd5'); foreach ($vars as $var) { if (!isset($_POST[$var]) || empty($_POST[$var])) { $response_array['status'] = 1; $response_array['description'] = 'Variable \'' . $var . '\' not set but required.'; echo json_encode($response_array); return; } } $projectname = htmlspecialchars(pdo_real_escape_string($_POST['project'])); $buildname = htmlspecialchars(pdo_real_escape_string($_POST['build'])); $buildstamp = htmlspecialchars(pdo_real_escape_string($_POST['stamp'])); $sitename = htmlspecialchars(pdo_real_escape_string($_POST['site'])); $track = htmlspecialchars(pdo_real_escape_string($_POST['track'])); $type = htmlspecialchars(pdo_real_escape_string($_POST['type'])); $starttime = htmlspecialchars(pdo_real_escape_string($_POST['starttime'])); $endtime = htmlspecialchars(pdo_real_escape_string($_POST['endtime'])); // Check if we have the CDash@Home scheduleid $scheduleid = 0; if (isset($_POST["clientscheduleid"])) { $scheduleid = pdo_real_escape_numeric($_POST["clientscheduleid"]); } // Add the build $build = new Build(); $build->ProjectId = get_project_id($projectname); $build->StartTime = gmdate(FMT_DATETIME, $starttime); $build->EndTime = gmdate(FMT_DATETIME, $endtime); $build->SubmitTime = gmdate(FMT_DATETIME); $build->Name = $buildname; $build->InsertErrors = false; // we have no idea if we have errors at this point $build->SetStamp($buildstamp); // Get the site id $site = new Site(); $site->Name = $sitename; $site->Insert(); $build->SiteId = $site->Id; // Make this an "append" build, so that it doesn't result in a separate row // from the rest of the "normal" submission. $build->Append = true; // TODO: Check the labels and generator and other optional if (isset($_POST["generator"])) { $build->Generator = htmlspecialchars(pdo_real_escape_string($_POST['generator'])); } $subprojectname = ""; if (isset($_POST["subproject"])) { $subprojectname = htmlspecialchars(pdo_real_escape_string($_POST['subproject'])); $build->SetSubProject($subprojectname); } // Check if this build already exists. $buildid = $build->GetIdFromName($subprojectname); // If not, add a new one. if ($buildid === 0) { $buildid = add_build($build, $scheduleid); } // Returns the OK submission $response_array['status'] = 0; $response_array['buildid'] = $buildid; $buildfile = new BuildFile(); // Check if the files exists foreach ($_POST['datafilesmd5'] as $md5) { $buildfile->md5 = $md5; $old_buildid = $buildfile->MD5Exists(); if (!$old_buildid) { $response_array['datafilesmd5'][] = 0; } else { $response_array['datafilesmd5'][] = 1; // Associate this build file with the new build if it has been previously // uploaded. require_once "copy_build_data.php"; copy_build_data($old_buildid, $buildid, $type); } } echo json_encode($response_array); }
function testBuildModel() { $this->startCodeCoverage(); $build = new Build(); $builderror = new BuildError(); $builderror->Type = 0; $builderror->Text = 'error'; $buildwarning = new BuildError(); $buildwarning->Type = 1; $buildwarning->Text = 'warning'; if ($build->GetName() !== false) { $this->fail("GetName didn't return false for empty build id"); return 1; } if ($build->GetLabels() !== false) { $this->fail("GetLabels didn't return false for empty build id"); return 1; } if ($build->GetGroup() !== false) { $this->fail("GetGroup didn't return false for empty build id"); return 1; } if ($build->GetNumberOfErrors() !== false) { $this->fail("GetNumberOfErrors didn't return false for empty build id"); return 1; } if ($build->GetNumberOfWarnings() !== false) { $this->fail("GetNumberOfWarnings didn't return false for empty build id"); return 1; } if ($build->SetSubProject('1234') !== false) { $this->fail("SetSubProject didn't return false for empty project id"); return 1; } if ($build->GetSubProjectName() !== false) { $this->fail("GetSubProjectName didn't return false for empty build id"); return 1; } if ($build->GetErrorDifferences() !== false) { $this->fail("GetErrorDifferences didn't return false for empty build id"); return 1; } if ($build->ComputeUpdateStatistics() !== false) { $this->fail("ComputeUpdateStatistics didn't return false for empty build id"); return 1; } if ($build->ComputeDifferences() !== false) { $this->fail("ComputeDifferences didn't return false for empty build id"); return 1; } if ($build->ComputeConfigureDifferences() !== false) { $this->fail("ComputeConfigureDifferences didn't return false for empty build id"); return 1; } if ($build->ComputeTestTiming() !== false) { $this->fail("ComputeTestTiming didn't return false for empty build id"); return 1; } if ($build->InsertLabelAssociations() !== false) { $this->fail("InsertLabelAssocations didn't return false for empty build id"); return 1; } if ($build->UpdateEndTime('2010-08-07') !== false) { $this->fail("UpdateEndTime didn't return false for empty build id"); return 1; } if ($build->SaveTotalTestsTime('100') !== false) { $this->fail("SaveTotalTestsTime didn't return false for empty build id"); return 1; } $build->Id = '1'; if ($build->ComputeTestTiming() !== false) { $this->fail("ComputeTestTiming didn't return false for empty project id"); return 1; } if ($build->ComputeUpdateStatistics() !== false) { $this->fail("ComputeUpdateStatistics didn't return false for empty project id"); return 1; } $build->ProjectId = '2'; $build->SiteId = '1'; $build->SetSubProject('8567'); if (strpos(file_get_contents($this->logfilename), "New subproject detected") === false) { $this->fail("'New subproject detected' not found in log after calling SetSubProject for invalid subproject id"); return 1; } if ($build->Exists() == false) { $this->fail("Exists returned false for a valid build id"); return 1; } $build->Id = '98765'; $build->SetStamp('20100610-1901-Experimental'); $build->Type = ''; //force this empty for coverage purposes $build->StartTime = '2009-12-18 14:19:11'; $build->EndTime = '2009-12-18 14:20:23'; $build->SubmitTime = '2012-01-25 16:43:11'; if ($build->Exists() == true) { $this->fail("Exists returned true for an invalid build id"); return 1; } $build->Save(); $build->Append = true; $build->InsertErrors = true; $build->AddError($builderror); $build->AddError($buildwarning); $build->Save(); $this->stopCodeCoverage(); return 0; }
public function testBuildRemovalWorksAsExpected() { require_once 'include/common.php'; require_once 'include/pdo.php'; require_once 'models/build.php'; require_once 'models/buildconfigure.php'; require_once 'models/builderror.php'; require_once 'models/buildfailure.php'; require_once 'models/buildgroup.php'; require_once 'models/buildnote.php'; require_once 'models/buildupdate.php'; require_once 'models/coverage.php'; require_once 'models/dynamicanalysis.php'; require_once 'models/dynamicanalysissummary.php'; require_once 'models/image.php'; require_once 'models/label.php'; require_once 'models/test.php'; require_once 'models/uploadfile.php'; $time = gmdate(FMT_DATETIME); // Find an existing site. $row = pdo_single_row_query('SELECT id FROM site LIMIT 1'); $siteid = $row['id']; // Label $label = new Label(); $label->SetText('remove me'); // Build $build = new Build(); $build->Name = 'RemovalWorksAsExpected'; $build->SetStamp('20160822-1810-Experimental'); $build->ProjectId = 1; $build->InsertErrors = true; $build->SiteId = $siteid; $build->StartTime = $time; $build->EndTime = $time; $build->SubmitTime = $time; $build->AddLabel($label); $buildgroup = new BuildGroup(); $build->GroupId = $buildgroup->GetGroupIdFromRule($build); $info = new BuildInformation(); $info->SetValue('OSNAME', 'Windows'); $build->Information = $info; // BuildError $error = new BuildError(); $error->Text = 'error: asdf'; $build->AddError($error); // BuildFailure $failure = new BuildFailure(); $failure->StdError = 'failure: asdf'; $failure->AddArgument('arg1'); $failure->AddLabel($label); $build->AddError($failure); $build->Save(); // Create another build to test shared resources. $existing_build = new Build(); $existing_build->Id = $build->Id; $existing_build->FillFromId($build->Id); $existing_build->SetStamp('20160822-1811-Experimental'); $existing_build->SubmitTime = $time; $existing_build->InsertErrors = true; $existing_build->AddError($failure); $existing_build->Id = null; $existing_build->Save(); // BuildConfigure $configure = new BuildConfigure(); $configure->BuildId = $build->Id; $configure->StartTime = $time; $configure->EndTime = $time; $configure->Command = 'cmake'; $configure->Log = "precontext\nWARNING: bar\npostcontext"; $configure->Status = 5; $configure->AddLabel($label); $configure->Insert(); $configure->ComputeWarnings(); $configure->ComputeErrors(); // BuildNote $note = new BuildNote(); $note->Name = 'my note'; $note->Text = 'note text'; $note->Time = $time; $note->BuildId = $build->Id; $note->Insert(); $shared_note = new BuildNote(); $shared_note->Name = 'my shared note'; $shared_note->Text = 'shared note text'; $shared_note->Time = $time; $shared_note->BuildId = $build->Id; $shared_note->Insert(); $shared_note->BuildId = $existing_build->Id; $shared_note->Insert(); // buildtesttime $build->SaveTotalTestsTime(8); // BuildUpdate $updatefile = new BuildUpdateFile(); $updatefile->Author = 'My Self'; $updatefile->Committer = 'My Self'; $updatefile->Email = '*****@*****.**'; $updatefile->CommitterEmail = '*****@*****.**'; $updatefile->Revision = 2; $updatefile->PriorRevision = 1; $updatefile->Filename = 'foo.cpp'; $updatefile->Status = 'MODIFIED'; $update = new BuildUpdate(); $update->AddFile($updatefile); $update->BuildId = $build->Id; $update->StartTime = $time; $update->EndTime = $time; $update->Command = 'git fetch'; $update->Insert(); pdo_query("INSERT INTO build2update (buildid, updateid)\n VALUES ({$existing_build->Id}, {$update->UpdateId})"); // Coverage $file1 = new CoverageFile(); $file1->FullPath = '/path/to/unshared.php'; $file1->File .= "this unshared line gets covered<br>"; $file1->File .= "this unshared line does not<br>"; $coverage1 = new Coverage(); $coverage1->Covered = 1; $coverage1->CoverageFile = $file1; $coverage1->LocTested = 1; $coverage1->LocUntested = 1; $coverage1->AddLabel($label); $file2 = new CoverageFile(); $file2->FullPath = '/path/to/shared.php'; $file2->File .= "this shared line gets covered<br>"; $file2->File .= "this shared line does not<br>"; $coverage2 = new Coverage(); $coverage2->Covered = 1; $coverage2->CoverageFile = $file2; $coverage2->LocTested = 1; $coverage2->LocUntested = 1; $coverage2->AddLabel($label); $summary = new CoverageSummary(); $summary->BuildId = $build->Id; $summary->AddCoverage($coverage1); $summary->AddCoverage($coverage2); $summary->Insert(true); $file1->TrimLastNewline(); $file1->Update($build->Id); $log1 = new CoverageFileLog(); $log1->AddLine(1, 1); $log1->BuildId = $build->Id; $log1->FileId = $file1->Id; $log1->Insert(true); $file2->TrimLastNewline(); $file2->Update($build->Id); $log2 = new CoverageFileLog(); $log2->AddLine(1, 1); $log2->BuildId = $build->Id; $log2->FileId = $file2->Id; $log2->Insert(true); // Also add coverage to existing build to test that shared files // do not get deleted. $existing_cov = new Coverage(); $existing_cov->Covered = 1; $existing_cov->CoverageFile = $file2; $existing_cov->LocTested = 1; $existing_cov->LocUntested = 1; $existing_cov->AddLabel($label); $existing_summary = new CoverageSummary(); $existing_summary->BuildId = $existing_build->Id; $existing_summary->AddCoverage($existing_cov); $existing_summary->Insert(true); $file2->Update($existing_build->Id); $existing_log = new CoverageFileLog(); $existing_log->AddLine(1, 1); $existing_log->BuildId = $existing_build->Id; $existing_log->FileId = $file2->Id; $existing_log->Insert(true); // DynamicAnalysis $DA_defect = new DynamicAnalysisDefect(); $DA_defect->Type = 'Potential Memory Leak'; $DA_defect->Value = 5; $DA = new DynamicAnalysis(); $DA->BuildId = $build->Id; $DA->Checker = 'Valgrind'; $DA->FullCommandLine = 'php DA_removebuilds.php'; $DA->Log = 'build removed successfully'; $DA->Name = 'removal test'; $DA->Path = '/path/to/removal/DA'; $DA->Status = 'failed'; $DA->AddDefect($DA_defect); $DA->AddLabel($label); $DA->Insert(); $DA_summary = new DynamicAnalysisSummary(); $DA_summary->BuildId = $build->Id; $DA_summary->Checker = 'Valgrind'; $DA_summary->AddDefects($DA_defect->Value); $DA_summary->Insert(); // Test $test = new Test(); $test->ProjectId = 1; $test->CompressedOutput = false; $test->Details = 'Completed'; $test->Name = 'removal test'; $test->Path = '/path/to/removal/test'; $test->Command = 'php test_removebuilds.php'; $test->Output = 'build removed successfully'; $measurement = new TestMeasurement(); $measurement->Name = 'Exit Value'; $measurement->Type = 'text/string'; $measurement->Value = 5; $test->AddMeasurement($measurement); $image = new Image(); $image->Extension = 'image/png'; $image->Data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='; $image->Name = 'remove_me.png'; $test->AddImage($image); $test->Insert(); $buildtest = new BuildTest(); $buildtest->BuildId = $build->Id; $buildtest->TestId = $test->Id; $buildtest->Status = 'passed'; $buildtest->Insert(); $test->AddLabel($label); $test->InsertLabelAssociations($build->Id); $test2 = new Test(); $test2->ProjectId = 1; $test2->CompressedOutput = false; $test2->Details = 'Completed'; $test2->Name = 'shared test'; $test2->Path = '/path/to/shared/test'; $test2->Command = 'php test_sharedtest.php'; $test2->Output = 'test shared successfully'; $measurement2 = new TestMeasurement(); $measurement2->Name = 'Exit Value'; $measurement2->Type = 'text/string'; $measurement2->Value = 0; $test2->AddMeasurement($measurement2); $image2 = new Image(); $image2->Extension = 'image/gif'; $image2->Name = 'smile.gif'; $image2->Data = base64_encode(file_get_contents(dirname(__FILE__) . '/data/smile.gif')); $test2->AddImage($image2); $test2->Insert(); $buildtest2 = new BuildTest(); $buildtest2->BuildId = $build->Id; $buildtest2->TestId = $test2->Id; $buildtest2->Status = 'passed'; $buildtest2->Insert(); $buildtest2->BuildId = $existing_build->Id; $buildtest2->Insert(); $test2->AddLabel($label); $test2->InsertLabelAssociations($build->Id); // UploadFile $filename = dirname(__FILE__) . '/data/smile.gif'; $upload1 = new UploadFile(); $upload1->Filename = $filename; $upload1->IsUrl = false; $upload1->BuildId = $build->Id; $upload1->Sha1Sum = sha1_file($filename); $upload1->Filesize = filesize($filename); $upload1->Insert(); $filename = dirname(__FILE__) . '/data/smile2.gif'; $upload2 = new UploadFile(); $upload2->Filename = $filename; $upload2->IsUrl = false; $upload2->BuildId = $build->Id; $upload2->Sha1Sum = sha1_file($filename); $upload2->Filesize = filesize($filename); $upload2->Insert(); $upload2->BuildId = $existing_build->Id; $upload2->Insert(); // Various tables that are too hard to spoof with models so we resort // to direct insertion. pdo_query("INSERT INTO buildemail (userid, buildid, category)\n VALUES (1, {$build->Id}, 0)"); pdo_query("INSERT INTO builderrordiff\n (buildid, type, difference_positive, difference_negative)\n VALUES ({$build->Id}, 0, 1, 1)"); pdo_query("INSERT INTO configureerrordiff (buildid, type, difference)\n VALUES ({$build->Id}, 0, 1)"); pdo_query("INSERT INTO coveragesummarydiff (buildid, loctested, locuntested)\n VALUES ({$build->Id}, 1, 1)"); pdo_query("INSERT INTO summaryemail (buildid, date, groupid)\n VALUES ({$build->Id}, '{$time}', 1)"); pdo_query("INSERT INTO subproject2build (subprojectid, buildid)\n VALUES (1, {$build->Id})"); pdo_query("INSERT INTO testdiff\n (buildid, type, difference_positive, difference_negative)\n VALUES ({$build->Id}, 0, 1, 1)"); // Check that everything was created successfully. $this->verify('build', 'id', '=', $build->Id, 1); $this->verify('build2group', 'buildid', '=', $build->Id, 1); $this->verify('buildemail', 'buildid', '=', $build->Id, 1); $this->verify('builderror', 'buildid', '=', $build->Id, 1); $this->verify('builderrordiff', 'buildid', '=', $build->Id, 1); $this->verify('buildinformation', 'buildid', '=', $build->Id, 1); $this->verify('buildtesttime', 'buildid', '=', $build->Id, 1); $this->verify('configure', 'buildid', '=', $build->Id, 1); $this->verify('configureerror', 'buildid', '=', $build->Id, 1); $this->verify('configureerrordiff', 'buildid', '=', $build->Id, 1); $this->verify('coveragesummary', 'buildid', '=', $build->Id, 1); $this->verify('coveragesummarydiff', 'buildid', '=', $build->Id, 1); $this->verify('coveragefilelog', 'buildid', '=', $build->Id, 2); $this->verify('dynamicanalysissummary', 'buildid', '=', $build->Id, 1); $this->verify('summaryemail', 'buildid', '=', $build->Id, 1); $this->verify('subproject2build', 'buildid', '=', $build->Id, 1); $this->verify('testdiff', 'buildid', '=', $build->Id, 1); list($buildfailureid, $detailsid) = $this->verify_get_columns('buildfailure', ['id', 'detailsid'], 'buildid', '=', $build->Id, 1); $this->verify('buildfailure2argument', 'buildfailureid', '=', $buildfailureid, 1); $this->verify('buildfailuredetails', 'id', '=', $detailsid, 1); $noteids = $this->verify_get_rows('build2note', 'noteid', 'buildid', '=', $build->Id, 2); $this->verify('note', 'id', 'IN', $noteids, 2); $coveragefileids = $this->verify_get_rows('coverage', 'fileid', 'buildid', '=', $build->Id, 2); $this->verify('coveragefile', 'id', 'IN', $coveragefileids, 2); $dynamicanalysisid = $this->verify_get_rows('dynamicanalysis', 'id', 'buildid', '=', $build->Id, 1); $this->verify('dynamicanalysisdefect', 'dynamicanalysisid', '=', $dynamicanalysisid, 1); $testids = $this->verify_get_rows('build2test', 'testid', 'buildid', '=', $build->Id, 2); $this->verify('test', 'id', 'IN', $testids, 2); $this->verify('testmeasurement', 'testid', 'IN', $testids, 2); $imgids = $this->verify_get_rows('test2image', 'imgid', 'testid', 'IN', $testids, 2); $this->verify('image', 'id', 'IN', $imgids, 2); $updateid = $this->verify_get_rows('build2update', 'updateid', 'buildid', '=', $build->Id, 1); $this->verify('buildupdate', 'id', '=', $updateid, 1); $this->verify('updatefile', 'updateid', '=', $updateid, 1); $uploadfileids = $this->verify_get_rows('build2uploadfile', 'fileid', 'buildid', '=', $build->Id, 2); $this->verify('uploadfile', 'id', 'IN', $uploadfileids, 2); $labelid = $this->verify_get_rows('label2build', 'labelid', 'buildid', '=', $build->Id, 1); $this->verify('label', 'id', '=', $labelid, 1); $this->verify('label2buildfailure', 'labelid', '=', $labelid, 2); $this->verify('label2coveragefile', 'labelid', '=', $labelid, 3); $this->verify('label2dynamicanalysis', 'labelid', '=', $labelid, 1); $this->verify('label2test', 'labelid', '=', $labelid, 2); // Remove the build. remove_build($build->Id); // Check that everything was deleted properly. $this->verify('build', 'id', '=', $build->Id, 0, true); $this->verify('build2group', 'buildid', '=', $build->Id, 0, true); $this->verify('build2note', 'buildid', '=', $build->Id, 0, true); $this->verify('build2test', 'buildid', '=', $build->Id, 0, true); $this->verify('build2update', 'buildid', '=', $build->Id, 0, true); $this->verify('build2uploadfile', 'buildid', '=', $build->Id, 0, true); $this->verify('buildemail', 'buildid', '=', $build->Id, 0, true); $this->verify('builderror', 'buildid', '=', $build->Id, 0, true); $this->verify('builderrordiff', 'buildid', '=', $build->Id, 0, true); $this->verify('buildfailure', 'buildid', '=', $build->Id, 0, true); $this->verify('buildfailure2argument', 'buildfailureid', '=', $buildfailureid, 0, true); $this->verify('buildfailuredetails', 'id', '=', $detailsid, 1, true); $this->verify('buildinformation', 'buildid', '=', $build->Id, 0, true); $this->verify('buildtesttime', 'buildid', '=', $build->Id, 0, true); $this->verify('buildupdate', 'id', '=', $updateid, 1, true); $this->verify('configure', 'buildid', '=', $build->Id, 0, true); $this->verify('configureerror', 'buildid', '=', $build->Id, 0, true); $this->verify('configureerrordiff', 'buildid', '=', $build->Id, 0, true); $this->verify('coverage', 'buildid', '=', $build->Id, 0, true); $this->verify('coveragefile', 'id', 'IN', $coveragefileids, 1, true); $this->verify('coveragefilelog', 'buildid', '=', $build->Id, 0, true); $this->verify('coveragesummary', 'buildid', '=', $build->Id, 0, true); $this->verify('coveragesummarydiff', 'buildid', '=', $build->Id, 0, true); $this->verify('dynamicanalysis', 'buildid', '=', $build->Id, 0, true); $this->verify('dynamicanalysissummary', 'buildid', '=', $build->Id, 0, true); $this->verify('dynamicanalysisdefect', 'dynamicanalysisid', '=', $dynamicanalysisid, 0, true); $this->verify('image', 'id', 'IN', $imgids, 1, true); $this->verify('label2build', 'buildid', '=', $build->Id, 0, true); $this->verify('label2buildfailure', 'labelid', '=', $labelid, 1, true); $this->verify('label2coveragefile', 'labelid', '=', $labelid, 1, true); $this->verify('label2dynamicanalysis', 'labelid', '=', $labelid, 0, true); $this->verify('label2test', 'labelid', '=', $labelid, 0, true); $this->verify('note', 'id', 'IN', $noteids, 1, true); $this->verify('summaryemail', 'buildid', '=', $build->Id, 0, true); $this->verify('subproject2build', 'buildid', '=', $build->Id, 0, true); $this->verify('test', 'id', 'IN', $testids, 1, true); $this->verify('test2image', 'testid', 'IN', $testids, 1, true); $this->verify('testdiff', 'buildid', '=', $build->Id, 0, true); $this->verify('testmeasurement', 'testid', 'IN', $testids, 1, true); $this->verify('updatefile', 'updateid', '=', $updateid, 1, true); $this->verify('uploadfile', 'id', 'IN', $uploadfileids, 1, true); }
function create_aggregate_build($build, $siteid = null) { require_once 'include/ctestparserutils.php'; if (is_null($siteid)) { $siteid = get_server_siteid(); } $aggregate_build = new Build(); $aggregate_build->Name = 'Aggregate Coverage'; $aggregate_build->SiteId = $siteid; $date = substr($build->GetStamp(), 0, strpos($build->GetStamp(), '-')); $aggregate_build->SetStamp($date . "-0000-Nightly"); $aggregate_build->ProjectId = $build->ProjectId; $aggregate_build->StartTime = $build->StartTime; $aggregate_build->EndTime = $build->EndTime; $aggregate_build->SubmitTime = gmdate(FMT_DATETIME); $aggregate_build->SetSubProject($build->GetSubProjectName()); $aggregate_build->InsertErrors = false; add_build($aggregate_build); return $aggregate_build; }