]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use XDG_STATE_HOME for %S and %L
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 Jul 2023 07:07:58 +0000 (16:07 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 20 Jul 2023 11:54:54 +0000 (12:54 +0100)
This fixes the test failure when invoked by a user.
===
Running ./systemd-tmpfiles --user on 'f /tmp/test-systemd-tmpfiles.1foag_ur/test-content.n_9r_xhm/arg - - - - %S'
expect: '/home/watanabe/.config'
actual: '/home/watanabe/.local/state'
Traceback (most recent call last):
  File "/home/watanabe/git/systemd/test/test-systemd-tmpfiles.py", line 233, in <module>
    test_valid_specifiers(user=True)
  File "/home/watanabe/git/systemd/test/test-systemd-tmpfiles.py", line 135, in test_valid_specifiers
    test_content('f {} - - - - %S',
  File "/home/watanabe/git/systemd/test/test-systemd-tmpfiles.py", line 88, in test_content
    assert content == expected
           ^^^^^^^^^^^^^^^^^^^
AssertionError
===

This also makes the test uses fallback paths.

Follow-up for b50aadaff22f9b3ad3bbcbfd2edd661456a5b4bf.

test/test-systemd-tmpfiles.py

index 369478d31edc0c10b0eca33509d6f2f1c9e39792..77ef53b9839d4ec904c38beb57f64ed2100f8aee 100755 (executable)
@@ -130,22 +130,23 @@ def test_valid_specifiers(*, user):
                      xdg_runtime_dir if user else '/run',
                      user=user)
 
-    xdg_config_home = os.getenv('XDG_CONFIG_HOME')
-    if xdg_config_home is not None or not user:
-        test_content('f {} - - - - %S',
-                     xdg_config_home if user else '/var/lib',
-                     user=user)
+    xdg_state_home = os.getenv('XDG_STATE_HOME')
+    if xdg_state_home is None and user:
+        xdg_state_home = os.path.join(home, ".local/state")
+    test_content('f {} - - - - %S',
+                 xdg_state_home if user else '/var/lib',
+                 user=user)
 
     xdg_cache_home = os.getenv('XDG_CACHE_HOME')
-    if xdg_cache_home is not None or not user:
-        test_content('f {} - - - - %C',
-                     xdg_cache_home if user else '/var/cache',
-                     user=user)
-
-    if xdg_config_home is not None or not user:
-        test_content('f {} - - - - %L',
-                     xdg_config_home + '/log' if user else '/var/log',
-                     user=user)
+    if xdg_cache_home is None and user:
+        xdg_cache_home = os.path.join(home, ".cache")
+    test_content('f {} - - - - %C',
+                 xdg_cache_home if user else '/var/cache',
+                 user=user)
+
+    test_content('f {} - - - - %L',
+                 os.path.join(xdg_state_home, 'log') if user else '/var/log',
+                 user=user)
 
     test_content('f {} - - - - %%', '%', user=user)