Ticket #7815: 0001-Test-for-7815.patch

File 0001-Test-for-7815.patch, 2.1 KB (added by fryguybob, 13 months ago)
  • new file tests/rts/T7815.hs

    From 9271c58cb825be888ac20c40c2671328b3ce73e2 Mon Sep 17 00:00:00 2001
    From: Ryan Yates <ryates@cs.rochester.edu>
    Date: Mon, 8 Apr 2013 21:45:22 -0400
    Subject: [PATCH] Test for #7815
    
    This test differes slightly from the code in the ticket, but the
    simplification betters the chances of seeing the error.  Instead of
    looking for the error with an additional tranaction, when error appears
    only one `reset` can complete and the other is blocked on STM raising an
    exception.
    ---
     tests/rts/T7815.hs | 29 +++++++++++++++++++++++++++++
     tests/rts/all.T    |  5 +++++
     2 files changed, 34 insertions(+)
     create mode 100644 tests/rts/T7815.hs
    
    diff --git a/tests/rts/T7815.hs b/tests/rts/T7815.hs
    new file mode 100644
    index 0000000..2710da1
    - +  
     1import GHC.Conc.Sync 
     2import Control.Monad 
     3import System.Environment 
     4 
     5test n = do 
     6  dog <- newTVarIO False 
     7  cat <- newTVarIO False 
     8  let unset = do 
     9        d <- readTVar dog 
     10        c <- readTVar cat 
     11        if (d || c) then retry else return () 
     12      setDog = unset >> writeTVar dog True 
     13      setCat = unset >> writeTVar cat True 
     14      reset = do 
     15        d <- readTVar dog 
     16        c <- readTVar cat 
     17        guard (d || c) 
     18        writeTVar dog False 
     19        writeTVar cat False 
     20   
     21  replicateM_ n (do 
     22    forkIO (atomically setDog) 
     23    forkIO (atomically setCat) 
     24    atomically reset 
     25    atomically reset) 
     26 
     27main = do 
     28  [n] <- getArgs 
     29  test (read n :: Int) 
  • tests/rts/all.T

    diff --git a/tests/rts/all.T b/tests/rts/all.T
    index 3a73054..f345b3b 100644
    a b test('T7636', [ exit_code(1), extra_run_opts('100000') ], compile_and_run, [''] 
    165165test('stablename001', expect_fail_for(['hpc']), compile_and_run, ['']) 
    166166# hpc should fail this, because it tags every variable occurrence with 
    167167# a different tick.  It's probably a bug if it works, hence expect_fail. 
     168 
     169# Run this test alone (via, high_memory_usage) to increase chances of seeing the race. 
     170test('T7815', [ high_memory_usage, 
     171                extra_run_opts('50000 +RTS -N2 -RTS'), 
     172                only_ways(['threaded1', 'threaded2']) ], compile_and_run, [''] )