def thread_join_not_joinable(t: Thread, cl: Cell) -> None: Requires(getMethod(t) == decr) Requires(getArg(t, 0) is cl) Requires(getArg(t, 1) is 7) Requires(getOld(t, arg(0).val) is 123) Requires(WaitLevel() < Level(t)) #:: ExpectedOutput(thread.join.failed:thread.not.joinable) t.join(Cell.incr, decr)
def thread_join_wrong_level(t: Thread, cl: Cell) -> None: Requires(getMethod(t) == decr) Requires(getArg(t, 0) is cl) Requires(getArg(t, 1) is 7) Requires(getOld(t, arg(0).val) is 123) Requires(Acc(ThreadPost(t))) #:: ExpectedOutput(thread.join.failed:wait.level.invalid) t.join(Cell.incr, decr)
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)
def thread_join_wrong_method(t: Thread, cl: Cell) -> None: Requires(getMethod(t) == Cell.incr) Requires(getArg(t, 0) is cl) Requires(getArg(t, 1) is 7) Requires(getOld(t, arg(0).val) is 123) Requires(Acc(ThreadPost(t))) Requires(WaitLevel() < Level(t)) t.join(decr) #:: ExpectedOutput(assert.failed:insufficient.permission) assert cl.val == 116
def thread_join_no_post_perm(t: Thread, cl: Cell) -> None: Requires(getMethod(t) == decr) Requires(getArg(t, 0) is cl) Requires(getArg(t, 1) is 7) Requires(getOld(t, arg(0).val) is 123) Requires(Joinable(t)) Requires(WaitLevel() < Level(t)) t.join(Cell.incr, decr) #:: ExpectedOutput(assert.failed:insufficient.permission) assert cl.val == 116
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)
def thread_join_part_perm(t: Thread, cl: Cell) -> None: Requires(getMethod(t) == decr) Requires(getArg(t, 0) is cl) Requires(getArg(t, 1) is 7) Requires(getOld(t, arg(0).val) is 123) Requires(Acc(ThreadPost(t), 1 / 2)) Requires(WaitLevel() < Level(t)) t.join(Cell.incr, decr) assert cl.val == 116 #:: ExpectedOutput(assignment.failed:insufficient.permission) cl.val = 11
def thread_join_pred_partial(t: Thread, cl: Cell) -> None: Requires(getMethod(t) == decr_pred) Requires(getArg(t, 0) is cl) Requires(getArg(t, 1) is 7) Requires(getOld(t, arg(0).val) is 123) Requires(Acc(ThreadPost(t), 1 / 2)) Requires(WaitLevel() < Level(t)) Ensures(Joinable(t)) t.join(decr, decr_pred) Unfold(Acc(cell_pred(cl, 116), 1 / 2)) assert cl.val == 116 #:: ExpectedOutput(unfold.failed:insufficient.permission) Unfold(Acc(cell_pred(cl, 116), 1 / 2))
def thread_join_pred(t: Thread, cl: Cell) -> None: Requires(getMethod(t) == decr_pred) Requires(getArg(t, 0) is cl) Requires(getArg(t, 1) is 7) Requires(getOld(t, arg(0).val) is 123) Requires(Acc(ThreadPost(t))) Requires(WaitLevel() < Level(t)) Ensures(Joinable(t)) #:: ExpectedOutput(postcondition.violated:assertion.false) Ensures(False) t.join(decr, decr_pred) Unfold(cell_pred(cl, 116)) assert cl.val == 116
def test(o: object) -> None: #:: ExpectedOutput(invalid.program:invalid.arg.use) Requires(arg(1) == o) pass