Beispiel #1
0
def RunTests():
    failed = 0
    passed = 0
    knownBugs = 0
    failures = []

    for name, method in MatchingNamesAndMethods():
        status = RunTest(name, method)
        if status is None:
            knownBugs += 1
        elif status:
            passed += 1
        else:
            failures.append(name)
            failed += 1
            if escargs.args.stop_on_failure:
                break

    if failed > 0:
        esclog.LogInfo("*** %s passed, %s, %s FAILED ***" %
                       (plural("test", passed), plural("known bug", knownBugs),
                        plural("TEST", failed, caps=True)))
        esclog.LogInfo("Failing tests:\n" + "\n".join(failures))
    else:
        esclog.LogInfo("*** %s passed, %s, %s failed ***" %
                       (plural("test", passed), plural(
                           "known bug", knownBugs), plural("test", failed)))
Beispiel #2
0
def RunTest(name, method):
    ok = True
    esclog.LogInfo("Run test: " + name)
    try:
        reset()
        AttachSideChannel(name)
        method()
        RemoveSideChannel()
        escutil.AssertAssertionAsserted()
        esclog.LogInfo("Passed.")
    except esctypes.KnownBug, e:
        RemoveSideChannel()
        esclog.LogInfo("Fails as expected: " + str(e))
        ok = None
Beispiel #3
0
def ListKnownBugs():
    for name, method in MatchingNamesAndMethods():
        reason = CheckForKnownBug(name, method)
        if reason is not None:
            esclog.LogInfo("%s: %s" % (name, reason))
Beispiel #4
0
    ok = True
    esclog.LogInfo("Run test: " + name)
    try:
        reset()
        AttachSideChannel(name)
        method()
        RemoveSideChannel()
        escutil.AssertAssertionAsserted()
        esclog.LogInfo("Passed.")
    except esctypes.KnownBug, e:
        RemoveSideChannel()
        esclog.LogInfo("Fails as expected: " + str(e))
        ok = None
    except esctypes.InsufficientVTLevel, e:
        RemoveSideChannel()
        esclog.LogInfo(
            "Skipped because terminal lacks requisite capability: " + str(e))
        ok = None
    except Exception, e:
        RemoveSideChannel()
        tb = traceback.format_exc()
        ok = False
        esclog.LogError("*** TEST %s FAILED:" % name)
        esclog.LogError(tb)
    esclog.LogInfo("")
    return ok


def MatchingNamesAndMethods():
    classes = []
    for category in [tests.tests]:
        classes.extend(category)