Author: gtjoseph Date: Fri Nov 21 11:36:30 2014 New Revision: 5986 URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5986 Log: testsuite: Add --cleanup option to runtests.py
This patch adds the -c,--cleanup option to runtests.py. If set, a test's output/root directory and symlink will be removed after successful completion. If the test fails or times out, the directory is left in place. This helps keep /tmp and /var/tmp from running out of space or inodes. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4198/ Modified: asterisk/trunk/runtests.py Modified: asterisk/trunk/runtests.py URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=5986&r1=5985&r2=5986 ============================================================================== --- asterisk/trunk/runtests.py (original) +++ asterisk/trunk/runtests.py Fri Nov 21 11:36:30 2014 @@ -49,6 +49,7 @@ self.__check_can_run(ast_version) self.stdout = "" self.timeout = timeout + self.cleanup = options.cleanup assert self.test_name.startswith('tests/') self.test_relpath = self.test_name[6:] @@ -114,6 +115,16 @@ if not self.passed: self._archive_logs() + elif self.cleanup: + try: + (run_num, run_dir, archive_dir) = self._find_run_dirs() + symlink_dir = os.path.dirname(run_dir) + absolute_dir = os.path.join(os.path.dirname(symlink_dir), os.readlink(symlink_dir)) + shutil.rmtree(absolute_dir) + os.remove(symlink_dir) + except: + print "Unable to clean up directory for test %s (non-fatal)" % self.test_name + print 'Test %s %s\n' % (cmd, 'timedout' if timedout else 'passed' if self.passed else 'failed') else: @@ -530,6 +541,9 @@ parser.add_option("-V", "--valgrind", action="store_true", dest="valgrind", default=False, help="Run Asterisk under Valgrind") + parser.add_option("-c", "--cleanup", action="store_true", + dest="cleanup", default=False, + help="Cleanup tmp directory after each successful test") (options, args) = parser.parse_args(argv) ast_version = AsteriskVersion(options.version) -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits
