blob: 3c504f65f173ff2b07da2d87b4420b00b6ab3b33 [file] [log] [blame]
# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Test the c_blkpg module."""
import errno
import os
import pytest
from chromite.lib import osutils
from chromite.utils import c_blkpg
def test_non_block() -> None:
"""Test the code against a non-block device."""
with osutils.OpenContext(".", flags=os.O_RDONLY) as fd:
with pytest.raises(OSError) as e:
c_blkpg.add_partition(fd, 0, 0, 0)
assert e.value.errno == errno.ENOTTY
with pytest.raises(OSError) as e:
c_blkpg.delete_partition(fd, 0)
assert e.value.errno == errno.ENOTTY