[ABRT PATCH] testsuite: added test for abrt-harvest-vmcore
by Petr Kubat
Signed-off-by: Petr Kubat <pkubat(a)redhat.com>
---
tests/runtests/aux/test_order | 1 +
tests/runtests/aux/test_order.rhel7 | 1 +
tests/runtests/kernel-vmcore-harvest/PURPOSE | 3 ++
tests/runtests/kernel-vmcore-harvest/runtest.sh | 61 +++++++++++++++++++++++++
4 files changed, 66 insertions(+)
create mode 100644 tests/runtests/kernel-vmcore-harvest/PURPOSE
create mode 100755 tests/runtests/kernel-vmcore-harvest/runtest.sh
diff --git a/tests/runtests/aux/test_order b/tests/runtests/aux/test_order
index 8c1880e..fd7a4c7 100644
--- a/tests/runtests/aux/test_order
+++ b/tests/runtests/aux/test_order
@@ -33,6 +33,7 @@ dbus-elements-handling
bodhi
oops-processing
abrt-python
+kernel-vmcore-harvest
# - reporting tests
bugzilla-bt-reattach
diff --git a/tests/runtests/aux/test_order.rhel7 b/tests/runtests/aux/test_order.rhel7
index 4d6ccb0..283ea55 100644
--- a/tests/runtests/aux/test_order.rhel7
+++ b/tests/runtests/aux/test_order.rhel7
@@ -33,6 +33,7 @@ dbus-elements-handling
#bodhi
oops-processing
abrt-python
+kernel-vmcore-harvest
# - reporting tests
bugzilla-bt-reattach
diff --git a/tests/runtests/kernel-vmcore-harvest/PURPOSE b/tests/runtests/kernel-vmcore-harvest/PURPOSE
new file mode 100644
index 0000000..378259a
--- /dev/null
+++ b/tests/runtests/kernel-vmcore-harvest/PURPOSE
@@ -0,0 +1,3 @@
+PURPOSE of kernel-vmcore-harvest
+Description: Tests moving kernel core dumps at startup
+Author: Petr Kubat <pkubat(a)redhat.com>
diff --git a/tests/runtests/kernel-vmcore-harvest/runtest.sh b/tests/runtests/kernel-vmcore-harvest/runtest.sh
new file mode 100755
index 0000000..cbc029b
--- /dev/null
+++ b/tests/runtests/kernel-vmcore-harvest/runtest.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of kernel-vmcore-harvest
+# Description: Tests moving kernel core dumps at startup
+# Author: Petr Kubat <pkubat(a)redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+. /usr/share/beakerlib/beakerlib.sh
+. ../aux/lib.sh
+
+TEST="kernel-vmcore-harvest"
+PACKAGE="abrt"
+REQUIRED_FILES="analyzer architecture component
+last_occurrence os_info os_release time type uid uuid vmcore"
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlShowRunningKernel
+ load_abrt_conf
+ rlPhaseEnd
+
+ rlPhaseStartTest
+ rlRun "mkdir /var/crash/test" 0 "Creating vmcore dir"
+ rlRun "echo testing > /var/crash/test/vmcore" 0 "Creating vmcore"
+ rlLogInfo "Restarting abrtd"
+ systemctl restart abrtd.service
+ rlLogInfo "Wait 1s for abrtd to finish checking vmcores"
+ sleep 1s
+ rlAssertExists "${ABRT_CONF_DUMP_LOCATION}/vmcore-test"
+ rlAssertExists "${ABRT_CONF_DUMP_LOCATION}/vmcore-test/analyzer"
+ for f in $REQUIRED_FILES; do
+ rlAssertExists "${ABRT_CONF_DUMP_LOCATION}/vmcore-test/$f"
+ done
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ rlRun "rm -rf /var/crash/test" 0 "Removing vmcore from /var/crash/"
+ rlRun "rm -rf ${ABRT_CONF_DUMP_LOCATION}/vmcore-test" 0 "Removing vmcore from the abrt dump location"
+ rlPhaseEnd
+ rlJournalPrintText
+rlJournalEnd
--
1.8.3.1
10 years, 9 months
[LIBREPORT PATCH] report-gtk: use wrapped text for warning labels
by Jakub Filak
Warning texts were designed to fit into window size but their width
depends on used font properties. Therefore we have to make text
wrapped in order to not resize window.
Closes rhbz#895745
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gui-wizard-gtk/wizard.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 9ddf076..2677700 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1976,6 +1976,7 @@ static void add_warning(const char *warning)
gtk_misc_set_alignment(GTK_MISC(warning_lbl), 0.0, 0.0);
gtk_label_set_justify(GTK_LABEL(warning_lbl), GTK_JUSTIFY_LEFT);
+ gtk_label_set_line_wrap(GTK_LABEL(warning_lbl), TRUE);
gtk_box_pack_start(g_box_warning_labels, warning_lbl, false, false, 0);
gtk_widget_show(warning_lbl);
}
--
1.8.3.1
10 years, 9 months
[ABRT PATCH] rewrite shell script for moving vmcores into python closes #676
by Petr Kubat
Signed-off-by: Petr Kubat <pkubat(a)redhat.com>
---
src/hooks/Makefile.am | 4 +-
src/hooks/abrt-harvest-vmcore.in | 82 -----------------
src/hooks/abrt_harvest_vmcore.py.in | 174 ++++++++++++++++++++++++++++++++++++
3 files changed, 176 insertions(+), 84 deletions(-)
delete mode 100644 src/hooks/abrt-harvest-vmcore.in
create mode 100644 src/hooks/abrt_harvest_vmcore.py.in
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index de97a88..dfa791c 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -60,7 +60,7 @@ pyhook_PYTHON = \
EXTRA_DIST = abrt_exception_handler.py.in \
abrt-install-ccpp-hook.in \
- abrt-harvest-vmcore.in \
+ abrt_harvest_vmcore.py.in \
abrt-harvest-uefioops.in
CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir $(wildcard \.\#*)) $(notdir $(wildcard *.pyc)) $(man1_MANS)
@@ -85,7 +85,7 @@ abrt-install-ccpp-hook: abrt-install-ccpp-hook.in
-e s,\@libexecdir\@,$(libexecdir),g \
$< >$@
-abrt-harvest-vmcore: abrt-harvest-vmcore.in
+abrt-harvest-vmcore: abrt_harvest_vmcore.py.in
sed -e s,\@CONF_DIR\@,\$(CONF_DIR)\,g \
-e s,\@DEFAULT_DUMP_LOCATION\@,$(DEFAULT_DUMP_LOCATION),g \
$< >$@
diff --git a/src/hooks/abrt-harvest-vmcore.in b/src/hooks/abrt-harvest-vmcore.in
deleted file mode 100644
index a9ed1a2..0000000
--- a/src/hooks/abrt-harvest-vmcore.in
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-#
-# This script is meant to be run once at system startup after abrtd is up
-# and running. It moves all vmcore directories in /var/crash
-# (which are presumably created by kdump) to abrtd spool directory.
-#
-# The goal is to let abrtd notice and process them as new problem data dirs.
-#
-
-cd /var/crash 2>/dev/null || exit 0
-
-# Wait for abrtd to start. Give it at least 1 second to initialize.
-i=10
-while ! pidof abrtd >/dev/null; do
- if test $((i--)) = 0; then
- exit 1
- fi
- sleep 1
-done
-sleep 1
-
-umask 077
-
-CopyVMcore=`sed -n '/^CopyVMcore[ \t]*=/ s/.*=[ \t]*//p' @CONF_DIR(a)/abrt-harvest-vmcore.conf 2>/dev/null`
-ABRTDumpDir=`sed -n '/^DumpLocation[ \t]*=/ s/.*=[ \t]*//p' @CONF_DIR(a)/abrt.conf 2>/dev/null`
-
-if test -z "$ABRTDumpDir"; then
- ABRTDumpDir="@DEFAULT_DUMP_LOCATION@"
-fi
-
-move_core=false
-if test x"$CopyVMcore" = x"no" || test x"$CopyVMcore" = x"0"; then
- move_core=true
-fi
-
-for d in *; do
- test -d "$d" || continue
- test -f "$d/vmcore" || continue
-
- dst="$ABRTDumpDir/vmcore-$d"
-
- # Did we already copy it last time we booted?
- test -d "$dst" && continue
- test -d "$dst.new" && continue
-
- # Copy/move vmcore directory to abrt spool dir.
- # We use .new suffix - we must make sure abrtd doesn't try
- # to process partially-copied directory.
- #
- # This is the efficient way:
- #mv -- "$d" "/var/tmp/abrt/vmcore-$d.new" || continue
- # ...and this is what selinux forces me to do
- # (otherwise files have wrong context and abrtd can't access them):
- cp -r --no-preserve=all -- "$d" "$dst.new" || {
- rm -rf -- "$dst.new"
- continue
- }
- $move_core && rm -rf -- "$d"
-
- # Let abrtd know what type of problem it is:
- printf 'vmcore' >"$dst.new/analyzer"
- printf 'vmcore' >"$dst.new/type"
- printf 'kernel' >"$dst.new/component"
- printf '%s' "`date '+%s'`" >"$dst.new/time"
- printf '%s' "`uname -i`" >"$dst.new/architecture"
- cp "$dst.new/time" "$dst.new/last_occurrence"
- printf '0' >"$dst.new/uid"
- # TODO: need to generate *real* UUID,
- # one which has a real chance of catching dups!
- # This one generates different hashes even for similar cores:
- printf '%s' "`sha1sum <"$dst.new/vmcore" | cut -d" " -f1`" >"$dst.new/uuid"
- cp /etc/system-release "$dst.new/os_release" || {
- cp /etc/redhat-release "$dst.new/os_release" || {
- cp /etc/SuSE-release "$dst.new/os_release"
- }
- }
- cp /etc/os-release "$dst.new/os_info"
-
- chown -R 0:0 -- "$dst.new"
- chmod -R u+rwX,go-rwxst -- "$dst.new"
- mv -- "$dst.new" "$dst"
-done
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
new file mode 100644
index 0000000..15e6d7c
--- /dev/null
+++ b/src/hooks/abrt_harvest_vmcore.py.in
@@ -0,0 +1,174 @@
+#!/usr/bin/python
+"""
+ This script is meant to be run once at system startup after abrtd is up
+ and running. It moves all vmcore directories in /var/crash
+ (which are presumably created by kdump) to abrtd spool directory.
+
+ The goal is to let abrtd notice and process them as new problem data dirs.
+"""
+
+import os
+import ConfigParser
+import StringIO
+import shutil
+import time
+import hashlib
+
+#Path to the vmcore directories
+CORE_DIR = '/var/crash'
+
+def write_to_file(path, content):
+ """
+ A function for writing into a file
+
+ path - path to the file
+ content - content to write into the file
+ """
+
+ with open(path, 'w') as wfile:
+ wfile.write(content)
+
+def change_owner_rec(dest):
+ """
+ A simple function to recursively change file mode for a directory.
+
+ dest - path to the directory
+ """
+
+ os.chown(dest, 0, 0)
+ for root, dirs, files in os.walk(dest):
+ for i in dirs:
+ os.chown(os.path.join(root, i), 0, 0)
+ for i in files:
+ os.chown(os.path.join(root, i), 0, 0)
+
+def change_mode_rec(dest):
+ """
+ A simple function to recursively change file mode for a directory.
+
+ dest - path to the directory
+ """
+
+ os.chmod(dest, 0700)
+ for root, dirs, files in os.walk(dest):
+ for i in dirs:
+ os.chmod(os.path.join(root, i), 0700)
+ for i in files:
+ os.chmod(os.path.join(root, i), 0600)
+
+def create_abrtd_info(dest):
+ """
+ A simple function to write important information for the abrt daemon into
+ the vmcore directory to let abrtd know what kind of problem it is.
+
+ dest - path to the vmcore directory
+ """
+ write_to_file(os.path.join(dest, "analyzer"), 'vmcore')
+ write_to_file(os.path.join(dest, "type"), 'vmcore')
+ write_to_file(os.path.join(dest, "component"), 'kernel')
+ write_to_file(os.path.join(dest, "time"), str(time.time()).split('.')[0])
+ shutil.copy(os.path.join(dest, "time"),
+ os.path.join(dest, "last_occurrence"))
+ write_to_file(os.path.join(dest, "architecture"), os.uname()[4])
+ write_to_file(os.path.join(dest, "uid"), '0')
+
+ # TODO: need to generate *real* UUID,
+ # one which has a real chance of catching dups!
+ # This one generates different hashes even for similar cores:
+ hashobj = hashlib.sha1()
+ #Iterate over the file a line at a time in order to not load the whole
+ #vmcore file
+ with open(os.path.join(dest, "vmcore"), 'r') as corefile:
+ for line in corefile:
+ hashobj.update(line)
+ write_to_file(os.path.join(dest, "uuid"), hashobj.hexdigest())
+
+ #Write os info into the vmcore directory
+ if os.path.exists('/etc/system-release'):
+ shutil.copy('/etc/system-release', os.path.join(dest, "os_release"))
+ elif os.path.exists('/etc/redhat-release'):
+ shutil.copy('/etc/redhat-release', os.path.join(dest, "os_release"))
+ elif os.path.exists('/etc/SuSE-release'):
+ shutil.copy('/etc/SuSE-release', os.path.join(dest, "os_release"))
+ if os.path.exists('/etc/os-release'):
+ shutil.copy('/etc/system-release', os.path.join(dest, "os_info"))
+
+def harvest_vmcore():
+ """
+ This function moves vmcore directories from /var/crash to a dump dir.
+
+ The script also creates additional files used to tell abrt what kind of
+ problem it is and creates an uuid from the vmcore using a sha1 hash
+ function.
+ """
+
+ if not os.path.exists('/etc/os-release'):
+ exit(0)
+
+ # Wait for abrtd to start. Give it at least 1 second to initialize.
+ for i in xrange(10):
+ if i is 9:
+ exit(1)
+ elif os.system('pidof abrtd >/dev/null'):
+ time.sleep(1)
+ else:
+ break
+
+ os.umask(077)
+
+ #Check abrt config files for copy/move settings and
+ config = ConfigParser.ConfigParser()
+ #We need to add a root section as ConfigParser doesn't know how to work
+ #with config files without any sections
+ with open('@CONF_DIR(a)/abrt-harvest-vmcore.conf') as conf_file:
+ conf_str = '[section]\n' + conf_file.read()
+ conf_fp = StringIO.StringIO(conf_str)
+ config.readfp(conf_fp)
+ copyvmcore = config.get('section', 'CopyVMcore')
+ with open('@CONF_DIR(a)/abrt.conf') as conf_file:
+ conf_str = '[section]\n' + conf_file.read()
+ conf_fp = StringIO.StringIO(conf_str)
+ config = ConfigParser.ConfigParser()
+ config.readfp(conf_fp)
+ try:
+ abrtdumpdir = config.get('section', 'DumpLocation')
+ except ConfigParser.NoOptionError:
+ abrtdumpdir = '@DEFAULT_DUMP_LOCATION@'
+
+ #Go through all directories in /var/crash
+ for cfile in os.listdir(CORE_DIR):
+ f_full = os.path.join(CORE_DIR, cfile)
+ if not os.path.isdir(f_full):
+ continue
+ files = [ ff for ff in os.listdir(f_full)
+ if os.path.isfile(os.path.join(f_full,ff)) ]
+ if 'vmcore' not in files:
+ continue
+
+ destdir = os.path.join(abrtdumpdir, ('vmcore-' + cfile))
+ destdirnew = destdir + '.new'
+ # Did we already copy it last time we booted?
+ if os.path.isdir(destdir):
+ continue
+ if os.path.isdir(destdirnew):
+ continue
+ # Copy/move vmcore directory to abrt spool dir.
+ # We use .new suffix - we must make sure abrtd doesn't try
+ # to process partially-copied directory.
+ shutil.copytree(f_full, destdirnew)
+ if copyvmcore == 'no':
+ shutil.rmtree(f_full)
+
+ # Let abrtd know what type of problem it is:
+ create_abrtd_info(destdirnew)
+
+ #chown -R 0:0
+ change_owner_rec(destdirnew)
+ #chmod -R u+rwX,go-rwxst
+ change_mode_rec(destdirnew)
+
+ #Get rid of the .new suffix
+ shutil.move(destdirnew, destdir)
+
+if __name__ == '__main__':
+ harvest_vmcore()
--
1.8.3.1
10 years, 9 months
[ABRT PATCH] abrtd: ensure that the dump location directory exists
by Jakub Filak
Not sure what is the plan for ticket #657 but I think that abrtd must
ensure that dump location directory exists. abrtd will use inotify until
we find a better solution.
This feature was added in commit
79ab220934b8e593922bda3eb1450d11584d00b3 and accidentally disabled in
commit d37f500e3954e95de20c18c373e3a664d7f55d8d
This commit fixes broken test abrtd-directories
Related to #657
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/daemon/abrtd.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index 5586953..2af55a5 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -41,7 +41,7 @@
/* Maximum number of simultaneously opened client connections. */
#define MAX_CLIENT_COUNT 10
-#define IN_DUMP_LOCATION_FLAGS (IN_CREATE | IN_MOVED_TO | IN_DELETE_SELF | IN_MOVE_SELF)
+#define IN_DUMP_LOCATION_FLAGS (IN_DELETE_SELF | IN_MOVE_SELF)
/* Daemon initializes, then sits in glib main loop, waiting for events.
* Events can be:
@@ -724,8 +724,7 @@ int main(int argc, char** argv)
perror_msg_and_die("inotify_init failed");
close_on_exec_on(inotify_fd);
-#if 0
- /* Watching 'g_settings_dump_location' for new files and delete self
+ /* Watching 'g_settings_dump_location' for delete self
* because hooks expects that the dump location exists if abrtd is running
*/
if (inotify_add_watch(inotify_fd, g_settings_dump_location, IN_DUMP_LOCATION_FLAGS) < 0)
@@ -733,7 +732,6 @@ int main(int argc, char** argv)
perror_msg("inotify_add_watch failed on '%s'", g_settings_dump_location);
goto init_error;
}
-#endif
/* ...and upload dir */
if (g_settings_sWatchCrashdumpArchiveDir)
{
--
1.8.3.1
10 years, 9 months
[SATYR PATCH 1/6] tests: refactor some common code
by Martin Milata
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
.gitignore | 1 +
tests/python/gdb.py | 15 +++------------
tests/python/java.py | 12 ++----------
tests/python/koops.py | 7 +------
tests/python/metrics.py | 8 +-------
tests/python/python.py | 13 ++-----------
tests/python/test_helpers.py | 11 +++++++++++
7 files changed, 21 insertions(+), 46 deletions(-)
diff --git a/.gitignore b/.gitignore
index ae69aa9..cbcf307 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,3 +51,4 @@ satyr.1
/tests/testsuite
/tests/testsuite.log
/tests/testsuite.dir
+/tests/python/test_helpers.pyc
diff --git a/tests/python/gdb.py b/tests/python/gdb.py
index fdc61a6..f271fe0 100755
--- a/tests/python/gdb.py
+++ b/tests/python/gdb.py
@@ -1,13 +1,7 @@
#!/usr/bin/env python
import unittest
-from test_helpers import BindingsTestCase, load_input_contents
-
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
-
+from test_helpers import *
contents = load_input_contents('../gdb_stacktraces/rhbz-803600')
threads_expected = 2
@@ -24,14 +18,11 @@ class TestGdbStacktrace(BindingsTestCase):
def setUp(self):
self.trace = satyr.GdbStacktrace(contents)
- def frame_count(self, trace):
- return sum(map(lambda x: len(x.frames), trace.threads))
-
def test_correct_thread_count(self):
self.assertEqual(len(self.trace.threads), threads_expected)
def test_correct_frame_count(self):
- self.assertEqual(self.frame_count(self.trace), frames_expected)
+ self.assertEqual(frame_count(self.trace), frames_expected)
def test_dup(self):
dup = self.trace.dup()
@@ -52,7 +43,7 @@ class TestGdbStacktrace(BindingsTestCase):
def test_normalize(self):
dup = self.trace.dup()
dup.normalize()
- self.assertNotEqual(self.frame_count(dup), self.frame_count(self.trace))
+ self.assertNotEqual(frame_count(dup), frame_count(self.trace))
def test_str(self):
out = str(self.trace)
diff --git a/tests/python/java.py b/tests/python/java.py
index eaa3d48..0bed791 100755
--- a/tests/python/java.py
+++ b/tests/python/java.py
@@ -1,12 +1,7 @@
#!/usr/bin/env python
import unittest
-from test_helpers import BindingsTestCase, load_input_contents
-
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
contents = load_input_contents('../java_stacktraces/java-02')
threads_expected = 1
@@ -25,14 +20,11 @@ class TestJavaStacktrace(BindingsTestCase):
def setUp(self):
self.trace = satyr.JavaStacktrace(contents)
- def frame_count(self, trace):
- return sum(map(lambda x: len(x.frames), trace.threads))
-
def test_correct_thread_count(self):
self.assertEqual(len(self.trace.threads), threads_expected)
def test_correct_frame_count(self):
- self.assertEqual(self.frame_count(self.trace), frames_expected)
+ self.assertEqual(frame_count(self.trace), frames_expected)
def test_dup(self):
dup = self.trace.dup()
diff --git a/tests/python/koops.py b/tests/python/koops.py
index 4922c61..241ad21 100755
--- a/tests/python/koops.py
+++ b/tests/python/koops.py
@@ -1,12 +1,7 @@
#!/usr/bin/env python
import unittest
-from test_helpers import BindingsTestCase, load_input_contents
-
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
contents = load_input_contents('../kerneloopses/rhbz-827868')
frames_expected = 32
diff --git a/tests/python/metrics.py b/tests/python/metrics.py
index ea79d10..1230ef6 100755
--- a/tests/python/metrics.py
+++ b/tests/python/metrics.py
@@ -1,13 +1,7 @@
#!/usr/bin/env python
import unittest
-
-from test_helpers import load_input_contents
-
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
class TestDistances(unittest.TestCase):
def setUp(self):
diff --git a/tests/python/python.py b/tests/python/python.py
index 1fcd49d..9529536 100755
--- a/tests/python/python.py
+++ b/tests/python/python.py
@@ -1,13 +1,7 @@
#!/usr/bin/env python
import unittest
-
-from test_helpers import BindingsTestCase, load_input_contents
-
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
path = '../python_stacktraces/python-01'
contents = load_input_contents(path)
@@ -24,11 +18,8 @@ class TestPythonStacktrace(BindingsTestCase):
def setUp(self):
self.trace = satyr.PythonStacktrace(contents)
- def frame_count(self, trace):
- return len(trace.frames)
-
def test_correct_frame_count(self):
- self.assertEqual(self.frame_count(self.trace), frames_expected)
+ self.assertEqual(frame_count(self.trace), frames_expected)
def test_dup(self):
dup = self.trace.dup()
diff --git a/tests/python/test_helpers.py b/tests/python/test_helpers.py
index ba023a0..d99b53a 100644
--- a/tests/python/test_helpers.py
+++ b/tests/python/test_helpers.py
@@ -1,6 +1,11 @@
import os
import unittest
+try:
+ import _satyr as satyr
+except ImportError:
+ import satyr
+
class BindingsTestCase(unittest.TestCase):
def assertGetSetCorrect(self, obj, attr, orig_val, new_val):
'''
@@ -18,6 +23,12 @@ def load_input_contents(path):
with file(path) as f:
return f.read()
+def frame_count(trace):
+ if hasattr(trace, 'frames'):
+ return len(trace.frames)
+ else:
+ return sum(map(lambda x: len(x.frames), trace.threads))
+
if __name__ == '__main__':
import sys
sys.exit('This module is not meant to be run directly')
--
1.8.3.1
10 years, 9 months
[SATYR PATCH] sr_report_to_json: do not segfault on invalid reports
by Michal Toman
Signed-off-by: Michal Toman <mtoman(a)redhat.com>
---
lib/report.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/report.c b/lib/report.c
index 6258855..b2c4d29 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -177,7 +177,7 @@ sr_report_to_json(struct sr_report *report)
case SR_REPORT_INVALID:
case SR_REPORT_GDB: /* gdb ureports are not supported */
report_type = "invalid";
- reason = "invalid";
+ reason = sr_strdup("invalid");
break;
case SR_REPORT_CORE:
report_type = "core";
--
1.8.3.1
10 years, 9 months
[GNOME-ABRT PATCH] Use wrapped text for the bug report link
by Jakub Filak
Closes rhbz#977473
Signe-off-by: Jakub Filak <jfilak(a)edhat.com>
---
src/gnome_abrt/views.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/gnome_abrt/views.py b/src/gnome_abrt/views.py
index 0e8942e..edc5a92 100644
--- a/src/gnome_abrt/views.py
+++ b/src/gnome_abrt/views.py
@@ -550,6 +550,14 @@ class OopsWindow(Gtk.ApplicationWindow):
lnk.set_visible(True)
lnk.set_halign(Gtk.Align.START)
lnk.set_valign(Gtk.Align.START)
+ lnk_lbl = lnk.get_child()
+ # using hasattr() because this constructions abuses a knowledge
+ # of current Gtk.LinkButton implementation details
+ # works fine with gtk-3.8.2
+ # in a future version of gtk, the child will not necessarily
+ # be an instance of Gtk.Label
+ if hasattr(lnk_lbl, "set_line_wrap"):
+ lnk_lbl.set_line_wrap(True)
self._builder.vbx_links.pack_start(lnk, False, True, 0)
need_align = True
--
1.8.3.1
10 years, 9 months
[ABRT PATCH] rewrite shell script for moving vmcores into python closes #676
by Petr Kubat
Signed-off-by: Petr Kubat <pkubat(a)redhat.com>
---
src/hooks/Makefile.am | 4 +-
src/hooks/abrt-harvest-vmcore.in | 82 -----------------
src/hooks/abrt_harvest_vmcore.py.in | 174 ++++++++++++++++++++++++++++++++++++
3 files changed, 176 insertions(+), 84 deletions(-)
delete mode 100644 src/hooks/abrt-harvest-vmcore.in
create mode 100644 src/hooks/abrt_harvest_vmcore.py.in
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index de97a88..dfa791c 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -60,7 +60,7 @@ pyhook_PYTHON = \
EXTRA_DIST = abrt_exception_handler.py.in \
abrt-install-ccpp-hook.in \
- abrt-harvest-vmcore.in \
+ abrt_harvest_vmcore.py.in \
abrt-harvest-uefioops.in
CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir $(wildcard \.\#*)) $(notdir $(wildcard *.pyc)) $(man1_MANS)
@@ -85,7 +85,7 @@ abrt-install-ccpp-hook: abrt-install-ccpp-hook.in
-e s,\@libexecdir\@,$(libexecdir),g \
$< >$@
-abrt-harvest-vmcore: abrt-harvest-vmcore.in
+abrt-harvest-vmcore: abrt_harvest_vmcore.py.in
sed -e s,\@CONF_DIR\@,\$(CONF_DIR)\,g \
-e s,\@DEFAULT_DUMP_LOCATION\@,$(DEFAULT_DUMP_LOCATION),g \
$< >$@
diff --git a/src/hooks/abrt-harvest-vmcore.in b/src/hooks/abrt-harvest-vmcore.in
deleted file mode 100644
index a9ed1a2..0000000
--- a/src/hooks/abrt-harvest-vmcore.in
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-#
-# This script is meant to be run once at system startup after abrtd is up
-# and running. It moves all vmcore directories in /var/crash
-# (which are presumably created by kdump) to abrtd spool directory.
-#
-# The goal is to let abrtd notice and process them as new problem data dirs.
-#
-
-cd /var/crash 2>/dev/null || exit 0
-
-# Wait for abrtd to start. Give it at least 1 second to initialize.
-i=10
-while ! pidof abrtd >/dev/null; do
- if test $((i--)) = 0; then
- exit 1
- fi
- sleep 1
-done
-sleep 1
-
-umask 077
-
-CopyVMcore=`sed -n '/^CopyVMcore[ \t]*=/ s/.*=[ \t]*//p' @CONF_DIR(a)/abrt-harvest-vmcore.conf 2>/dev/null`
-ABRTDumpDir=`sed -n '/^DumpLocation[ \t]*=/ s/.*=[ \t]*//p' @CONF_DIR(a)/abrt.conf 2>/dev/null`
-
-if test -z "$ABRTDumpDir"; then
- ABRTDumpDir="@DEFAULT_DUMP_LOCATION@"
-fi
-
-move_core=false
-if test x"$CopyVMcore" = x"no" || test x"$CopyVMcore" = x"0"; then
- move_core=true
-fi
-
-for d in *; do
- test -d "$d" || continue
- test -f "$d/vmcore" || continue
-
- dst="$ABRTDumpDir/vmcore-$d"
-
- # Did we already copy it last time we booted?
- test -d "$dst" && continue
- test -d "$dst.new" && continue
-
- # Copy/move vmcore directory to abrt spool dir.
- # We use .new suffix - we must make sure abrtd doesn't try
- # to process partially-copied directory.
- #
- # This is the efficient way:
- #mv -- "$d" "/var/tmp/abrt/vmcore-$d.new" || continue
- # ...and this is what selinux forces me to do
- # (otherwise files have wrong context and abrtd can't access them):
- cp -r --no-preserve=all -- "$d" "$dst.new" || {
- rm -rf -- "$dst.new"
- continue
- }
- $move_core && rm -rf -- "$d"
-
- # Let abrtd know what type of problem it is:
- printf 'vmcore' >"$dst.new/analyzer"
- printf 'vmcore' >"$dst.new/type"
- printf 'kernel' >"$dst.new/component"
- printf '%s' "`date '+%s'`" >"$dst.new/time"
- printf '%s' "`uname -i`" >"$dst.new/architecture"
- cp "$dst.new/time" "$dst.new/last_occurrence"
- printf '0' >"$dst.new/uid"
- # TODO: need to generate *real* UUID,
- # one which has a real chance of catching dups!
- # This one generates different hashes even for similar cores:
- printf '%s' "`sha1sum <"$dst.new/vmcore" | cut -d" " -f1`" >"$dst.new/uuid"
- cp /etc/system-release "$dst.new/os_release" || {
- cp /etc/redhat-release "$dst.new/os_release" || {
- cp /etc/SuSE-release "$dst.new/os_release"
- }
- }
- cp /etc/os-release "$dst.new/os_info"
-
- chown -R 0:0 -- "$dst.new"
- chmod -R u+rwX,go-rwxst -- "$dst.new"
- mv -- "$dst.new" "$dst"
-done
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
new file mode 100644
index 0000000..15e6d7c
--- /dev/null
+++ b/src/hooks/abrt_harvest_vmcore.py.in
@@ -0,0 +1,174 @@
+#!/usr/bin/python
+"""
+ This script is meant to be run once at system startup after abrtd is up
+ and running. It moves all vmcore directories in /var/crash
+ (which are presumably created by kdump) to abrtd spool directory.
+
+ The goal is to let abrtd notice and process them as new problem data dirs.
+"""
+
+import os
+import ConfigParser
+import StringIO
+import shutil
+import time
+import hashlib
+
+#Path to the vmcore directories
+CORE_DIR = '/var/crash'
+
+def write_to_file(path, content):
+ """
+ A function for writing into a file
+
+ path - path to the file
+ content - content to write into the file
+ """
+
+ with open(path, 'w') as wfile:
+ wfile.write(content)
+
+def change_owner_rec(dest):
+ """
+ A simple function to recursively change file mode for a directory.
+
+ dest - path to the directory
+ """
+
+ os.chown(dest, 0, 0)
+ for root, dirs, files in os.walk(dest):
+ for i in dirs:
+ os.chown(os.path.join(root, i), 0, 0)
+ for i in files:
+ os.chown(os.path.join(root, i), 0, 0)
+
+def change_mode_rec(dest):
+ """
+ A simple function to recursively change file mode for a directory.
+
+ dest - path to the directory
+ """
+
+ os.chmod(dest, 0700)
+ for root, dirs, files in os.walk(dest):
+ for i in dirs:
+ os.chmod(os.path.join(root, i), 0700)
+ for i in files:
+ os.chmod(os.path.join(root, i), 0600)
+
+def create_abrtd_info(dest):
+ """
+ A simple function to write important information for the abrt daemon into
+ the vmcore directory to let abrtd know what kind of problem it is.
+
+ dest - path to the vmcore directory
+ """
+ write_to_file(os.path.join(dest, "analyzer"), 'vmcore')
+ write_to_file(os.path.join(dest, "type"), 'vmcore')
+ write_to_file(os.path.join(dest, "component"), 'kernel')
+ write_to_file(os.path.join(dest, "time"), str(time.time()).split('.')[0])
+ shutil.copy(os.path.join(dest, "time"),
+ os.path.join(dest, "last_occurrence"))
+ write_to_file(os.path.join(dest, "architecture"), os.uname()[4])
+ write_to_file(os.path.join(dest, "uid"), '0')
+
+ # TODO: need to generate *real* UUID,
+ # one which has a real chance of catching dups!
+ # This one generates different hashes even for similar cores:
+ hashobj = hashlib.sha1()
+ #Iterate over the file a line at a time in order to not load the whole
+ #vmcore file
+ with open(os.path.join(dest, "vmcore"), 'r') as corefile:
+ for line in corefile:
+ hashobj.update(line)
+ write_to_file(os.path.join(dest, "uuid"), hashobj.hexdigest())
+
+ #Write os info into the vmcore directory
+ if os.path.exists('/etc/system-release'):
+ shutil.copy('/etc/system-release', os.path.join(dest, "os_release"))
+ elif os.path.exists('/etc/redhat-release'):
+ shutil.copy('/etc/redhat-release', os.path.join(dest, "os_release"))
+ elif os.path.exists('/etc/SuSE-release'):
+ shutil.copy('/etc/SuSE-release', os.path.join(dest, "os_release"))
+ if os.path.exists('/etc/os-release'):
+ shutil.copy('/etc/system-release', os.path.join(dest, "os_info"))
+
+def harvest_vmcore():
+ """
+ This function moves vmcore directories from /var/crash to a dump dir.
+
+ The script also creates additional files used to tell abrt what kind of
+ problem it is and creates an uuid from the vmcore using a sha1 hash
+ function.
+ """
+
+ if not os.path.exists('/etc/os-release'):
+ exit(0)
+
+ # Wait for abrtd to start. Give it at least 1 second to initialize.
+ for i in xrange(10):
+ if i is 9:
+ exit(1)
+ elif os.system('pidof abrtd >/dev/null'):
+ time.sleep(1)
+ else:
+ break
+
+ os.umask(077)
+
+ #Check abrt config files for copy/move settings and
+ config = ConfigParser.ConfigParser()
+ #We need to add a root section as ConfigParser doesn't know how to work
+ #with config files without any sections
+ with open('@CONF_DIR(a)/abrt-harvest-vmcore.conf') as conf_file:
+ conf_str = '[section]\n' + conf_file.read()
+ conf_fp = StringIO.StringIO(conf_str)
+ config.readfp(conf_fp)
+ copyvmcore = config.get('section', 'CopyVMcore')
+ with open('@CONF_DIR(a)/abrt.conf') as conf_file:
+ conf_str = '[section]\n' + conf_file.read()
+ conf_fp = StringIO.StringIO(conf_str)
+ config = ConfigParser.ConfigParser()
+ config.readfp(conf_fp)
+ try:
+ abrtdumpdir = config.get('section', 'DumpLocation')
+ except ConfigParser.NoOptionError:
+ abrtdumpdir = '@DEFAULT_DUMP_LOCATION@'
+
+ #Go through all directories in /var/crash
+ for cfile in os.listdir(CORE_DIR):
+ f_full = os.path.join(CORE_DIR, cfile)
+ if not os.path.isdir(f_full):
+ continue
+ files = [ ff for ff in os.listdir(f_full)
+ if os.path.isfile(os.path.join(f_full,ff)) ]
+ if 'vmcore' not in files:
+ continue
+
+ destdir = os.path.join(abrtdumpdir, ('vmcore-' + cfile))
+ destdirnew = destdir + '.new'
+ # Did we already copy it last time we booted?
+ if os.path.isdir(destdir):
+ continue
+ if os.path.isdir(destdirnew):
+ continue
+ # Copy/move vmcore directory to abrt spool dir.
+ # We use .new suffix - we must make sure abrtd doesn't try
+ # to process partially-copied directory.
+ shutil.copytree(f_full, destdirnew)
+ if copyvmcore == 'no':
+ shutil.rmtree(f_full)
+
+ # Let abrtd know what type of problem it is:
+ create_abrtd_info(destdirnew)
+
+ #chown -R 0:0
+ change_owner_rec(destdirnew)
+ #chmod -R u+rwX,go-rwxst
+ change_mode_rec(destdirnew)
+
+ #Get rid of the .new suffix
+ shutil.move(destdirnew, destdir)
+
+if __name__ == '__main__':
+ harvest_vmcore()
--
1.8.3.1
10 years, 9 months
[SATYR PATCH] be compatible with older version of autotools
by Richard Marko
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
configure.ac | 2 +-
tests/Makefile.am | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6f70413..ca7a003 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,7 +10,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
# The 'yes' argument is undocumented but it is common knowledge that it works.
AM_SILENT_RULES([yes])
-AM_PROG_AR
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_CC
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 630e1e7..cef50ce 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,7 +70,7 @@ atconfig: $(top_builddir)/config.status
(cd ${top_builddir} && ./config.status ${subdir}/atconfig)
check-local: $(check_DATA)
- $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) -j4
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
installcheck-local: $(check_DATA)
$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' $(TESTSUITEFLAGS) ||:
--
1.8.3.1
10 years, 9 months
[SATYR PATCH] spec: synchronize with dist-git spec
by Martin Milata
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
satyr.spec.in | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/satyr.spec.in b/satyr.spec.in
index ef5de3d..3b31036 100644
--- a/satyr.spec.in
+++ b/satyr.spec.in
@@ -12,15 +12,6 @@ BuildRequires: python2-devel
BuildRequires: elfutils-devel, elfutils-libelf-devel, binutils-devel
BuildRequires: rpm-devel
-# We're going to switch to elfutils unwinder once it's available
-%if 0%{?rhel}
-%else
-# libunwind exists only on selected arches
-%ifarch %{arm} hppa ia64 mips ppc ppc64 %{ix86} x86_64
-BuildRequires: libunwind-devel >= 1.1
-%endif
-%endif
-
%description
Satyr is a library that can be used to create and process microreports.
Microreports consist of structured data suitable to be analyzed in a fully
@@ -81,6 +72,26 @@ make check
%{python_sitearch}/%{name}/*
%changelog
+* Mon Jul 29 2013 Martin Milata <mmilata(a)redhat.com> 0.6-1
+- New upstream version
+ - Do not export internal function symbols.
+
+* Thu Jul 25 2013 Martin Milata <mmilata(a)redhat.com> 0.5-2
+- Remove libunwind dependency altogether, always use GDB for unwinding.
+
+* Thu Jul 25 2013 Jakub Filak <jfilak(a)redhat.com> 0.5-1
+- Added function that creates core stacktrace from GDB output. Several bugfixes.
+
+* Tue Jul 09 2013 Martin Milata <mmilata(a)redhat.com> 0.4-2
+- Fix failing tests (failure manifests only on s390x)
+
+* Mon Jul 08 2013 Martin Milata <mmilata(a)redhat.com> 0.4-1
+- New upstream version
+ - Added features needed by ABRT
+ - Support for uReport2
+ - Major C and Python API changes
+- Patch for python-2.6 compatibility
+
* Tue Apr 02 2013 Dan Horák <dan[at]danny.cz> 0.3-2
- libunwind exists only on selected arches
--
1.8.3.1
10 years, 9 months