diff options
author | MarcelineVQ <matthewnhyatt@gmail.com> | 2015-12-23 01:23:33 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-23 10:05:39 +0100 |
commit | 7ed0da6cde909e662d09e1f39c3fccfa10f91a7f (patch) | |
tree | 5afdda1d857199b41a520db124083991daa04ae6 /testsuite/tests | |
parent | ed213ead5e92aa3c2ae830a00f06684a1028d3ad (diff) | |
download | haskell-7ed0da6cde909e662d09e1f39c3fccfa10f91a7f.tar.gz |
Modify Nmax to maxN Trac #10728
Added test and changed -Nmax to -maxN, -n was taken
Noticed strange -m behavoir and fixed -m from quietly
ignoring being passed invalid opts, e.g. "-msasd"
Reviewers: simonmar, hvr, austin, thomie, bgamari
Reviewed By: hvr, thomie, bgamari
Subscribers: bgamari, hvr, thomie, simonmar
Differential Revision: https://phabricator.haskell.org/D1677
GHC Trac Issues: #10728
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/rts/T10728.hs | 40 | ||||
-rw-r--r-- | testsuite/tests/rts/T10728.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/rts/all.T | 13 |
3 files changed, 49 insertions, 5 deletions
diff --git a/testsuite/tests/rts/T10728.hs b/testsuite/tests/rts/T10728.hs new file mode 100644 index 0000000000..056124d0ca --- /dev/null +++ b/testsuite/tests/rts/T10728.hs @@ -0,0 +1,40 @@ +-- T10728 test case for ``-maxN<n>`` + +module Main where + +import GHC.Conc (getNumProcessors, getNumCapabilities) +import GHC.Environment +import Data.Char + +main :: IO () +main = do + -- We're parsing args passed in to make sure things are proper between the + -- cli and the program. + n <- getN + + c <- getNumCapabilities + p <- getNumProcessors + + putStr $ check n c p + +----- + +check :: Int -> Int -> Int -> String +check n c p + | n /= 0 && c /= 0 && p /= 0 -- These should never be 0 + -- Capabilities are equal to n, are they also within processor count? + && (n == c && c <= p) + -- Capabilities are equal to processor count, are they also within n? + || (c == p && c <= n) + = "maxN Successful" +check _n _c _p = "maxN Error" + +-- Parsing ``-maxN<n>`` from Args to be sure of it. +getN :: IO Int +getN = getFullArgs >>= return . go + where + go :: [String] -> Int + go as = case reads ( + dropWhile (not . isDigit) . (!! 1) $ as ) :: [(Int, String)] of + [x] -> fst x + _ -> 0 diff --git a/testsuite/tests/rts/T10728.stdout b/testsuite/tests/rts/T10728.stdout new file mode 100644 index 0000000000..715329ea3c --- /dev/null +++ b/testsuite/tests/rts/T10728.stdout @@ -0,0 +1 @@ +maxN Successful diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index 9892050b34..c88bd62267 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -1,9 +1,9 @@ test('testblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0')], + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0')], compile_and_run, ['']) test('testmblockalloc', - [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0')], + [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0')], compile_and_run, ['']) # -I0 is important: the idle GC will run the memory leak detector, # which will crash because the mblocks we allocate are not in a state @@ -53,7 +53,7 @@ test('divbyzero', when(opsys('mingw32'), omit_ways(prof_ways))], compile_and_run, ['']) -test('outofmem', when(opsys('darwin'), skip), +test('outofmem', when(opsys('darwin'), skip), run_command, ['$MAKE -s --no-print-directory outofmem']) test('outofmem2', extra_run_opts('+RTS -M5m -RTS'), run_command, ['$MAKE -s --no-print-directory outofmem2']) @@ -111,8 +111,8 @@ test('T2615', # omit dyn and profiling ways, because we don't build dyn_l or p_l # variants of the RTS by default -test('traceEvent', [ omit_ways(['dyn'] + prof_ways), - extra_run_opts('+RTS -ls -RTS') ], +test('traceEvent', [ omit_ways(['dyn'] + prof_ways), + extra_run_opts('+RTS -ls -RTS') ], compile_and_run, ['-eventlog']) test('T4059', @@ -333,3 +333,6 @@ test('T10590', [ignore_output, when(opsys('mingw32'),skip)], compile_and_run, [' # 20000 was easily enough to trigger the bug with 7.10 test('T10904', [ omit_ways(['ghci']), extra_run_opts('20000') ], compile_and_run, ['T10904lib.c']) + +test('T10728', [extra_run_opts('+RTS -maxN3 -RTS'), req_smp], + compile_and_run, ['-threaded']) |