From: Kamalesh Babulal Date: Tue, 19 Jul 2022 20:50:17 +0000 (-0600) Subject: test-019: fix issues on unsuccessful no-container runs X-Git-Tag: v2.0.3~11^2^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfb2a82daf5d0651eee5b0a4506d57486605b8be;p=thirdparty%2Flibcgroup.git test-019: fix issues on unsuccessful no-container runs 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 Signed-off-by: Tom Hromatka (cherry picked from commit 59260dfeec1753540fd9ddccc0515aa0ddf2d6ed) --- diff --git a/ftests/019-cgconfig-uidgid_dperm_fperm.py b/ftests/019-cgconfig-uidgid_dperm_fperm.py index cd6c9dcb..67ac6225 100755 --- a/ftests/019-cgconfig-uidgid_dperm_fperm.py +++ b/ftests/019-cgconfig-uidgid_dperm_fperm.py @@ -60,7 +60,7 @@ def setup(config): config.container.run(['groupadd', GROUP]) else: Run.run(['sudo', 'useradd', '-p', 'Test019#1', USER]) - Run.run(['sudo', 'groupadd', GROUP]) + Run.run(['sudo', 'groupadd', '-f', GROUP]) def test(config): result = consts.TEST_PASSED @@ -111,7 +111,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