Commit 06fe0cea authored by Iustin Pop's avatar Iustin Pop
Browse files

Improve the test driver

The tests are moved to a separate data structure, and we can select a
subset of tests to run.
parent 88f25dd0
...@@ -29,17 +29,18 @@ import Data.IORef ...@@ -29,17 +29,18 @@ import Data.IORef
import Test.QuickCheck.Batch import Test.QuickCheck.Batch
import System.IO import System.IO
import System.Exit import System.Exit
import System (getArgs)
import Ganeti.HTools.QC import Ganeti.HTools.QC
fastOptions :: TestOptions fast :: TestOptions
fastOptions = TestOptions fast = TestOptions
{ no_of_tests = 500 { no_of_tests = 500
, length_of_tests = 10 , length_of_tests = 10
, debug_tests = False } , debug_tests = False }
slowOptions :: TestOptions slow :: TestOptions
slowOptions = TestOptions slow = TestOptions
{ no_of_tests = 50 { no_of_tests = 50
, length_of_tests = 100 , length_of_tests = 100
, debug_tests = False } , debug_tests = False }
...@@ -59,17 +60,26 @@ wrapTest ir t to = do ...@@ -59,17 +60,26 @@ wrapTest ir t to = do
_ -> return () _ -> return ()
return tr return tr
allTests :: [(String, TestOptions, [TestOptions -> IO TestResult])]
allTests =
[ ("PeerMap", fast, testPeerMap)
, ("Container", fast, testContainer)
, ("Instance", fast, testInstance)
, ("Node", fast, testNode)
, ("Text", fast, testText)
, ("OpCodes", fast, testOpCodes)
, ("Cluster", slow, testCluster)
]
main :: IO () main :: IO ()
main = do main = do
errs <- newIORef 0 errs <- newIORef 0
let wrap = map (wrapTest errs) let wrap = map (wrapTest errs)
runTests "PeerMap" fastOptions $ wrap testPeerMap args <- getArgs
runTests "Container" fastOptions $ wrap testContainer let tests = if null args
runTests "Instance" fastOptions $ wrap testInstance then allTests
runTests "Node" fastOptions $ wrap testNode else filter (\(name, _, _) -> name `elem` args) allTests
runTests "Text" fastOptions $ wrap testText mapM_ (\(name, opts, tl) -> runTests name opts (wrap tl)) tests
runTests "OpCodes" fastOptions $ wrap testOpCodes
runTests "Cluster" slowOptions $ wrap testCluster
terr <- readIORef errs terr <- readIORef errs
(if terr > 0 (if terr > 0
then do then do
......
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