From c1ba24ac07ba43e048d0b2fa6c90075a70327687 Mon Sep 17 00:00:00 2001 From: Sebastian Mitterle Date: Mon, 11 Sep 2023 08:54:31 -0400 Subject: [PATCH] startup_policy: fix teardown Remove all files to avoid Permission errors on next test run. Signed-off-by: Sebastian Mitterle --- libvirt/tests/src/virtual_disks/startup_policy.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libvirt/tests/src/virtual_disks/startup_policy.py b/libvirt/tests/src/virtual_disks/startup_policy.py index 5a9069e621..dc3ae6527c 100644 --- a/libvirt/tests/src/virtual_disks/startup_policy.py +++ b/libvirt/tests/src/virtual_disks/startup_policy.py @@ -23,6 +23,7 @@ # Using as lower capital is not the best way to do, but this is just a # workaround to avoid changing the entire file. logging = log.getLogger('avocado.' + __name__) +new_source_file = "" def run(test, params, env): @@ -282,8 +283,10 @@ def update_source_policy(update=True, policy='optional'): :param update: update value or not :param policy: policy value :return: flag_option and boolean value + and new_source_file path """ source_file = policy_item.get('file') + global new_source_file if update: new_source_file = source_file+".empty" else: @@ -518,5 +521,9 @@ def rename_file(source_file, target_file, revert=False): os.remove(disk_xml_file) if os.path.exists(media_file): os.remove(media_file) + if os.path.exists(media_file_new): + os.remove(media_file_new) + if os.path.exists(new_source_file): + os.remove(new_source_file) if os.path.exists(disk_xml_policy_file): os.remove(disk_xml_policy_file)