Commit 61c1f542 authored by Simon Marlow's avatar Simon Marlow
Browse files

test repeated open/close of 1000 files

parent 827f8cea
......@@ -69,6 +69,8 @@ clean(['openFile006.out'])
test('openFile007', compose(expect_fail_if_compiler_type('hugs'),
expect_fail_if_windows), compile_and_run, [''])
clean(['openFile007.out'])
test('openFile008', normal, compile_and_run, [''])
test('putStr001', normal, compile_and_run, [''])
test('readFile001', compose(expect_fail_if_compiler_type('hugs'),
expect_fail_if_windows), compile_and_run, [''])
......
import System.IO
import System.Cmd
import System.FilePath
import Text.Printf
import System.Directory
import Control.Monad
testdir = "openFile008_testdir"
-- Test repeated opening/closing of 1000 files. This is useful for guaging
-- the performance of open/close and file locking.
main = do
system ("rm -rf " ++ testdir)
createDirectory testdir
let filenames = [testdir </> printf "file%03d" (n::Int) | n <- [1..1000]]
forM_ [1..50] $ \_ -> do
hs <- mapM (\f -> openFile f WriteMode) filenames
mapM_ hClose hs
mapM_ removeFile filenames
removeDirectory testdir
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment