Home | History | Annotate | Download | only in scheduler
      1 #!/usr/bin/python
      2 
      3 import gc
      4 import logging
      5 import unittest
      6 
      7 import common
      8 from autotest_lib.client.common_lib.test_utils import mock
      9 from autotest_lib.scheduler import gc_stats
     10 
     11 
     12 class 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 
     36 if __name__ == '__main__':
     37     unittest.main()
     38