Skip to content

Commit 4770b44

Browse files
committed
Added a test that paramertizes the xattr name
1 parent 4f517be commit 4770b44

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/test_xattr.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,53 @@ def test_xattr_utf8_filenames(
330330
),
331331
],
332332
)
333+
334+
335+
@pytest.mark.parametrize(
336+
'xattr_name',
337+
[
338+
pytest.param('user.ascii', id='ASCII'),
339+
pytest.param('user.café', id='French'),
340+
pytest.param('user.файл', id='Cyrillic'),
341+
pytest.param('user.测试', id='Chinese'),
342+
pytest.param('user.🔒secure', id='Emoji'),
343+
],
344+
)
345+
def test_xattr_utf8_names(
346+
test_file: str,
347+
server: FileActivityService,
348+
xattr_name: str,
349+
):
350+
"""
351+
Tests that xattr events with UTF-8 xattr names are correctly
352+
tracked.
353+
354+
Args:
355+
test_file: File monitored on the host.
356+
server: The server instance to communicate with.
357+
xattr_name: The xattr name to set and remove.
358+
"""
359+
process = Process.from_proc()
360+
361+
os.setxattr(test_file, xattr_name, b'value')
362+
os.removexattr(test_file, xattr_name)
363+
364+
server.wait_events(
365+
skip_xattr=False,
366+
events=[
367+
Event(
368+
process=process,
369+
event_type=EventType.XATTR_SET,
370+
file='',
371+
host_path=test_file,
372+
xattr_name=xattr_name,
373+
),
374+
Event(
375+
process=process,
376+
event_type=EventType.XATTR_REMOVE,
377+
file='',
378+
host_path=test_file,
379+
xattr_name=xattr_name,
380+
),
381+
],
382+
)

0 commit comments

Comments
 (0)