Commit 7b1d3895 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

fix final summary printout

parent f732563f
Loading
Loading
Loading
Loading
Loading
+46 −9
Original line number Diff line number Diff line
@@ -932,6 +932,7 @@ class MLDConformance:

    def analyseTag(self, tag: str) -> bool:
        failed_before = self.getFailedCommandCount()
        non_be_count = 0
        # reset MLD, Sample Stats
        if self.args.be_test:
            with open(self.BEcsv[tag], "w") as f:
@@ -967,6 +968,12 @@ class MLDConformance:
                    errorDetails,
                    executedCommand,
                ) in pool.imap_unordered(self.analyseOneCommandFromTuple, args):
                    if (
                        runStatus == "OK"
                        and analysisResult
                        and str(analysisResult).startswith("NON-BE")
                    ):
                        non_be_count += 1
                    if self.args.verbose:
                        if runStatus == "OK":
                            if not analysisResult:
@@ -1004,6 +1011,12 @@ class MLDConformance:
                    errorDetails,
                    executedCommand,
                ) = self.analyseOneCommand(tag, pyTestsTag, idx, self.totalTests)
                if (
                    runStatus == "OK"
                    and analysisResult
                    and str(analysisResult).startswith("NON-BE")
                ):
                    non_be_count += 1
                if self.args.verbose:
                    if runStatus == "OK":
                        if not analysisResult:
@@ -1036,18 +1049,25 @@ class MLDConformance:

        if self.args.be_test:
            self.doBEanalysis(selectTag=tag)
            analysis_ok = True
        else:
            self.doAnalysis(selectTag=tag, corridor=True)
            analysis_ok = self.doAnalysis(selectTag=tag, corridor=True)

        failed_after = self.getFailedCommandCount()
        failed_delta = failed_after - failed_before
        if failed_delta == 0:
        if failed_delta == 0 and non_be_count == 0 and analysis_ok:
            print(f"[{tag}] OK")
            return True

        print(
            f"[{tag}] FAILED ({failed_delta} command(s) failed). See {self.failedCmdsFile}"
        )
        reasons = []
        if failed_delta > 0:
            reasons.append(f"{failed_delta} command(s) failed")
        if non_be_count > 0:
            reasons.append(f"{non_be_count} NON-BE result(s)")
        if not analysis_ok:
            reasons.append("corridor/report analysis failed")
        reason_text = ", ".join(reasons) if reasons else "analysis mismatch"
        print(f"[{tag}] FAILED ({reason_text}). See {self.failedCmdsFile}")
        return False

    def process(
@@ -1326,8 +1346,10 @@ class MLDConformance:
            print(
                f"\033[92mMLD Corridor passed for {tag} with max MLD diff of {maxDiff} \033[00m"
            )
        return not corridor_failed

    def doAnalysis(self, selectTag="all", corridor=False):
        all_ok = True
        keys = IVAS_Bins.keys() if selectTag == "all" else [selectTag]
        for tag in keys:
            if os.path.exists(self.mldcsv[tag]):
@@ -1387,11 +1409,17 @@ class MLDConformance:
                            delimiter=",",
                            dtype=[("MLD", "f8"), ("pyTestTag", "<U256")],
                        )
                        self.computeCorridor(mldRefWithTags, mdlCutWithTags, tag)
                        corridor_ok = self.computeCorridor(
                            mldRefWithTags, mdlCutWithTags, tag
                        )
                        all_ok = all_ok and corridor_ok
                    else:
                        print(
                            f"\033[91mMissing reference MLD file for {tag} : {refMldFile} \033[00m"
                        )
                        all_ok = False

        return all_ok


if __name__ == "__main__":
@@ -1521,13 +1549,22 @@ if __name__ == "__main__":

    testTags = IVAS_Bins.keys() if args.test_mode == "ALL" else [args.test_mode]
    overall_success = True
    tag_results = {}
    for tag in testTags:
        if args.report_only:
            conformance.doAnalysis(selectTag=tag, corridor=True)
            tag_ok = conformance.doAnalysis(selectTag=tag, corridor=True)
        elif not args.analyse:
            overall_success = conformance.runTag(tag) and overall_success
            tag_ok = conformance.runTag(tag)
        else:
            overall_success = conformance.analyseTag(tag) and overall_success
            tag_ok = conformance.analyseTag(tag)

        tag_results[tag] = tag_ok
        overall_success = tag_ok and overall_success

    print("Summary of results:")
    for tag in testTags:
        tag_status = "OK" if tag_results.get(tag, False) else "FAILED"
        print(f"[{tag}] {tag_status}")

    if overall_success:
        print("Overall result: OK")