コード例 #1
0
ファイル: test_thread_fork.py プロジェクト: zeta1999/nagini
def client_fork(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == Cell.incr)
    Requires(Acc(cell.val))
    Requires(cell is getArg(t, 0))
    Ensures(getOld(t, arg(0).val) == 12)
    Ensures(WaitLevel() < Level(t))
    #:: ExpectedOutput(postcondition.violated:insufficient.permission)
    Ensures(Acc(MayStart(t)))
    cell.val = 12
    t.start(decr, Cell.incr)
コード例 #2
0
ファイル: test_thread_1.py プロジェクト: zeta1999/nagini
def client_fork(t: Thread, l: BaseLock) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == noop)
    Requires(l is getArg(t, 0))
    Ensures(WaitLevel() < Level(t))
    #:: ExpectedOutput(invalid.program:invalid.thread.start)
    t.start(noop)
コード例 #3
0
ファイル: test_thread_fork.py プロジェクト: zeta1999/nagini
def client_fork_wrong_mayjoin(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == Cell.incr)
    Requires(Acc(cell.val))
    Requires(cell is getArg(t, 0))
    #:: ExpectedOutput(postcondition.violated:assertion.false)
    Ensures(Joinable(t))
    t.start(decr, Cell.incr)
コード例 #4
0
ファイル: test_thread_fork.py プロジェクト: zeta1999/nagini
def client_fork_wrong_thread_post(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == Cell.incr)
    Requires(Acc(cell.val))
    Requires(cell is getArg(t, 0))
    #:: ExpectedOutput(postcondition.violated:insufficient.permission)
    Ensures(Acc(ThreadPost(t)))
    t.start(decr, Cell.incr)
コード例 #5
0
ファイル: test_thread_fork.py プロジェクト: zeta1999/nagini
def client_fork_wrong_old_2(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == Cell.incr)
    Requires(Acc(cell.val))
    Requires(cell is getArg(t, 0))
    #:: ExpectedOutput(postcondition.violated:assertion.false)
    Ensures(getOld(t, arg(0).val) == 14)
    cell.val = 12
    t.start(decr, Cell.incr)
コード例 #6
0
def client_create(b: bool) -> Thread:
    Ensures(MayStart(Result()))
    Ensures(Implies(b, getArg(Result(), 1) is 3))
    Ensures(Implies(not b, getArg(Result(), 1) is 6))
    Ensures(Implies(not b, getMethod(Result()) == decr))
    #:: ExpectedOutput(postcondition.violated:assertion.false)
    Ensures(getArg(Result(), 2) is None)
    cl = Cell()
    if b:
        t = Thread(None, target=cl.incr, args=(3, ))
    else:
        t = Thread(target=decr, group=None, args=(cl, 6))
    return t
コード例 #7
0
ファイル: test_thread_fork.py プロジェクト: zeta1999/nagini
def client_fork_precond_not_fulfilled(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == Cell.incr)
    Requires(cell is getArg(t, 0))
    #:: ExpectedOutput(thread.start.failed:insufficient.permission)
    t.start(decr, Cell.incr)
コード例 #8
0
ファイル: test_thread_fork.py プロジェクト: zeta1999/nagini
def client_fork_method_unknown(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(Acc(cell.val))
    Requires(cell is getArg(t, 0))
    #:: ExpectedOutput(thread.start.failed:method.not.listed)
    t.start(decr, Cell.incr)