From 004121a38daa43189bfdcd57c234cec6f12e8f52 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 5 Sep 2017 09:35:59 -0700 Subject: [PATCH] Upload all logs when AVCs and/or crashes detected Previously we just got a screenshot of some AVCs or coredumps, which told us something was wrong but didn't really help debug it. So, let's upload the output of the commands and then also use the post-fail hook to upload the system logs, which should give us much more info to work with. --- tests/_console_avc_crash.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/_console_avc_crash.pm b/tests/_console_avc_crash.pm index 5eacbd29..1bbea36a 100644 --- a/tests/_console_avc_crash.pm +++ b/tests/_console_avc_crash.pm @@ -15,9 +15,20 @@ sub run { console_loadkeys_us; # check there are no AVCs. We expect an error here: if we don't # get an error, it means there *are* AVCs. - record_soft_failure "AVC(s) found" unless (script_run 'ausearch -m avc -ts yesterday 2>&1'); + my $hook_run = 0; + unless (script_run 'ausearch -m avc -ts yesterday > /tmp/avcs.txt 2>&1') { + record_soft_failure "AVC(s) found (see avcs.txt log)"; + upload_logs "/tmp/avcs.txt"; + # Run the post-fail hook so we have all the logs + $self->post_fail_hook(); + $hook_run = 1; + } # check there are no crashes. Similarly expect an error here - record_soft_failure "Crash(es) found" unless (script_run 'coredumpctl list 2>&1'); + unless (script_run 'coredumpctl list > /tmp/coredumps.txt 2>&1') { + record_soft_failure "Crash(es) found (see coredumps.txt log)"; + upload_logs "/tmp/coredumps.txt"; + $self->post_fail_hook() unless ($hook_run); + } } sub test_flags {