autotest: Remove existing autoserv dirs on startup
While server tests, when run normally, will clean up their temporary
installation and some large output directories, the same is not true
when a user uses ctrl-c to force-close the test.
This change modifies server tests to remove existing /tmp/autoserv-* and
/tmp/sysinfo/autoserv-* directories before creating new ones, such that
existing left-over directories will not cause a DUT's /tmp filesystem to
run out of space.
BUG=chromium:863601
TEST=Ran server tests to completion, ran a modified server test with
a syntax error, and interrupted running server tests with SIGINT.
The first two cases remain unchanged, as the test framework
performed cleanup as expected. Ensured that the third test case was
actually triggering a cleanup.
TEST=Used get_tmp_dir to create multiple temp dirs, including a set of
nested temporary directories. Then alternated between printing
self.tmp_dirs and calling delete_all_tmp_dirs with various parent
directories to ensure the expected behavior was occuring both on
the host and with regards to the contents of self.tmp_dirs.
Change-Id: I82a1619d4c8976547792f3cac84b6ed41148b484
Reviewed-on: https://chromium-review.googlesource.com/1147500
Commit-Ready: Alex Khouderchah <[email protected]>
Tested-by: Alex Khouderchah <[email protected]>
Reviewed-by: Richard Barnette <[email protected]>
diff --git a/server/test.py b/server/test.py
index f1b1873..99d155f 100644
--- a/server/test.py
+++ b/server/test.py
@@ -84,6 +84,9 @@
class _sysinfo_logger(object):
+ AUTOTEST_PARENT_DIR = '/tmp/sysinfo'
+ OUTPUT_PARENT_DIR = '/tmp'
+
def __init__(self, job):
self.job = job
self.pickle = None
@@ -109,10 +112,14 @@
if not self.host.is_client_install_supported:
return self.host, None, None
try:
- tmp_dir = self.host.get_tmp_dir(parent="/tmp/sysinfo")
+ # Remove existing autoserv-* directories before creating more
+ self.host.delete_all_tmp_dirs(self.AUTOTEST_PARENT_DIR)
+ self.host.delete_all_tmp_dirs(self.OUTPUT_PARENT_DIR)
+
+ tmp_dir = self.host.get_tmp_dir(self.AUTOTEST_PARENT_DIR)
self.autotest = autotest.Autotest(self.host)
self.autotest.install(autodir=tmp_dir)
- self.outputdir = self.host.get_tmp_dir()
+ self.outputdir = self.host.get_tmp_dir(self.OUTPUT_PARENT_DIR)
except:
# if installation fails roll back the host
try: