# Path: haystack/memory_dumper.py
# class MemoryDumper:
#     ARCHIVE_TYPES = ["dir", "tar", "gztar"]
#     def __init__(self, pid, dest):
#     def make_mappings(self):
#     def dump(self, dest=None):
#     def _dump_all_mappings_winapp(self, destdir):
#     def _dump_all_mappings(self, destdir):
#     def _free_process(self):
#     def _dump_mapping(self, m, tmpdir):
# def dump(pid, outfile):
# def _dump(opt):
# def argparser():
# def main():


import logging
import os
import shutil
import subprocess
import sys
import tempfile
import time
import unittest
        import os
        import haystack.api
        import haystack.api
        import haystack.api
from haystack import memory_dumper
        from haystack import types
        from haystack.mappings import folder
        from haystack.mappings.base import MemoryHandler
        tgt = tempfile.mkdtemp()
        self.tgts.append(tgt)
        return tgt

    def _renew_process(self):
        self.process.kill()
        self.process = self.run_app_test('test3', stdout=self.devnull.fileno())
        time.sleep(0.1)

    def test_mappings_file(self):
        '''Checks if memory_dumper make a _memory_handler index file'''
        tgt1 = self._make_tgt_dir()
        self.devnull = open('/dev/null')
        self.process = self.run_app_test('test1', stdout=self.devnull.fileno())
        time.sleep(0.1)
        # FIXME, heaponly is breaking machine detection.
        out1 = memory_dumper.dump(self.process.pid, tgt1, "dir", True)
        self.assertIsNotNone(open('%s/_memory_handler' % out1))
        self.assertGreater(len(
            open('%s/_memory_handler' % out1).readlines()), 15, 'the _memory_handler file looks too small')

    def test_dumptype_dir(self):
        '''Checks if dumping to folder works'''
        tgt1 = self._make_tgt_dir()
        tgt2 = self._make_tgt_dir()
        tgt3 = self._make_tgt_dir()

        self.devnull = open('/dev/null')
        self.process = self.run_app_test('test3', stdout=self.devnull.fileno())
        time.sleep(0.1)

# Path: haystack/memory_dumper.py
# class MemoryDumper:
#     ARCHIVE_TYPES = ["dir", "tar", "gztar"]
#     def __init__(self, pid, dest):
#     def make_mappings(self):
#     def dump(self, dest=None):
#     def _dump_all_mappings_winapp(self, destdir):
#     def _dump_all_mappings(self, destdir):
#     def _free_process(self):
#     def _dump_mapping(self, m, tmpdir):
# def dump(pid, outfile):
# def _dump(opt):
# def argparser():
# def main():


# Path: test/haystack/test_memory_dumper.py
import logging
import os
import shutil
import subprocess
import sys
import tempfile
import time
import unittest
        import os
        import haystack.api
        import haystack.api
        import haystack.api
from haystack import memory_dumper
        from haystack import types
        from haystack.mappings import folder
        from haystack.mappings.base import MemoryHandler

        tgt = tempfile.mkdtemp()
        self.tgts.append(tgt)
        return tgt

    def _renew_process(self):
        self.process.kill()
        self.process = self.run_app_test('test3', stdout=self.devnull.fileno())
        time.sleep(0.1)

    def test_mappings_file(self):
        '''Checks if memory_dumper make a _memory_handler index file'''
        tgt1 = self._make_tgt_dir()
        self.devnull = open('/dev/null')
        self.process = self.run_app_test('test1', stdout=self.devnull.fileno())
        time.sleep(0.1)
        # FIXME, heaponly is breaking machine detection.
        out1 = memory_dumper.dump(self.process.pid, tgt1, "dir", True)
        self.assertIsNotNone(open('%s/_memory_handler' % out1))
        self.assertGreater(len(
            open('%s/_memory_handler' % out1).readlines()), 15, 'the _memory_handler file looks too small')

    def test_dumptype_dir(self):
        '''Checks if dumping to folder works'''
        tgt1 = self._make_tgt_dir()
        tgt2 = self._make_tgt_dir()
        tgt3 = self._make_tgt_dir()

        self.devnull = open('/dev/null')
        self.process = self.run_app_test('test3', stdout=self.devnull.fileno())
        time.sleep(0.1)

        out1 = memory_dumper.dump(self.process.pid, tgt1, "dir", True)