• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2
3import gc
4import logging
5
6import common
7from autotest_lib.client.common_lib.test_utils import mock
8from autotest_lib.client.common_lib.test_utils import unittest
9from autotest_lib.scheduler import gc_stats
10
11
12class TestGcStats(unittest.TestCase):
13    def setUp(self):
14        self.god = mock.mock_god()
15
16
17    def tearDown(self):
18        self.god.unstub_all()
19
20
21    def test_log_garbage_collector_stats(self):
22        # Call this for code coverage.
23        # Prevent log spam from this test but do test that the log
24        # message formats correctly.
25        def _mock_logging_func(message, *args):
26            if args:
27                message %= args
28        self.god.stub_with(logging, 'debug', _mock_logging_func)
29        self.god.stub_with(logging, 'info', _mock_logging_func)
30        gc_stats._log_garbage_collector_stats()
31        # Add a new dict, exercise the delta counting & printing code.
32        y = {}
33        gc_stats._log_garbage_collector_stats(1)
34
35
36if __name__ == '__main__':
37    unittest.main()
38