1. Pypy
  2. Untitled project
  3. stmgc

Commits

Armin Rigo  committed a8273b9

Add a passing test for stm_clear_on_abort()

  • Participants
  • Parent commits 24b6be3
  • Branches default

Comments (0)

Files changed (2)

File c4/test/support.py

View file
     void stm_initialize_and_set_max_abort(int max_aborts);
     void stm_initialize_tests(int max_aborts);
 
+    void stm_clear_on_abort(void *start, size_t bytes);
+
     /* some constants normally private that are useful in the tests */
     #define WORD                     ...
     #define GC_PAGE_SIZE             ...

File c4/test/test_extra.py

View file
     
     check_free_old(p3o)
     check_free_old(p2)
-    
-    
+
+def test_clear_on_abort():
+    p = ffi.new("char[]", "hello")
+    lib.stm_clear_on_abort(p, 2)
+    #
+    @perform_transaction
+    def run(retry_counter):
+        if retry_counter == 0:
+            assert ffi.string(p) == "hello"
+            abort_and_retry()
+        else:
+            assert p[0] == '\0'
+            assert p[1] == '\0'
+            assert p[2] == 'l'
+            assert p[3] == 'l'
+            assert p[4] == 'o'