summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-09-17 18:30:57 +0200
committerMichał Górny <mgorny@gentoo.org>2022-09-17 18:30:57 +0200
commit3c251c8d655011ec2ee4ec02933e8e02163b4620 (patch)
tree225bc6dd8208e5c3ead9b6594dead4ac8d5dbafc /tests
parent1cdca1a14706c46f9161c8eca319dad7b15e7cd6 (diff)
downloadgemato-3c251c8d655011ec2ee4ec02933e8e02163b4620.tar.gz
Fix a corner case when open() fails w/ NXIO/OPNOTSUPP on reg file
Closes: https://github.com/projg2/gemato/issues/21 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_verify.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_verify.py b/tests/test_verify.py
index 8890e1a..0c3fba9 100644
--- a/tests/test_verify.py
+++ b/tests/test_verify.py
@@ -4,11 +4,13 @@
# Licensed under the terms of 2-clause BSD license
import contextlib
+import errno
import itertools
import os
import os.path
import socket
import stat
+import unittest.mock
import pytest
@@ -560,3 +562,11 @@ def test_entry_compatibility(a_cls, a_name, a_args, b_cls, b_name,
e1 = new_manifest_entry(a_cls, a_name, *a_args)
e2 = new_manifest_entry(b_cls, b_name, *b_args)
assert verify_entry_compatibility(e1, e2) == (expected, diff)
+
+
+def test_get_file_metadata_fail_to_open_reg(test_tree):
+ """Regression test for when open() fails on a seemingly regular file"""
+ with unittest.mock.patch("os.open") as mock_open:
+ mock_open.side_effect = OSError(errno.ENXIO, "mocked error")
+ with pytest.raises(OSError):
+ list(get_file_metadata(test_tree / "regular-file", {}))