def __init__(self): '''Initializes an unified log reader.''' super(UnifiedLogReader, self).__init__() self._caches = None self._ts_list = [] self._uuidtext_folder_path = None self._vfs = virtual_file_system.VirtualFileSystem( virtual_file.VirtualFile) self.total_logs_processed = 0
def testGetVirtualFile(self): '''Tests the get_virtual_file function.''' file_system = virtual_file_system.VirtualFileSystem( virtual_file.VirtualFile) path = os.path.join( self._TEST_DATA_PATH, '7EF56328D53A78B59CCCE3E3189F57') file_entry = file_system.get_virtual_file(path, filetype='uuidtext') self.assertIsNotNone(file_entry) self.assertIsInstance(file_entry, virtual_file.VirtualFile)
def testPathJoin(self): '''Tests the path_join function.''' file_system = virtual_file_system.VirtualFileSystem( virtual_file.VirtualFile) expected_path = os.path.join( self._TEST_DATA_PATH, '7EF56328D53A78B59CCCE3E3189F57') path = file_system.path_join( self._TEST_DATA_PATH, '7EF56328D53A78B59CCCE3E3189F57') self.assertEqual(path, expected_path)
def testIsDir(self): '''Tests the is_dir function.''' file_system = virtual_file_system.VirtualFileSystem( virtual_file.VirtualFile) result = file_system.is_dir(self._TEST_DATA_PATH) self.assertTrue(result) path = os.path.join( self._TEST_DATA_PATH, '7EF56328D53A78B59CCCE3E3189F57') result = file_system.is_dir(path) self.assertFalse(result)
def testListdir(self): '''Tests the listdir function.''' file_system = virtual_file_system.VirtualFileSystem( virtual_file.VirtualFile) expected_directory_entries = [ '0000000000000030.tracev3', '7EF56328D53A78B59CCCE3E3189F57', '8E21CAB1DCF936B49F85CF860E6F34EC'] directory_entries = file_system.listdir(self._TEST_DATA_PATH) self.assertEqual(len(directory_entries), 3) self.assertEqual(sorted(directory_entries), expected_directory_entries)
def testPathExists(self): '''Tests the path_exists function.''' file_system = virtual_file_system.VirtualFileSystem( virtual_file.VirtualFile) path = os.path.join( self._TEST_DATA_PATH, '7EF56328D53A78B59CCCE3E3189F57') result = file_system.path_exists(path) self.assertTrue(result) path = os.path.join(self._TEST_DATA_PATH, 'bogus') result = file_system.path_exists(path) self.assertFalse(result)
def _CreateTestFile(self): '''Creates a test tracev3 file. Returns: tuple[VirtualFile, TraceV3]: virtual and tracev3 file objects for testing. ''' file_system = virtual_file_system.VirtualFileSystem( virtual_file.VirtualFile) path = self._GetTestFilePath(['0000000000000030.tracev3']) file_entry = virtual_file.VirtualFile(path, filetype='uuidtext') timesync = self._CreateTestTimesync() timesync_list = [timesync] uuidtext_path = self._GetTestFilePath([]) test_file = tracev3_file.TraceV3(file_system, file_entry, timesync_list, uuidtext_path) return file_entry, test_file