]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
test-020: fix issues on unsuccessful no-container runs
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 19 Jul 2022 20:50:31 +0000 (14:50 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 19 Jul 2022 20:50:34 +0000 (14:50 -0600)
Running the test with --no-container, might cause an issue with useradd
or groupadd command if the home directory of the test user exists/test
user group exists.

The home directory of the user doesn't get removed by default on all
distros, so explicitly pass the '-r' flag to userdel to remove the
directory.  Whereas user group might exist due to unsuccessful test
runs, address it by passing '-f' flags to groupadd command, that
returns success even if the group exists, that will be removed
by the groupdel command at the exit.

This is not an issue with containers test cases, because they are
created and destroyed for every test case execution.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit e650f509840c4134a706e6600e3b909be07b249b)

ftests/020-cgconfig-tasks_perms_owner.py

index b4d22c0e0a35fb00c52b413d65f4985b60ef6b24..928258c3653653468f48c9f5ed8f2c2af681d7ed 100755 (executable)
@@ -64,7 +64,7 @@ def setup(config):
         config.container.run(['groupadd', GROUP])
     else:
         Run.run(['sudo', 'useradd', '-p', 'Test020#1', USER])
-        Run.run(['sudo', 'groupadd', GROUP])
+        Run.run(['sudo', 'groupadd', '-f', GROUP])
 
 def test(config):
     result = consts.TEST_PASSED
@@ -108,7 +108,7 @@ def teardown(config):
             config.container.run(['userdel', USER])
             config.container.run(['groupdel', GROUP])
         else:
-            Run.run(['sudo', 'userdel', USER])
+            Run.run(['sudo', 'userdel', '-r', USER])
             Run.run(['sudo', 'groupdel', GROUP])
     except:
         pass