File size: 1,833 Bytes
201dc77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""U11-13: a ceiling run with no known-good evidence must not certify the verifier."""
import importlib.util
import os

import pytest

REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def _load():
    spec = importlib.util.spec_from_file_location(
        "lean_ceiling_under_test", os.path.join(REPO, "scripts", "lean_ceiling_test.py")
    )
    m = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(m)
    return m


ADV_PASS = {"n": 61, "accepted": 0, "pass": True}
KG_PASS = {"n": 100, "accepted": 100, "pass": True}


def test_adversarial_only_report_in_a_full_run_fails():
    # all-reject verifier: known-good stage skipped (no candidate survived the compile filter)
    m = _load()
    assert m.ceiling_ok({"adversarial": ADV_PASS}, only=None) is False


def test_both_sides_pass():
    m = _load()
    assert m.ceiling_ok({"known_good": KG_PASS, "adversarial": ADV_PASS}, only=None) is True


def test_either_side_failing_fails():
    m = _load()
    assert m.ceiling_ok({"known_good": {**KG_PASS, "pass": False}, "adversarial": ADV_PASS}, only=None) is False
    assert m.ceiling_ok({"known_good": KG_PASS, "adversarial": {**ADV_PASS, "pass": False}}, only=None) is False


def test_only_modes_require_their_own_side():
    m = _load()
    assert m.ceiling_ok({"adversarial": ADV_PASS}, only="adversarial") is True
    assert m.ceiling_ok({"known_good": KG_PASS}, only="good") is True
    assert m.ceiling_ok({}, only="good") is False
    assert m.ceiling_ok({}, only="adversarial") is False


def test_empty_good_results_yield_a_failing_known_good_entry():
    m = _load()
    entry = m.empty_known_good_entry(candidates=180, excluded=180)
    assert entry["pass"] is False and entry["n"] == 0
    assert m.ceiling_ok({"known_good": entry, "adversarial": ADV_PASS}, only=None) is False