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

Unified Diff: server/site_tests/logging_KernelCrashServer/logging_KernelCrashServer.py

Issue 3454023: autotest: Test new meta files in crash directory (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Fix bug Created 10 years, 3 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
« no previous file with comments | « server/site_host_attributes.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: server/site_tests/logging_KernelCrashServer/logging_KernelCrashServer.py
diff --git a/server/site_tests/logging_KernelCrashServer/logging_KernelCrashServer.py b/server/site_tests/logging_KernelCrashServer/logging_KernelCrashServer.py
index d139d06a24993ecbb0947ec464f94e0faf980afb..1414ac645771caf50c0d511b30c1d5d2f40b0945 100644
--- a/server/site_tests/logging_KernelCrashServer/logging_KernelCrashServer.py
+++ b/server/site_tests/logging_KernelCrashServer/logging_KernelCrashServer.py
@@ -6,28 +6,82 @@ import logging, os, shutil, time
from autotest_lib.client.common_lib import error
from autotest_lib.server import autotest, site_host_attributes, test
+_CONSENT_FILE = '/home/chronos/Consent To Send Stats'
+_STOWED_CONSENT_FILE = '/var/lib/kernel-crash-server.consent'
+
class logging_KernelCrashServer(test.test):
version = 1
+ def _exact_copy(self, source, dest):
+ """Copy remote source to dest removing dest if source does not exist."""
petkov 2010/09/30 05:29:27 I don't quite understand the comment -- you always
+ self._host.run('rm -f "%s"; cp "%s" "%s" 2>/dev/null; true' %
+ (dest, source, dest))
+
+
+ def cleanup(self):
+ self._exact_copy(_STOWED_CONSENT_FILE, _CONSENT_FILE)
+ test.test.cleanup(self)
+
+
+ def _can_disable_consent(self):
+ """Returns whether or not host can have consent disabled.
+
+ Presence of /etc/send_metrics causes ui.conf job (which starts
+ after chromeos_startup) to regenerate a consent file if one
+ does not exist. Therefore, we cannot guarantee that
+ crash-reporter.conf will start with the file gone if we
+ removed it before causing a crash.
+ """
+ status = self._host.run('[ -r /etc/send_metrics ]', ignore_status=True)
+ return status.exit_status != 0
+
+
+ def _crash_it(self, consent):
+ """Crash the host after setting the consent as given."""
+ if consent:
+ self._host.run('echo test-consent > "%s"' % _CONSENT_FILE)
+ else:
+ self._host.run('rm -f "%s"' % _CONSENT_FILE)
+ logging.info('KernelCrashServer: crashing %s' % self._host.hostname)
+ boot_id = self._host.get_boot_id()
+ self._host.run(
+ 'sh -c "sync; sleep 1; echo bug > /proc/breakme" >/dev/null 2>&1 &')
+ self._host.wait_for_restart(old_boot_id=boot_id)
+
+
def run_once(self, host=None):
+ self._host = host
+ client_attributes = site_host_attributes.HostAttributes(host.hostname)
client_at = autotest.Autotest(host)
+ self._exact_copy(_CONSENT_FILE, _STOWED_CONSENT_FILE)
+
client_at.run_test('logging_KernelCrash',
tag='before-crash',
- is_before=True)
+ is_before=True,
+ consent=True)
- client_attributes = site_host_attributes.HostAttributes(host.hostname)
if not client_attributes.has_working_kcrash:
raise error.TestNAError(
'This device is unable to report kernel crashes')
- # Crash the client
- logging.info('KernelCrashServer: crashing %s' % host.hostname)
- boot_id = host.get_boot_id()
- host.run('sh -c "sleep 1; echo bug > /proc/breakme" >/dev/null 2>&1 &')
- host.wait_for_restart(old_boot_id=boot_id)
- # Check for crash handling
+ self._crash_it(True)
+
+ # Check for crash handling with consent.
client_at.run_test('logging_KernelCrash',
- tag='after-crash',
- is_before=False)
+ tag='after-crash-consent',
+ is_before=False,
+ consent=True)
+
+ if not self._can_disable_consent():
+ logging.info('This device always has metrics enabled, '
+ 'skipping test of metrics disabled mode.')
+ else:
+ self._crash_it(False)
+
+ # Check for crash handling without consent.
+ client_at.run_test('logging_KernelCrash',
+ tag='after-crash-no-consent',
+ is_before=False,
+ consent=False)
« no previous file with comments | « server/site_host_attributes.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698