aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-runner.c
diff options
context:
space:
mode:
authorAntonin Décimo <antonin.decimo@gmail.com>2022-03-11 14:08:49 +0100
committerSimon Ser <contact@emersion.fr>2022-06-09 18:34:17 +0000
commit9434e8d69f76d7859ed7b18edc5a62450ad8d040 (patch)
tree8f5bc37e37479183bc2da284a7444a3b7ac68f8c /tests/test-runner.c
parentcursor/os-compatibility: fix trailing space (diff)
downloadwayland-9434e8d69f76d7859ed7b18edc5a62450ad8d040.tar
wayland-9434e8d69f76d7859ed7b18edc5a62450ad8d040.tar.gz
wayland-9434e8d69f76d7859ed7b18edc5a62450ad8d040.tar.bz2
wayland-9434e8d69f76d7859ed7b18edc5a62450ad8d040.tar.lz
wayland-9434e8d69f76d7859ed7b18edc5a62450ad8d040.tar.xz
wayland-9434e8d69f76d7859ed7b18edc5a62450ad8d040.tar.zst
wayland-9434e8d69f76d7859ed7b18edc5a62450ad8d040.zip
Check that XDG base directories paths are absolute
The [spec][1] reads: > All paths set in these environment variables must be absolute. If an > implementation encounters a relative path in any of these variables it should > consider the path invalid and ignore it. and > If $XDG_DATA_HOME is either not set or empty, a default equal to > $HOME/.local/share should be used. Testing that the path is absolute also entails that is is non-empty. [1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
Diffstat (limited to 'tests/test-runner.c')
-rw-r--r--tests/test-runner.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/test-runner.c b/tests/test-runner.c
index c0247b5..d07dab1 100644
--- a/tests/test-runner.c
+++ b/tests/test-runner.c
@@ -180,7 +180,7 @@ set_xdg_runtime_dir(void)
xrd_env = getenv("XDG_RUNTIME_DIR");
/* if XDG_RUNTIME_DIR is not set in environ, fallback to /tmp */
assert((snprintf(xdg_runtime_dir, PATH_MAX, "%s/wayland-tests-XXXXXX",
- xrd_env ? xrd_env : "/tmp") < PATH_MAX)
+ (xrd_env && xrd_env[0] == '/') ? xrd_env : "/tmp") < PATH_MAX)
&& "test error: XDG_RUNTIME_DIR too long");
assert(mkdtemp(xdg_runtime_dir) && "test error: mkdtemp failed");
@@ -200,7 +200,7 @@ static void
rmdir_xdg_runtime_dir(void)
{
const char *xrd_env = getenv("XDG_RUNTIME_DIR");
- assert(xrd_env && "No XDG_RUNTIME_DIR set");
+ assert(xrd_env && xrd_env[0] == '/' && "No XDG_RUNTIME_DIR set");
/* rmdir may fail if some test didn't do clean up */
if (rmdir(xrd_env) == -1)