Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r235:68143e7ceb28 Date: 2013-06-22 15:28 +0200 http://bitbucket.org/pypy/stmgc/changeset/68143e7ceb28/
Log: Fix the test to avoid a thread-order-dependent failure. diff --git a/c4/test/support.py b/c4/test/support.py --- a/c4/test/support.py +++ b/c4/test/support.py @@ -58,6 +58,7 @@ void stm_set_transaction_length(long length_max); /* extra non-public code */ + void printfcolor(char *msg); void *stm_malloc(size_t size); gcptr stmgcpage_malloc(size_t size); void stmgcpage_free(gcptr obj); @@ -122,6 +123,11 @@ extern revision_t stm_global_cur_time(void); extern revision_t get_private_rev_num(void); + void printfcolor(char *msg) + { + fprintf(stderr, "%s\n", msg); + } + int gettid(gcptr obj) { int result = stm_get_tid(obj); @@ -329,6 +335,7 @@ raise exc, val, tb def run(self, fn, lck, i): + printf('run: calling %r' % (fn,)) try: try: lib.stm_initialize_and_set_max_abort(self.max_aborts) @@ -487,6 +494,8 @@ def minor_collect(): lib.stmgc_minor_collect() +printf = lib.printfcolor + def is_stub(p): return p.h_tid & GCFLAG_STUB @@ -541,6 +550,8 @@ def cb(_, retry_counter): del fine[:] try: + printf('perform_transaction: calling %r with retry_counter=%d' % + (callback, retry_counter)) loopback = callback(retry_counter) except Exception: if not sys.stdout.isatty(): diff --git a/c4/test/test_gcpage.py b/c4/test/test_gcpage.py --- a/c4/test/test_gcpage.py +++ b/c4/test/test_gcpage.py @@ -341,6 +341,9 @@ check_not_free(p1) assert classify(p1) == "private_from_protected" assert classify(follow_revision(p1)) == "public" # has been stolen + # leave time for f2 to finish, before we commit changes to p1 + # (which has got in its read set) + r.wait_while_in_parallel() perform_transaction(cb) def f2(r): def cb(c): @@ -353,7 +356,9 @@ r.leave_in_parallel() check_not_free(p2) assert classify(p2) == "public" + r.enter_in_parallel() perform_transaction(cb) + r.leave_in_parallel() run_parallel(f1, f2) def test_private_from_protected_inevitable(): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit