Skip to content

Commit

Permalink
Reorder the tearDownClass cleanup
Browse files Browse the repository at this point in the history
Fixes an issue where rmtree tries to access and consequently remove
a temp folder where the server has opened a file already.
This results in error:
"PermissionError: [WinError 32] The process cannot access the file
because it is being used by another process"

For reference read:
theupdateframework#1119

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
  • Loading branch information
MVrachev committed Oct 1, 2020
1 parent 2693620 commit e2ccfdb
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
5 changes: 3 additions & 2 deletions tests/test_arbitrary_package_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated of all the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down
5 changes: 3 additions & 2 deletions tests/test_endless_data_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated of all the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down
5 changes: 3 additions & 2 deletions tests/test_extraneous_dependencies_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated of all the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down
5 changes: 3 additions & 2 deletions tests/test_indefinite_freeze_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated of all the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down
5 changes: 3 additions & 2 deletions tests/test_key_revocation_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated for the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down
5 changes: 3 additions & 2 deletions tests/test_mix_and_match_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated of all the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down
5 changes: 3 additions & 2 deletions tests/test_replay_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated of all the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down
5 changes: 3 additions & 2 deletions tests/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated for the test cases
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()


def setUp(self):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_updater_root_rotation_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()

# Remove the temporary repository directory, which should contain all the
# metadata, targets, and key files generated for the test cases.
shutil.rmtree(cls.temporary_directory)

# Kills the server subprocess and closes the temp file used for logging.
cls.server_process_handler.clean()



Expand Down

0 comments on commit e2ccfdb

Please sign in to comment.