# Path: dtformats/cpio.py
# class CPIOArchiveFileEntry(data_range.DataRange):
# class CPIOArchiveFile(data_format.BinaryDataFile):
#   def __init__(self, file_object, data_offset=0, data_size=0):
#   def __init__(self, debug=False, output_writer=None):
#   def _DebugPrintFileEntry(self, file_entry):
#   def _ReadFileEntry(self, file_object, file_offset):
#   def _ReadFileEntries(self, file_object):
#   def Close(self):
#   def FileEntryExistsByPath(self, path):
#   def GetFileEntries(self, path_prefix=''):
#   def GetFileEntryByPath(self, path):
#   def ReadFileObject(self, file_object):
#   _FABRIC = data_format.BinaryDataFile.ReadDefinitionFile('cpio.yaml')
#   _CPIO_SIGNATURE_BINARY_BIG_ENDIAN = b'\x71\xc7'
#   _CPIO_SIGNATURE_BINARY_LITTLE_ENDIAN = b'\xc7\x71'
#   _CPIO_SIGNATURE_PORTABLE_ASCII = b'070707'
#   _CPIO_SIGNATURE_NEW_ASCII = b'070701'
#   _CPIO_SIGNATURE_NEW_ASCII_WITH_CHECKSUM = b'070702'
#   _CPIO_ATTRIBUTE_NAMES_ODC = (
#       'device_number', 'inode_number', 'mode', 'user_identifier',
#       'group_identifier', 'number_of_links', 'special_device_number',
#       'modification_time', 'path_size', 'file_size')
#   _CPIO_ATTRIBUTE_NAMES_CRC = (
#       'inode_number', 'mode', 'user_identifier', 'group_identifier',
#       'number_of_links', 'modification_time', 'path_size',
#       'file_size', 'device_major_number', 'device_minor_number',
#       'special_device_major_number', 'special_device_minor_number',
#       'checksum')
# 
# Path: tests/test_lib.py
# class BaseTestCase(unittest.TestCase):
# class TestOutputWriter(output_writers.OutputWriter):
#   _TEST_DATA_PATH = os.path.join(os.getcwd(), 'test_data')
#   def _GetTestFilePath(self, path_segments):
#   def _SkipIfPathNotExists(self, path):
#   def __init__(self):
#   def Close(self):
#   def Open(self):
#   def WriteText(self, text):


import io
import unittest
from dtformats import cpio
from tests import test_lib
  def testReadFileObjectOnNewASCII(self):
    """Tests the ReadFileObject function on new ASCII format."""
    output_writer = test_lib.TestOutputWriter()
    test_file = cpio.CPIOArchiveFile(debug=True, output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['cpio', 'syslog.newc.cpio'])
    self._SkipIfPathNotExists(test_file_path)

    test_file.Open(test_file_path)

    self.assertEqual(test_file.file_format, 'newc')

    test_file.Close()

  def testReadFileObjectOnNewASCIIWithCRC(self):
    """Tests the ReadFileObject function on new ASCII with CRC format."""
    output_writer = test_lib.TestOutputWriter()
    test_file = cpio.CPIOArchiveFile(debug=True, output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['cpio', 'syslog.crc.cpio'])
    self._SkipIfPathNotExists(test_file_path)

    test_file.Open(test_file_path)

    self.assertEqual(test_file.file_format, 'crc')

    test_file.Close()

  def testReadFileObjectOnPortableASCII(self):
    """Tests the ReadFileObject function on portable ASCII format."""

# Path: dtformats/cpio.py
# class CPIOArchiveFileEntry(data_range.DataRange):
# class CPIOArchiveFile(data_format.BinaryDataFile):
#   def __init__(self, file_object, data_offset=0, data_size=0):
#   def __init__(self, debug=False, output_writer=None):
#   def _DebugPrintFileEntry(self, file_entry):
#   def _ReadFileEntry(self, file_object, file_offset):
#   def _ReadFileEntries(self, file_object):
#   def Close(self):
#   def FileEntryExistsByPath(self, path):
#   def GetFileEntries(self, path_prefix=''):
#   def GetFileEntryByPath(self, path):
#   def ReadFileObject(self, file_object):
#   _FABRIC = data_format.BinaryDataFile.ReadDefinitionFile('cpio.yaml')
#   _CPIO_SIGNATURE_BINARY_BIG_ENDIAN = b'\x71\xc7'
#   _CPIO_SIGNATURE_BINARY_LITTLE_ENDIAN = b'\xc7\x71'
#   _CPIO_SIGNATURE_PORTABLE_ASCII = b'070707'
#   _CPIO_SIGNATURE_NEW_ASCII = b'070701'
#   _CPIO_SIGNATURE_NEW_ASCII_WITH_CHECKSUM = b'070702'
#   _CPIO_ATTRIBUTE_NAMES_ODC = (
#       'device_number', 'inode_number', 'mode', 'user_identifier',
#       'group_identifier', 'number_of_links', 'special_device_number',
#       'modification_time', 'path_size', 'file_size')
#   _CPIO_ATTRIBUTE_NAMES_CRC = (
#       'inode_number', 'mode', 'user_identifier', 'group_identifier',
#       'number_of_links', 'modification_time', 'path_size',
#       'file_size', 'device_major_number', 'device_minor_number',
#       'special_device_major_number', 'special_device_minor_number',
#       'checksum')
# 
# Path: tests/test_lib.py
# class BaseTestCase(unittest.TestCase):
# class TestOutputWriter(output_writers.OutputWriter):
#   _TEST_DATA_PATH = os.path.join(os.getcwd(), 'test_data')
#   def _GetTestFilePath(self, path_segments):
#   def _SkipIfPathNotExists(self, path):
#   def __init__(self):
#   def Close(self):
#   def Open(self):
#   def WriteText(self, text):


# Path: tests/cpio.py
import io
import unittest
from dtformats import cpio
from tests import test_lib

  def testReadFileObjectOnNewASCII(self):
    """Tests the ReadFileObject function on new ASCII format."""
    output_writer = test_lib.TestOutputWriter()
    test_file = cpio.CPIOArchiveFile(debug=True, output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['cpio', 'syslog.newc.cpio'])
    self._SkipIfPathNotExists(test_file_path)

    test_file.Open(test_file_path)

    self.assertEqual(test_file.file_format, 'newc')

    test_file.Close()

  def testReadFileObjectOnNewASCIIWithCRC(self):
    """Tests the ReadFileObject function on new ASCII with CRC format."""
    output_writer = test_lib.TestOutputWriter()
    test_file = cpio.CPIOArchiveFile(debug=True, output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['cpio', 'syslog.crc.cpio'])
    self._SkipIfPathNotExists(test_file_path)

    test_file.Open(test_file_path)

    self.assertEqual(test_file.file_format, 'crc')

    test_file.Close()

  def testReadFileObjectOnPortableASCII(self):
    """Tests the ReadFileObject function on portable ASCII format."""

    output_writer = test_lib.TestOutputWriter()