Example #1
0
    def testOpenAndClose(self):
        """Test the open and close functionality."""
        file_system = lvm_file_system.LVMFileSystem(self._resolver_context,
                                                    self._lvm_path_spec)
        self.assertIsNotNone(file_system)

        file_system.Open()
Example #2
0
    def testFileEntryExistsByPathSpec(self):
        """Test the file entry exists by path specification functionality."""
        file_system = lvm_file_system.LVMFileSystem(self._resolver_context)
        self.assertIsNotNone(file_system)

        file_system.Open(self._lvm_path_spec)

        path_spec = lvm_path_spec.LVMPathSpec(location='/',
                                              parent=self._qcow_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = lvm_path_spec.LVMPathSpec(parent=self._qcow_path_spec,
                                              volume_index=1)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = lvm_path_spec.LVMPathSpec(location='/lvm2',
                                              parent=self._qcow_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = lvm_path_spec.LVMPathSpec(parent=self._qcow_path_spec,
                                              volume_index=9)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = lvm_path_spec.LVMPathSpec(location='/lvm0',
                                              parent=self._qcow_path_spec)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = lvm_path_spec.LVMPathSpec(location='/lvm9',
                                              parent=self._qcow_path_spec)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

        file_system.Close()
Example #3
0
    def testGetFileEntryByPathSpec(self):
        """Tests the GetFileEntryByPathSpec function."""
        file_system = lvm_file_system.LVMFileSystem(self._resolver_context,
                                                    self._lvm_path_spec)
        self.assertIsNotNone(file_system)

        file_system.Open()

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/',
            parent=self._raw_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, '')

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            parent=self._raw_path_spec,
            volume_index=0)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, 'lvm1')

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/lvm1',
            parent=self._raw_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, 'lvm1')

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            parent=self._raw_path_spec,
            volume_index=9)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/lvm0',
            parent=self._raw_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/lvm9',
            parent=self._raw_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)
Example #4
0
    def NewFileSystem(self, resolver_context):
        """Creates a new file system object.

    Args:
      resolver_context (Context): resolver context.

    Returns:
      FileSystem: file system.
    """
        return lvm_file_system.LVMFileSystem(resolver_context)
Example #5
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_file = self._GetTestFilePath(['lvmtest.qcow2'])
        path_spec = os_path_spec.OSPathSpec(location=test_file)
        self._qcow_path_spec = qcow_path_spec.QCOWPathSpec(parent=path_spec)
        self._lvm_path_spec = lvm_path_spec.LVMPathSpec(
            location='/', parent=self._qcow_path_spec)

        self._file_system = lvm_file_system.LVMFileSystem(
            self._resolver_context)
        self._file_system.Open(self._lvm_path_spec)
Example #6
0
    def testGetRootFileEntry(self):
        """Test the get root file entry functionality."""
        file_system = lvm_file_system.LVMFileSystem(self._resolver_context,
                                                    self._lvm_path_spec)
        self.assertIsNotNone(file_system)

        file_system.Open()

        file_entry = file_system.GetRootFileEntry()

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, '')
Example #7
0
    def testGetFileEntryByPathSpec(self):
        """Tests the GetFileEntryByPathSpec function."""
        file_system = lvm_file_system.LVMFileSystem(self._resolver_context)
        self.assertIsNotNone(file_system)

        file_system.Open(self._lvm_path_spec)

        path_spec = lvm_path_spec.LVMPathSpec(location='/',
                                              parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, '')

        path_spec = lvm_path_spec.LVMPathSpec(parent=self._qcow_path_spec,
                                              volume_index=1)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, 'lvm2')

        path_spec = lvm_path_spec.LVMPathSpec(location='/lvm2',
                                              parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNotNone(file_entry)
        self.assertEqual(file_entry.name, 'lvm2')

        path_spec = lvm_path_spec.LVMPathSpec(parent=self._qcow_path_spec,
                                              volume_index=9)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        path_spec = lvm_path_spec.LVMPathSpec(location='/lvm0',
                                              parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        path_spec = lvm_path_spec.LVMPathSpec(location='/lvm9',
                                              parent=self._qcow_path_spec)
        file_entry = file_system.GetFileEntryByPathSpec(path_spec)

        self.assertIsNone(file_entry)

        file_system.Close()
Example #8
0
    def setUp(self):
        """Sets up the needed objects used throughout the test."""
        self._resolver_context = context.Context()
        test_path = self._GetTestFilePath(['lvm.raw'])
        self._SkipIfPathNotExists(test_path)

        test_os_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_OS, location=test_path)
        self._raw_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_RAW, parent=test_os_path_spec)
        self._lvm_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/',
            parent=self._raw_path_spec)

        self._file_system = lvm_file_system.LVMFileSystem(
            self._resolver_context, self._lvm_path_spec)
        self._file_system.Open()
Example #9
0
    def testFileEntryExistsByPathSpec(self):
        """Test the file entry exists by path specification functionality."""
        file_system = lvm_file_system.LVMFileSystem(self._resolver_context,
                                                    self._lvm_path_spec)
        self.assertIsNotNone(file_system)

        file_system.Open()

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/',
            parent=self._raw_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            parent=self._raw_path_spec,
            volume_index=0)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/lvm1',
            parent=self._raw_path_spec)
        self.assertTrue(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            parent=self._raw_path_spec,
            volume_index=9)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/lvm0',
            parent=self._raw_path_spec)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))

        path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_LVM,
            location='/lvm9',
            parent=self._raw_path_spec)
        self.assertFalse(file_system.FileEntryExistsByPathSpec(path_spec))