# Path: px/px_file.py
# class PxFileBuilder:
# class PxFile(object):
#     def __init__(self):
#     def build(self):
#     def __repr__(self):
#     def __init__(self, pid, filetype):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def _resolve_name(self):
#     def device_number(self):
#     def fifo_id(self):
#     def get_endpoints(self):
# def resolve_endpoint(endpoint):
# def call_lsof():
# def lsof_to_files(lsof):
# def get_all():
# 
# Path: px/px_ipc_map.py
#     T = TypeVar("T")
#     S = TypeVar("S")
# FILE_TYPES = ["PIPE", "FIFO", "unix", "IPv4", "IPv6"]
# class IpcMap(object):
# class PeerProcess(object):
#     def __init__(
#         self,
#         process,  # type: px_process.PxProcess
#         files,  # type: Iterable[px_file.PxFile]
#         processes,  # type: Iterable[px_process.PxProcess]
#         is_root,  # type: bool
#     ):
#     def _create_fds(self, is_root):
#     def _create_mapping(self):
#     def _create_indices(self):
#     def _get_other_end_pids(self, file):
#     def add_ipc_entry(self, process, file):
#     def keys(self):
#     def __getitem__(self, process):
#     def __init__(self, name=None, pid=None):
#     def __repr__(self):
#     def __hash__(self):
#     def __str__(self):
# def create_pid2process(processes):
# def add_arraymapping(mapping, key, value):


import os.path
from px import px_file
from px import px_ipc_map
from . import testutils
    assert tc_file not in tc_ipc_map.network_connections

    postgres_ipc_map = testutils.create_ipc_map(42745, files)
    assert 33019 in postgres_ipc_map._get_other_end_pids(postgres_file)
    assert postgres_file not in postgres_ipc_map.network_connections


def test_get_ipc_map_1():
    """Tyre kick IpcMap with some real world data"""
    files = None
    my_dir = os.path.dirname(__file__)
    with open(os.path.join(my_dir, "lsof-test-output-linux-1.txt"), "r") as lsof_output:
        files = px_file.lsof_to_files(lsof_output.read())

    ipc_map = testutils.create_ipc_map(1997, files)
    keys = list(ipc_map.keys())
    assert len(keys) == 2

    peer0 = keys[0]
    assert len(ipc_map[peer0]) == 1

    peer1 = keys[1]
    assert len(ipc_map[peer1]) == 1


def test_get_ipc_map_2():
    """Tyre kick IpcMap with some real world data"""
    files = None
    my_dir = os.path.dirname(__file__)
    with open(os.path.join(my_dir, "lsof-test-output-linux-2.txt"), "r") as lsof_output:

# Path: px/px_file.py
# class PxFileBuilder:
# class PxFile(object):
#     def __init__(self):
#     def build(self):
#     def __repr__(self):
#     def __init__(self, pid, filetype):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def _resolve_name(self):
#     def device_number(self):
#     def fifo_id(self):
#     def get_endpoints(self):
# def resolve_endpoint(endpoint):
# def call_lsof():
# def lsof_to_files(lsof):
# def get_all():
# 
# Path: px/px_ipc_map.py
#     T = TypeVar("T")
#     S = TypeVar("S")
# FILE_TYPES = ["PIPE", "FIFO", "unix", "IPv4", "IPv6"]
# class IpcMap(object):
# class PeerProcess(object):
#     def __init__(
#         self,
#         process,  # type: px_process.PxProcess
#         files,  # type: Iterable[px_file.PxFile]
#         processes,  # type: Iterable[px_process.PxProcess]
#         is_root,  # type: bool
#     ):
#     def _create_fds(self, is_root):
#     def _create_mapping(self):
#     def _create_indices(self):
#     def _get_other_end_pids(self, file):
#     def add_ipc_entry(self, process, file):
#     def keys(self):
#     def __getitem__(self, process):
#     def __init__(self, name=None, pid=None):
#     def __repr__(self):
#     def __hash__(self):
#     def __str__(self):
# def create_pid2process(processes):
# def add_arraymapping(mapping, key, value):


# Path: tests/px_ipc_map_test.py
import os.path
from px import px_file
from px import px_ipc_map
from . import testutils

    assert tc_file not in tc_ipc_map.network_connections

    postgres_ipc_map = testutils.create_ipc_map(42745, files)
    assert 33019 in postgres_ipc_map._get_other_end_pids(postgres_file)
    assert postgres_file not in postgres_ipc_map.network_connections


def test_get_ipc_map_1():
    """Tyre kick IpcMap with some real world data"""
    files = None
    my_dir = os.path.dirname(__file__)
    with open(os.path.join(my_dir, "lsof-test-output-linux-1.txt"), "r") as lsof_output:
        files = px_file.lsof_to_files(lsof_output.read())

    ipc_map = testutils.create_ipc_map(1997, files)
    keys = list(ipc_map.keys())
    assert len(keys) == 2

    peer0 = keys[0]
    assert len(ipc_map[peer0]) == 1

    peer1 = keys[1]
    assert len(ipc_map[peer1]) == 1


def test_get_ipc_map_2():
    """Tyre kick IpcMap with some real world data"""
    files = None
    my_dir = os.path.dirname(__file__)
    with open(os.path.join(my_dir, "lsof-test-output-linux-2.txt"), "r") as lsof_output:

        files = px_file.lsof_to_files(lsof_output.read())