test: Try to create temporary XDG_RUNTIME_DIR with correct mode

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2022-06-23 19:44:27 +01:00
parent e6e2370e9e
commit d9194ffb4d
3 changed files with 18 additions and 2 deletions

View file

@ -855,6 +855,7 @@ EXTRA_DIST += data/installable/meson.build
EXTRA_DIST += data/meson.build
EXTRA_DIST += meson.build
EXTRA_DIST += meta_template.test.in
EXTRA_DIST += mkdir-m700.py
# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
include $(top_srcdir)/aminclude_static.am

View file

@ -76,8 +76,8 @@ test_env.set('DBUS_TEST_UNINSTALLED', '1')
xdgdir = custom_target('gen-xdgdir',
command: [
python, '-c',
'import os, sys; os.makedirs(sys.argv[1], exist_ok=True)',
python,
files('mkdir-m700.py'),
meson.current_build_dir() / 'XDG_RUNTIME_DIR',
],
output: 'XDG_RUNTIME_DIR'

15
test/mkdir-m700.py Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env python3
# Copyright 2022 Collabora Ltd.
# SPDX-License-Identifier: MIT
import os
import sys
# Note that we can't create the XDG_RUNTIME_DIR with permissions 0700
# on MSYS2, which rejects attempts to change permissions, hence "|| true".
os.makedirs(sys.argv[1], exist_ok=True)
try:
os.chmod(sys.argv[1], 0o700)
except OSError:
pass