Commit 3793bbd7 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

fix summary printout

parent 7b1d3895
Loading
Loading
Loading
Loading
Loading
+29 −30
Original line number Diff line number Diff line
@@ -1050,13 +1050,20 @@ class MLDConformance:
        if self.args.be_test:
            self.doBEanalysis(selectTag=tag)
            analysis_ok = True
            corridor_fail_count = 0
            max_mld_value = None
        else:
            analysis_ok = self.doAnalysis(selectTag=tag, corridor=True)
            analysis_ok, corridor_fail_count, max_mld_value = self.doAnalysis(
                selectTag=tag, corridor=True
            )

        failed_after = self.getFailedCommandCount()
        failed_delta = failed_after - failed_before
        max_mld_text = (
            f", MAX_MLD={max_mld_value}" if max_mld_value is not None else ""
        )
        if failed_delta == 0 and non_be_count == 0 and analysis_ok:
            print(f"[{tag}] OK")
            print(f"[{tag}] OK{max_mld_text}")
            return True

        reasons = []
@@ -1064,10 +1071,16 @@ class MLDConformance:
            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")
        if corridor_fail_count > 0:
            reasons.append(f"MLD corridor failed in {corridor_fail_count} cases")
        reason_text = ", ".join(reasons) if reasons else "analysis mismatch"
        print(f"[{tag}] FAILED ({reason_text}). See {self.failedCmdsFile}")
        tag_text = f"\033[97m[{tag}]\033[00m"
        fail_text = f"\033[91mFAILED ({reason_text})\033[00m"
        if failed_delta > 0:
            print(f"{tag_text} {fail_text}{max_mld_text}. See {self.failedCmdsFile}")
        else:
            print(f"{tag_text} {fail_text}{max_mld_text}")
        print()
        return False

    def process(
@@ -1318,19 +1331,6 @@ class MLDConformance:
            corridor_failed = True

        if corridor_failed:
            mismatch_reason = []
            if not same_shape:
                mismatch_reason.append(
                    f"shape mismatch REF={refMLD.shape}, DUT={dutMLD.shape}"
                )
            if same_shape and not same_tags:
                mismatch_reason.append("pyTestTag mismatch")
            mismatch_suffix = (
                f" ({'; '.join(mismatch_reason)})" if mismatch_reason else ""
            )
            print(
                f"\033[91mMLD Corridor failed for {tag} with max MLD diff of {maxDiff}{mismatch_suffix} \033[00m"
            )
            new_mld_dir = os.path.join(
                self.testvDir, "mld_ref2"
            )
@@ -1342,14 +1342,12 @@ class MLDConformance:
            )
            with open(refMldFile2, "w") as f:
                np.savetxt(f, mldWithTags, fmt="%s", delimiter=",")
        else:
            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
        corridor_fail_count = 0
        max_mld_value = None
        keys = IVAS_Bins.keys() if selectTag == "all" else [selectTag]
        for tag in keys:
            if os.path.exists(self.mldcsv[tag]):
@@ -1378,6 +1376,11 @@ class MLDConformance:
                N = mdlValues.shape[0]
                if N == 0:
                    continue
                tag_max_mld = float(mdlValues.max())
                if max_mld_value is None:
                    max_mld_value = tag_max_mld
                else:
                    max_mld_value = max(max_mld_value, tag_max_mld)
                m0 = np.sum(mdlValues == 0)
                m05 = np.sum(mdlValues <= 0.5)
                m1 = np.sum(mdlValues <= 1.0)
@@ -1413,13 +1416,15 @@ class MLDConformance:
                            mldRefWithTags, mdlCutWithTags, tag
                        )
                        all_ok = all_ok and corridor_ok
                        corridor_fail_count += int(not corridor_ok)
                    else:
                        print(
                            f"\033[91mMissing reference MLD file for {tag} : {refMldFile} \033[00m"
                        )
                        all_ok = False
                        corridor_fail_count += 1

        return all_ok
        return all_ok, corridor_fail_count, max_mld_value


if __name__ == "__main__":
@@ -1548,25 +1553,19 @@ if __name__ == "__main__":
        sys.exit(0)

    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:
            tag_ok = conformance.doAnalysis(selectTag=tag, corridor=True)
            tag_ok, _, _ = conformance.doAnalysis(selectTag=tag, corridor=True)
        elif not args.analyse:
            tag_ok = conformance.runTag(tag)
        else:
            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")
    else:
        print("Overall result: FAILED")