]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests/999: tidy config writes and stress paths
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sun, 15 Mar 2026 05:32:56 +0000 (11:02 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 19 Mar 2026 17:30:52 +0000 (11:30 -0600)
Systemd.write_config_with_pid() now writes the temporary config inside a
context manager so the file descriptor is always closed. The 999-stress
helper switched to os.path.join(), which automatically uses the right
separator, makes the intent clearer than manual '/' concatenation, and
guards future edits from producing malformed paths.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/ftests/999-stress-cgroup_init.py

index 15982905441f2b147a455a0d0e40526fcdcf0782..13a97dbf3f780542bfe434ef5d8c990c91192139 100755 (executable)
@@ -17,13 +17,13 @@ import sys
 import os
 
 MNT_COUNT = 101
-MNT_POINT = '/tmp/'
+MNT_ROOT = '/tmp'
 DIR_PREFIX = 'name'
 RANDOM_DIR = ''.join(random.choices(string.ascii_letters, k=5)) + '-999stress'
 
 
 def cgroup_path(count):
-    return MNT_POINT + RANDOM_DIR + '/' + DIR_PREFIX + str(count)
+    return os.path.join(MNT_ROOT, RANDOM_DIR, '{}{}'.format(DIR_PREFIX, count))
 
 
 def prereqs(config):
@@ -33,7 +33,7 @@ def prereqs(config):
 def setup(config):
     cmd = ['sudo', 'mkdir']
 
-    cmd.append(MNT_POINT + RANDOM_DIR)
+    cmd.append(os.path.join(MNT_ROOT, RANDOM_DIR))
 
     for count in range(MNT_COUNT):
         cmd.append(cgroup_path(count))
@@ -76,7 +76,7 @@ def teardown(config):
     for count in range(MNT_COUNT):
         cmd.append(cgroup_path(count))
 
-    cmd.append(MNT_POINT + RANDOM_DIR)
+    cmd.append(os.path.join(MNT_ROOT, RANDOM_DIR))
 
     # execute rmdir top-level top-level/sub-directory* at once.
     Run.run(cmd)