Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/stderr #631

Merged
merged 4 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CTAWAVE/impl/checkCMFHDBaselineConstraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"CMFHD profile",
count(array_unique($presentationProfileArray)) === 1 && array_unique($presentationProfileArray)[0] == "CMFHD",
"FAIL",
"All CMAF Swithcing sets are CMFHD conformant",
"Not all CMAF Swithcing sets are CMFHD conformant"
"All CMAF Switching sets are CMFHD conformant",
"Not all CMAF Switching sets are CMFHD conformant"
);
2 changes: 0 additions & 2 deletions DASH/processMPD.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ function processAdaptationSetOfCurrentPeriod()
}
}


$logger->setModule("HEALTH");
validate_segment(
$adaptationDirectory,
$representationDirectory,
Expand Down
8 changes: 8 additions & 0 deletions Utils/moduleLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ public function setModule($moduleName)
$this->currentHook = '';
}

public function getCurrentModule() {
return $this->currentModule;
}

public function getCurrentHook() {
return $this->currentHook;
}

public function getModuleVerdict($moduleName)
{
if (!array_key_exists($moduleName, $this->entries)) {
Expand Down
71 changes: 69 additions & 2 deletions Utils/segment_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ function validate_segment(
$file_location[] = 'notexist';
}

// Save content of stderr
saveStdErrOutput($representationDirectory);

return $file_location;
}

Expand Down Expand Up @@ -158,12 +161,13 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)

$adaptation_set = $mpdHandler->getFeatures()['Period'][$selectedPeriod]['AdaptationSet'][$selectedAdaptation];
$representation = $adaptation_set['Representation'][$selectedRepresentation];
$stdErrPath = $session->getDir()."/stderr.txt";
if (!$hls_manifest) {
$logger->test(
"Segment Validations",
"analyze_results()",
"stderr filled??",
filesize("$representationDirectory/stderr.txt") !== 0,
filesize($stdErrPath) !== 0 && filesize($stdErrPath) !== false,
"FAIL",
"Contents in stderr.txt found",
"Failed to process adaptationset $selectedAdaptation, " .
Expand All @@ -174,7 +178,7 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)
"Segment Validations",
"analyze_results()",
"stderr filled??",
filesize("$representationDirectory/stderr.txt") !== 0,
filesize($stdErrPath) !== 0 && filesize($stdErrPath) !== false,
"FAIL",
"Contents in stderr.txt found",
"Failed to process HLS $tag_array[0] index $tag_array[1]"
Expand Down Expand Up @@ -208,6 +212,10 @@ function analyze_results($returncode, $curr_adapt_dir, $representationDirectory)

rename($session->getDir() . "/leafinfo.txt", "$representationDirectory/leafInfo.txt");

if (file_exists($stdErrPath)) {
rename($stdErrPath, "$representationDirectory/stderr.txt");
}

if (!$hls_manifest) {
## Check segment duration and start times against MPD times.
loadAndCheckSegmentDuration();
Expand Down Expand Up @@ -245,6 +253,10 @@ function run_backend($configFile, $representationDirectory = "")

$moveAtom = true;

$currentModule = $logger->getCurrentModule();
$currentHook = $logger->getCurrentHook();

$logger->setModule("HEALTH");
$moveAtom &= $logger->test(
"Health Checks",
"Segment Validation",
Expand Down Expand Up @@ -317,6 +329,10 @@ function run_backend($configFile, $representationDirectory = "")
}
}

// Restore module information since health checks are over
$logger->setModule($currentModule);
$logger->setHook($currentHook);

return $returncode;
}

Expand Down Expand Up @@ -515,3 +531,54 @@ function checkSegmentDurationWithMPD($segmentsTime, $PTO, $duration, $representa
);
}
}

function saveStdErrOutput($representationDirectory) {
global $logger;

$currentModule = $logger->getCurrentModule();
$currentHook = $logger->getCurrentHook();
$logger->setModule("SEGMENT_VALIDATION");

$content = file_get_contents("$representationDirectory/stderr.txt");
$contentArray = explode("\n", $content);

if (!$contentArray->length ){
$logger->test(
"Segment Validation",
"Segment Validation",
"std error output",
true,
"PASS",
"Segment validation did not produce any output",
$content
);
} else {
foreach ($contentArray as $i => $msg){
$severity = "PASS";
//Catch both warn and warning
if (stripos($msg, "warn") !== FALSE){
$severity = "WARN";
}
//Catch errors
if (stripos($msg, "error") !== FALSE){
$severity = "FAIL";
}

$logger->test(
"Segment Validation",
"Segment Validation",
"std error output",
$severity == "PASS",
$severity,
$msg,
$msg
);

}
}


// Restore module information since health checks are over
$logger->setModule($currentModule);
$logger->setHook($currentHook);
}