Author: Remi Meier <remi.me...@inf.ethz.ch> Branch: c8-private-pages Changeset: r1556:080ece9f6963 Date: 2015-01-20 11:11 +0100 http://bitbucket.org/pypy/stmgc/changeset/080ece9f6963/
Log: improve test_random diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -481,14 +481,6 @@ { if (!_stm_validate()) stm_abort_transaction(); - -#if STM_TESTS - if (STM_PSEGMENT->transaction_state != TS_INEVITABLE - && STM_PSEGMENT->last_commit_log_entry->next == INEV_RUNNING) { - /* abort for tests... */ - stm_abort_transaction(); - } -#endif } diff --git a/c8/test/test_gcpage.py b/c8/test/test_gcpage.py --- a/c8/test/test_gcpage.py +++ b/c8/test/test_gcpage.py @@ -300,7 +300,8 @@ self.start_transaction() self.become_inevitable() # - py.test.raises(Conflict, self.switch, 0) + self.switch(0) + py.test.raises(Conflict, self.commit_transaction) # self.switch(1) diff --git a/c8/test/test_random.py b/c8/test/test_random.py --- a/c8/test/test_random.py +++ b/c8/test/test_random.py @@ -349,7 +349,8 @@ def op_become_inevitable(ex, global_state, thread_state): trs = thread_state.transaction_state - global_state.check_if_can_become_inevitable(trs) + if not trs.check_must_abort(): + global_state.check_if_can_become_inevitable(trs) thread_state.push_roots(ex) ex.do(raising_call(trs.check_must_abort(), @@ -426,18 +427,13 @@ v = ord(global_state.rnd.choice("abcdefghijklmnop")) assert trs.write_root(r, v) is not None # - aborts = trs.check_must_abort() - if aborts: - thread_state.abort_transaction() offset = global_state.get_root_size(r) + " - 1" if is_ref: - ex.do(raising_call(aborts, "stm_set_ref", r, offset, v, try_cards)) - if not aborts: - ex.do(raising_call(False, "stm_set_ref", r, "0", v, try_cards)) + ex.do(raising_call(False, "stm_set_ref", r, offset, v, try_cards)) + ex.do(raising_call(False, "stm_set_ref", r, "0", v, try_cards)) else: - ex.do(raising_call(aborts, "stm_set_char", r, repr(chr(v)), offset, try_cards)) - if not aborts: - ex.do(raising_call(False, "stm_set_char", r, repr(chr(v)), "HDR", try_cards)) + ex.do(raising_call(False, "stm_set_char", r, repr(chr(v)), offset, try_cards)) + ex.do(raising_call(False, "stm_set_char", r, repr(chr(v)), "HDR", try_cards)) def op_read(ex, global_state, thread_state): r = thread_state.get_random_root() @@ -509,8 +505,6 @@ ex.do('#') # trs = new_thread_state.transaction_state - if trs and not trs.check_must_abort(): - global_state.check_if_can_become_inevitable(trs) conflicts = trs and trs.check_must_abort() ex.thread_num = new_thread_state.num # @@ -568,28 +562,28 @@ # random steps: possible_actions = [ - op_allocate, - op_allocate_ref, op_allocate_ref, - op_write, op_write, op_write, - op_read, op_read, op_read, op_read, op_read, op_read, op_read, op_read, - op_commit_transaction, - op_abort_transaction, - op_forget_root, - op_become_inevitable, - op_assert_size, - op_assert_modified, - op_minor_collect, - op_major_collect, + [op_read,]*100, + [op_write,]*70, + [op_allocate,]*25, + [op_allocate_ref]*30, + [op_commit_transaction,]*10, + [op_abort_transaction,], + [op_forget_root]*10, + [op_become_inevitable]*2, + [op_assert_size]*20, + [op_assert_modified]*10, + [op_minor_collect]*5, + [op_major_collect], ] + possible_actions = [item for sublist in possible_actions for item in sublist] + print possible_actions for _ in range(2000): # make sure we are in a transaction: curr_thread = op_switch_thread(ex, global_state, curr_thread) - if (global_state.is_inevitable_transaction_running() - and curr_thread.transaction_state is None): - continue # don't bother trying to start a transaction - if curr_thread.transaction_state is None: + if global_state.is_inevitable_transaction_running(): + continue # don't bother trying to start a transaction op_start_transaction(ex, global_state, curr_thread) assert curr_thread.transaction_state is not None _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit