Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: client/bin/base_sysinfo.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cli/job.py ('K') | « client/bin/autotest ('k') | client/bin/harness.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/bin/base_sysinfo.py
diff --git a/client/bin/base_sysinfo.py b/client/bin/base_sysinfo.py
index e58f61bd2d25baf2f843e4dc27352e535aa008ba..7e06f140988793585a3877c2d42da5e1a52aef8c 100644
--- a/client/bin/base_sysinfo.py
+++ b/client/bin/base_sysinfo.py
@@ -78,11 +78,12 @@ class logfile(loggable):
class command(loggable):
- def __init__(self, cmd, logf=None, log_in_keyval=False):
+ def __init__(self, cmd, logf=None, log_in_keyval=False, compress_log=False):
if not logf:
logf = cmd.replace(" ", "_")
super(command, self).__init__(logf, log_in_keyval)
self.cmd = cmd
+ self._compress_log = compress_log
def __repr__(self):
@@ -111,16 +112,21 @@ class command(loggable):
def run(self, logdir):
- stdin = open(os.devnull, "r")
- stdout = open(os.path.join(logdir, self.logf), "w")
- stderr = open(os.devnull, "w")
env = os.environ.copy()
if "PATH" not in env:
env["PATH"] = "/usr/bin:/bin"
- subprocess.call(self.cmd, stdin=stdin, stdout=stdout, stderr=stderr,
- shell=True, env=env)
- for f in (stdin, stdout, stderr):
- f.close()
+ logf_path = os.path.join(logdir, self.logf)
+ stdin = open(os.devnull, "r")
+ stderr = open(os.devnull, "w")
+ stdout = open(logf_path, "w")
+ try:
+ subprocess.call(self.cmd, stdin=stdin, stdout=stdout, stderr=stderr,
+ shell=True, env=env)
+ finally:
+ for f in (stdin, stdout, stderr):
+ f.close()
+ if self._compress_log and os.path.exists(logf_path):
+ utils.system('gzip -9 "%s"' % logf_path, ignore_status=True)
class base_sysinfo(object):
@@ -161,7 +167,11 @@ class base_sysinfo(object):
# add in a couple of extra files and commands we want to grab
self.test_loggables.add(command("df -mP", logf="df"))
- self.test_loggables.add(command("dmesg -c", logf="dmesg"))
+ # We compress the dmesg because it can get large when kernels are
+ # configured with a large buffer and some tests trigger OOMs or
+ # other large "spam" that fill it up...
+ self.test_loggables.add(command("dmesg -c", logf="dmesg",
+ compress_log=True))
self.boot_loggables.add(logfile("/proc/cmdline",
log_in_keyval=True))
# log /proc/mounts but with custom filename since we already
« cli/job.py ('K') | « client/bin/autotest ('k') | client/bin/harness.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698