Revision 3e16567e

b/.gitignore
97 97
/test/hs/hspace
98 98
/test/hs/hpc-htools
99 99
/test/hs/hpc-mon-collector
100
/test/hs/test
100
/test/hs/htest
101 101

  
102 102
# tools
103 103
/tools/kvm-ifup
b/Makefile.am
417 417
	$(HS_PROGS) \
418 418
	test/hs/hpc-htools \
419 419
	test/hs/hpc-mon-collector \
420
	test/hs/test \
420
	test/hs/htest \
421 421
	src/hconfd \
422 422
	src/rpc-test
423 423

  
......
432 432

  
433 433
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
434 434
HEXTRA =
435
# internal extra flags (used for test/hs/test mainly)
435
# internal extra flags (used for test/hs/htest mainly)
436 436
HEXTRA_INT =
437 437
# exclude options for coverage reports
438 438
HPCEXCL = --exclude Main \
......
684 684
	  $(HEXTRA) $(HEXTRA_INT) $@
685 685
	@touch "$@"
686 686

  
687
# for the test/hs/test binary, we need to enable profiling/coverage
688
test/hs/test: HEXTRA_INT=-fhpc -itest/hs
687
# for the test/hs/htest binary, we need to enable profiling/coverage
688
test/hs/htest: HEXTRA_INT=-fhpc -itest/hs
689 689

  
690 690
# we compile the hpc-htools binary with the program coverage
691 691
test/hs/hpc-htools: HEXTRA_INT=-fhpc
......
1040 1040
	test/py/qa.qa_config_unittest.py \
1041 1041
	test/py/tempfile_fork_unittest.py
1042 1042

  
1043
haskell_tests = test/hs/test
1043
haskell_tests = test/hs/htest
1044 1044

  
1045 1045
dist_TESTS = \
1046 1046
	test/py/check-cert-expired_unittest.bash \
......
1552 1552
	test -z "$$error"
1553 1553

  
1554 1554
.PHONY: hs-check
1555
hs-check: test/hs/test test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS) \
1555
hs-check: test/hs/htest test/hs/hpc-htools test/hs/hpc-mon-collector $(HS_BUILT_TEST_HELPERS) \
1556 1556
	| $(BUILT_PYTHON_SOURCES)
1557 1557
	@rm -f *.tix
1558
	./test/hs/test
1558
	./test/hs/htest
1559 1559
	HBINARY="./test/hs/hpc-htools" ./test/hs/offline-test.sh
1560 1560

  
1561 1561
# E111: indentation is not a multiple of four
......
1773 1773
	$(MAKE) $(AM_MAKEFLAGS) hs-check
1774 1774
	@mkdir_p@ $(COVERAGE_HS_DIR)
1775 1775
	hpc sum --union $(HPCEXCL) \
1776
	  test.tix hpc-htools.tix hpc-mon-collector.tix > coverage-htools.tix
1776
	  htest.tix hpc-htools.tix hpc-mon-collector.tix > coverage-htools.tix
1777 1777
	hpc markup --destdir=$(COVERAGE_HS_DIR) coverage-htools.tix
1778 1778
	hpc report coverage-htools.tix
1779 1779
	$(LN_S) -f hpc_index.html $(COVERAGE_HS_DIR)/index.html
b/test/hs/htest.hs
1
{-| Unittest runner for ganeti-htools.
2

  
3
-}
4

  
5
{-
6

  
7
Copyright (C) 2009, 2011, 2012 Google Inc.
8

  
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
13

  
14
This program is distributed in the hope that it will be useful, but
15
WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
General Public License for more details.
18

  
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22
02110-1301, USA.
23

  
24
-}
25

  
26
module Main(main) where
27

  
28
import Data.Monoid (mappend)
29
import Test.Framework
30
import System.Environment (getArgs)
31
import System.Log.Logger
32

  
33
import Test.Ganeti.TestImports ()
34
import Test.Ganeti.Attoparsec
35
import Test.Ganeti.BasicTypes
36
import Test.Ganeti.Block.Drbd.Parser
37
import Test.Ganeti.Block.Drbd.Types
38
import Test.Ganeti.Common
39
import Test.Ganeti.Confd.Utils
40
import Test.Ganeti.Confd.Types
41
import Test.Ganeti.Daemon
42
import Test.Ganeti.Errors
43
import Test.Ganeti.HTools.Backend.Simu
44
import Test.Ganeti.HTools.Backend.Text
45
import Test.Ganeti.HTools.CLI
46
import Test.Ganeti.HTools.Cluster
47
import Test.Ganeti.HTools.Container
48
import Test.Ganeti.HTools.Graph
49
import Test.Ganeti.HTools.Instance
50
import Test.Ganeti.HTools.Loader
51
import Test.Ganeti.HTools.Node
52
import Test.Ganeti.HTools.PeerMap
53
import Test.Ganeti.HTools.Types
54
import Test.Ganeti.JSON
55
import Test.Ganeti.Jobs
56
import Test.Ganeti.JQueue
57
import Test.Ganeti.Luxi
58
import Test.Ganeti.Network
59
import Test.Ganeti.Objects
60
import Test.Ganeti.OpCodes
61
import Test.Ganeti.Query.Filter
62
import Test.Ganeti.Query.Language
63
import Test.Ganeti.Query.Query
64
import Test.Ganeti.Rpc
65
import Test.Ganeti.Ssconf
66
import Test.Ganeti.THH
67
import Test.Ganeti.Types
68
import Test.Ganeti.Utils
69

  
70
-- | Our default test options, overring the built-in test-framework
71
-- ones (but not the supplied command line parameters).
72
defOpts :: TestOptions
73
defOpts = TestOptions
74
       { topt_seed                               = Nothing
75
       , topt_maximum_generated_tests            = Just 500
76
       , topt_maximum_unsuitable_generated_tests = Just 5000
77
       , topt_maximum_test_size                  = Nothing
78
       , topt_maximum_test_depth                 = Nothing
79
       , topt_timeout                            = Nothing
80
       }
81

  
82
-- | All our defined tests.
83
allTests :: [Test]
84
allTests =
85
  [ testBasicTypes
86
  , testAttoparsec
87
  , testCommon
88
  , testConfd_Types
89
  , testConfd_Utils
90
  , testDaemon
91
  , testBlock_Drbd_Parser
92
  , testBlock_Drbd_Types
93
  , testErrors
94
  , testHTools_Backend_Simu
95
  , testHTools_Backend_Text
96
  , testHTools_CLI
97
  , testHTools_Cluster
98
  , testHTools_Container
99
  , testHTools_Graph
100
  , testHTools_Instance
101
  , testHTools_Loader
102
  , testHTools_Node
103
  , testHTools_PeerMap
104
  , testHTools_Types
105
  , testJSON
106
  , testJobs
107
  , testJQueue
108
  , testLuxi
109
  , testNetwork
110
  , testObjects
111
  , testOpCodes
112
  , testQuery_Filter
113
  , testQuery_Language
114
  , testQuery_Query
115
  , testRpc
116
  , testSsconf
117
  , testTHH
118
  , testTypes
119
  , testUtils
120
  ]
121

  
122
-- | Main function. Note we don't use defaultMain since we want to
123
-- control explicitly our test sizes (and override the default).
124
main :: IO ()
125
main = do
126
  ropts <- getArgs >>= interpretArgsOrExit
127
  let opts = maybe defOpts (defOpts `mappend`) $ ropt_test_options ropts
128
  -- silence the logging system, so that tests can execute I/O actions
129
  -- which create logs without polluting stderr
130
  -- FIXME: improve this by allowing tests to use logging if needed
131
  updateGlobalLogger rootLoggerName (setLevel EMERGENCY)
132
  defaultMainWithOpts allTests (ropts { ropt_test_options = Just opts })
/dev/null
1
{-| Unittest runner for ganeti-htools.
2

  
3
-}
4

  
5
{-
6

  
7
Copyright (C) 2009, 2011, 2012 Google Inc.
8

  
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
13

  
14
This program is distributed in the hope that it will be useful, but
15
WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
General Public License for more details.
18

  
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22
02110-1301, USA.
23

  
24
-}
25

  
26
module Main(main) where
27

  
28
import Data.Monoid (mappend)
29
import Test.Framework
30
import System.Environment (getArgs)
31
import System.Log.Logger
32

  
33
import Test.Ganeti.TestImports ()
34
import Test.Ganeti.Attoparsec
35
import Test.Ganeti.BasicTypes
36
import Test.Ganeti.Block.Drbd.Parser
37
import Test.Ganeti.Block.Drbd.Types
38
import Test.Ganeti.Common
39
import Test.Ganeti.Confd.Utils
40
import Test.Ganeti.Confd.Types
41
import Test.Ganeti.Daemon
42
import Test.Ganeti.Errors
43
import Test.Ganeti.HTools.Backend.Simu
44
import Test.Ganeti.HTools.Backend.Text
45
import Test.Ganeti.HTools.CLI
46
import Test.Ganeti.HTools.Cluster
47
import Test.Ganeti.HTools.Container
48
import Test.Ganeti.HTools.Graph
49
import Test.Ganeti.HTools.Instance
50
import Test.Ganeti.HTools.Loader
51
import Test.Ganeti.HTools.Node
52
import Test.Ganeti.HTools.PeerMap
53
import Test.Ganeti.HTools.Types
54
import Test.Ganeti.JSON
55
import Test.Ganeti.Jobs
56
import Test.Ganeti.JQueue
57
import Test.Ganeti.Luxi
58
import Test.Ganeti.Network
59
import Test.Ganeti.Objects
60
import Test.Ganeti.OpCodes
61
import Test.Ganeti.Query.Filter
62
import Test.Ganeti.Query.Language
63
import Test.Ganeti.Query.Query
64
import Test.Ganeti.Rpc
65
import Test.Ganeti.Ssconf
66
import Test.Ganeti.THH
67
import Test.Ganeti.Types
68
import Test.Ganeti.Utils
69

  
70
-- | Our default test options, overring the built-in test-framework
71
-- ones (but not the supplied command line parameters).
72
defOpts :: TestOptions
73
defOpts = TestOptions
74
       { topt_seed                               = Nothing
75
       , topt_maximum_generated_tests            = Just 500
76
       , topt_maximum_unsuitable_generated_tests = Just 5000
77
       , topt_maximum_test_size                  = Nothing
78
       , topt_maximum_test_depth                 = Nothing
79
       , topt_timeout                            = Nothing
80
       }
81

  
82
-- | All our defined tests.
83
allTests :: [Test]
84
allTests =
85
  [ testBasicTypes
86
  , testAttoparsec
87
  , testCommon
88
  , testConfd_Types
89
  , testConfd_Utils
90
  , testDaemon
91
  , testBlock_Drbd_Parser
92
  , testBlock_Drbd_Types
93
  , testErrors
94
  , testHTools_Backend_Simu
95
  , testHTools_Backend_Text
96
  , testHTools_CLI
97
  , testHTools_Cluster
98
  , testHTools_Container
99
  , testHTools_Graph
100
  , testHTools_Instance
101
  , testHTools_Loader
102
  , testHTools_Node
103
  , testHTools_PeerMap
104
  , testHTools_Types
105
  , testJSON
106
  , testJobs
107
  , testJQueue
108
  , testLuxi
109
  , testNetwork
110
  , testObjects
111
  , testOpCodes
112
  , testQuery_Filter
113
  , testQuery_Language
114
  , testQuery_Query
115
  , testRpc
116
  , testSsconf
117
  , testTHH
118
  , testTypes
119
  , testUtils
120
  ]
121

  
122
-- | Main function. Note we don't use defaultMain since we want to
123
-- control explicitly our test sizes (and override the default).
124
main :: IO ()
125
main = do
126
  ropts <- getArgs >>= interpretArgsOrExit
127
  let opts = maybe defOpts (defOpts `mappend`) $ ropt_test_options ropts
128
  -- silence the logging system, so that tests can execute I/O actions
129
  -- which create logs without polluting stderr
130
  -- FIXME: improve this by allowing tests to use logging if needed
131
  updateGlobalLogger rootLoggerName (setLevel EMERGENCY)
132
  defaultMainWithOpts allTests (ropts { ropt_test_options = Just opts })

Also available in: Unified diff