Exemple #1
0
def cleanup_task_state():
  """Cleans state before and after a task is executed."""
  # Cleanup stale processes.
  process_handler.cleanup_stale_processes()

  # Clear build urls, temp and testcase directories.
  shell.clear_build_urls_directory()
  shell.clear_crash_stacktraces_directory()
  shell.clear_testcase_directories()
  shell.clear_temp_directory()
  shell.clear_system_temp_directory()
  shell.clear_device_temp_directories()

  # Reset memory tool environment variables.
  environment.reset_current_memory_tool_options()

  # Call python's garbage collector.
  utils.python_gc()
Exemple #2
0
    def test(self):
        """Test clear_system_temp_directory works as expected."""
        self.fs.CreateFile('/tmp/aa/bb.txt', contents='abc')
        self.fs.CreateFile('/tmp/cc/dd/ee.txt', contents='def')
        self.fs.CreateDirectory('/tmp/ff/gg')
        self.fs.CreateDirectory('/tmp/hh')
        self.fs.CreateDirectory('/unrelated')
        self.fs.CreateFile('/unrelated/zz.txt', contents='zzz')
        os.symlink('/unrelated/zz.txt', '/tmp/hh/gg.txt')
        os.symlink('/unrelated', '/tmp/ii')

        shell.clear_system_temp_directory()

        self.assertTrue(os.path.exists('/tmp'))
        self.assertTrue(os.path.exists('/unrelated'))
        self.assertEqual(shell.get_directory_file_count('/tmp'), 0)
        self.assertEqual(shell.get_directory_file_count('/unrelated'), 1)
        self.assertFalse(os.path.exists('/tmp/aa/bb.txt'))
        self.assertFalse(os.path.exists('/tmp/cc/dd/ee.txt'))
        self.assertFalse(os.path.exists('/tmp/ff/gg'))
        self.assertFalse(os.path.exists('/tmp/hh'))