diff --git a/.gitignore b/.gitignore index dafc350..bff32d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/abrt-2.10.9.tar.gz +/abrt-2.10.5.tar.gz /abrt-2.10.9.tar.gz diff --git a/EMPTY b/EMPTY deleted file mode 100644 index 9c558e3..0000000 --- a/EMPTY +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/tests/aux/lib.sh b/tests/aux/lib.sh new file mode 100644 index 0000000..5493797 --- /dev/null +++ b/tests/aux/lib.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +function check_prior_crashes() { + rlAssert0 "No prior crashes recorded" $(abrt-cli list 2> /dev/null | wc -l) + if [ ! "_$(abrt-cli list 2> /dev/null | wc -l)" == "_0" ]; then + abrt-cli list + rlDie "Won't proceed" + fi +} + +function create_custom_event() { + rlLog "Creating custom test event" + cat > /etc/libreport/events.d/test_event.conf << _EOF_ +EVENT=notify + echo "ABRT tests - EVENT=notify - $DUMP_DIR" + touch /tmp/abrt-done + true +EVENT=notify-dup + echo "ABRT tests - EVENT=notify-dup - $DUMP_DIR" + touch /tmp/abrt-done + true +_EOF_ +} + +function remove_custom_event() { + rlLog "Removing custom test event" + rm -f /etc/libreport/events.d/test_event.conf + rm -f /tmp/abrt-done +} + +function wait_for_hooks() { + rlLog "Waiting for all hooks to end" + # Wait at least 1 second + sleep 1 + local c=0 + while [ ! -f "/tmp/abrt-done" ]; do + sleep 0.1 + let c=$c+1 + if [ $c -gt 3000 ]; then + rlFail "Timeout" + break + fi + done + t=$( echo "scale=2; ($c/10)+1" | bc ) + rlLog "Hooks ended in $t seconds" +} + +function get_crash_path() { + rlLog "Get crash path" + rlAssertGreater "Crash recorded" $(abrt-cli list 2> /dev/null | wc -l) 0 + crash_PATH="$(abrt-cli list 2> /dev/null | grep Directory | awk '{ print $2 }' | tail -n1)" + if [ ! -d "$crash_PATH" ]; then + echo "Dump location listing:" + ls -l $ABRT_CONF_DUMP_LOCATION + echo "abrt-cli list:" + abrt-cli list + echo "Syslog:" + print_syslog 10 + rlFail "No crash dir generated, this shouldn't happen" + fi + rlLog "PATH = $crash_PATH" +} diff --git a/tests/cli-ng-sanity/Makefile b/tests/cli-ng-sanity/Makefile new file mode 100644 index 0000000..938bf10 --- /dev/null +++ b/tests/cli-ng-sanity/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/abrt/Sanity/cli-ng-sanity +# Description: Test basic abrt-cli-ng funcionality +# Author: Martin Kutlak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/abrt/Sanity/cli-ng-sanity +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Martin Kutlak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic abrt-cli-ng funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: abrt" >> $(METADATA) + @echo "Requires: abrt abrt-cli-ng coreutils libreport-plugin-logger" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/cli-ng-sanity/PURPOSE b/tests/cli-ng-sanity/PURPOSE new file mode 100644 index 0000000..8c649dd --- /dev/null +++ b/tests/cli-ng-sanity/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of cli-ng-sanity +Description: does sanity on abrt-cli-ng +Author: Richard Marko diff --git a/tests/cli-ng-sanity/runtest.sh b/tests/cli-ng-sanity/runtest.sh new file mode 100644 index 0000000..42af67e --- /dev/null +++ b/tests/cli-ng-sanity/runtest.sh @@ -0,0 +1,138 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of cli-ng-sanity +# Description: does sanity on abrt-cli-ng +# Author: Richard Marko +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 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="cli-ng-sanity" +PACKAGE="abrt" + +rlJournalStart + rlPhaseStartSetup + LANG="" + export LANG + + # Since we send SIGSEGV to sleep(1) and coreutils will be unsigned. + rlRun "augtool set /files/etc/abrt/abrt-action-save-package-data.conf/OpenGPGCheck no" 0 + + check_prior_crashes + create_custom_event + rlServiceStart abrtd abrt-journal-core + + TmpDir=$(mktemp -d) + pushd $TmpDir + rlPhaseEnd + + rlPhaseStartTest "--version" + rlRun "abrt -v 2>&1 | grep 'abrt'" + rlRun "abrt --version 2>&1 | grep 'abrt'" + rlPhaseEnd + + rlPhaseStartTest "--help" + rlRun "abrt --help" 0 + rlRun "abrt --help 2>&1 | grep 'usage: abrt'" + rlPhaseEnd + + rlPhaseStartTest "list" + timeout --signal=SEGV 1 sleep 10 + wait_for_hooks + get_crash_path + + rlRun "abrt list | grep -i 'Id'" + rlRun "abrt list | grep -i 'Component'" + rlRun "abrt list --pretty full | grep -i 'Command line'" + rlPhaseEnd + + rlPhaseStartTest "list -n" # list not-reported + rlRun "abrt list -n | grep -i 'Id'" + rlRun "abrt list -n | grep -i 'Component'" + rlPhaseEnd + + rlPhaseStartTest "status" + rlRun "abrt status | grep 'has detected 1 problem'" + rlPhaseEnd + + rlPhaseStartTest "report NONEXISTENT" + rlRun "abrt report NONEXISTENT" 1 + rlPhaseEnd + + rlPhaseStartTest "report not-reportable" + rlRun "touch $crash_PATH/not-reportable" + + cp $crash_PATH/{type,analyzer} ./ + + echo "cli_sanity_test_not_reportable" > $crash_PATH/type + echo "cli_sanity_test_not_reportable" > $crash_PATH/analyzer + + PROBLEM_ID=$(abrt list --fmt {short_id}) + rlRun "abrt report 2>&1 | tee abrt-cli-report-not-reportable.log" 0 + rlAssertGrep "Problem '$PROBLEM_ID' cannot be reported" abrt-cli-report-not-reportable.log + + cp -f type analyzer $crash_PATH + + rlRun "rm -f $crash_PATH/not-reportable" + rlPhaseEnd + + rlPhaseStartTest "info DIR" + rlRun "abrt info" + rlRun "abrt info --pretty email > info.out" + rlPhaseEnd + + rlPhaseStartTest "list (after reporting)" + DIR=$( abrt list --pretty full | grep 'Path' | head -n1 | awk '{ print $2 }' ) + + # this should ensure that ABRT will consider the problem as reported + rlRun "reporter-print -r -d $DIR -o /dev/null" + + # this expects that reporter-print works and adds an URL to + # the output file to the problem's data + rlRun "abrt list | grep -i 'file:///dev/null'" + rlPhaseEnd + + rlPhaseStartTest "list -n (after reporting)" # list not-reported + rlRun "abrt list -n | grep 'No problems'" + rlPhaseEnd + + rlPhaseStartTest "info NONEXISTENT" + rlRun "abrt info NONEXISTENT" 1 + rlPhaseEnd + + rlPhaseStartTest "remove NONEXISTENT" + rlRun "abrt remove NONEXISTENT" 1 + rlPhaseEnd + + rlPhaseStartTest "remove DIR" + rlRun "abrt remove -f" + rlPhaseEnd + + rlPhaseStartCleanup + remove_custom_event + popd # TmpDir + rm -rf $TmpDir + rlPhaseEnd + rlJournalPrintText +rlJournalEnd diff --git a/tests/cli-sanity/Makefile b/tests/cli-sanity/Makefile new file mode 100644 index 0000000..a4ae774 --- /dev/null +++ b/tests/cli-sanity/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/abrt/Sanity/cli-sanity +# Description: Test basic abrt-cli funcionality +# Author: Martin Kutlak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/abrt/Sanity/cli-sanity +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Martin Kutlak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test basic abrt-cli funcionality" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: abrt" >> $(METADATA) + @echo "Requires: abrt abrt-cli coreutils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/cli-sanity/PURPOSE b/tests/cli-sanity/PURPOSE new file mode 100644 index 0000000..8ff0c9d --- /dev/null +++ b/tests/cli-sanity/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of cli-sanity +Description: does sanity on abrt-cli +Author: Michal Nowak diff --git a/tests/cli-sanity/runtest.sh b/tests/cli-sanity/runtest.sh new file mode 100755 index 0000000..e8d9c53 --- /dev/null +++ b/tests/cli-sanity/runtest.sh @@ -0,0 +1,210 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of cli-sanity +# Description: does sanity on report-cli +# Author: Michal Nowak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 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="cli-sanity" +PACKAGE="abrt" + +rlJournalStart + rlPhaseStartSetup + LANG="" + export LANG + + # Since we send SIGSEGV to sleep(1) and coreutils will be unsigned. + rlRun "augtool set /files/etc/abrt/abrt-action-save-package-data.conf/OpenGPGCheck no" 0 + + check_prior_crashes + create_custom_event + rlServiceStart abrtd abrt-journal-core + + TmpDir=$(mktemp -d) + pushd $TmpDir + rlPhaseEnd + + rlPhaseStartTest "--version" + rlRun "abrt-cli --version | grep 'abrt-cli'" +# rlAssertEquals "abrt-cli and abrt-cli RPM claim the same version" "$(abrt-cli -V | awk '{ print $2 }')" "$(rpmquery --qf='%{VERSION}' abrt-cli)" + rlPhaseEnd + + rlPhaseStartTest "--help" + rlRun "abrt-cli --help" 0 + rlRun "abrt-cli --help 2>&1 | grep 'Usage: abrt-cli'" + rlPhaseEnd + + rlPhaseStartTest "list the same as ls" + abrt-cli list &> param_cmd + abrt-cli ls &> param_abbrev + rlAssertNotDiffer param_cmd param_abbrev + rlPhaseEnd + + rlPhaseStartTest "remove the same as rm" + abrt-cli remove &> param_cmd + abrt-cli rm &> param_abbrev + rlAssertNotDiffer param_cmd param_abbrev + rlPhaseEnd + + rlPhaseStartTest "report the same as e" + abrt-cli report &> param_cmd + abrt-cli e &> param_abbrev + rlAssertNotDiffer param_cmd param_abbrev + rlPhaseEnd + + rlPhaseStartTest "info the same as i" + abrt-cli info &> param_cmd + abrt-cli i &> param_abbrev + rlAssertNotDiffer param_cmd param_abbrev + rlPhaseEnd + + rlPhaseStartTest "status the same as st" + abrt-cli status &> param_cmd + abrt-cli st &> param_abbrev + rlAssertNotDiffer param_cmd param_abbrev + rlPhaseEnd + + rlPhaseStartTest "process the same as p" + abrt-cli process &> param_cmd + abrt-cli p &> param_abbrev + rlAssertNotDiffer param_cmd param_abbrev + rlPhaseEnd + + + rlPhaseStartTest "list" + timeout --signal=SEGV 1 sleep 10 + wait_for_hooks + get_crash_path + + rlRun "abrt-cli list | grep -i 'cmdline'" + rlRun "abrt-cli list | grep -i 'Package'" + rlPhaseEnd + + rlPhaseStartTest "list -n" # list not-reported + rlRun "abrt-cli list -n | grep -i 'cmdline'" + rlRun "abrt-cli list -n | grep -i 'Package'" + rlPhaseEnd + + rlPhaseStartTest "report FAKEDIR" + rlRun "abrt-cli report FAKEDIR" 1 + rlPhaseEnd + + rlPhaseStartTest "report not-reportable" + rlRun "touch $crash_PATH/not-reportable" + + cp $crash_PATH/{type,analyzer} ./ + + echo "cli_sanity_test_not_reportable" > $crash_PATH/type + echo "cli_sanity_test_not_reportable" > $crash_PATH/analyzer + + rlRun "abrt-cli report $crash_PATH 2>&1 | tee abrt-cli-report-not-reportable.log" 0 + rlAssertGrep "Problem '$crash_PATH' cannot be reported" abrt-cli-report-not-reportable.log + + cp -f type analyzer $crash_PATH + + rlRun "rm -f $crash_PATH/not-reportable" + rlPhaseEnd + + rlPhaseStartTest "report not-reportable --unsafe parameter" + rlRun "touch $crash_PATH/not-reportable" + + cp $crash_PATH/{type,analyzer} ./ + + echo "cli_sanity_test_not_reportable_unsafe" > $crash_PATH/type + echo "cli_sanity_test_not_reportable_unsafe" > $crash_PATH/analyzer + + rlRun "abrt-cli report --unsafe $crash_PATH 2>&1 | tee abrt-cli-report-not-reportable-unsafe.log" 0 + rlAssertNotGrep "Problem '$crash_PATH' cannot be reported" abrt-cli-report-not-reportable-unsafe.log + rlAssertGrep "Error: no processing is specified for event 'report-cli'" abrt-cli-report-not-reportable-unsafe.log + + cp -f type analyzer $crash_PATH + + rlRun "rm -f $crash_PATH/not-reportable" + rlPhaseEnd + + # This test used to select 1st analyzer (Local GNU Debugger) + # and run it, then "edit" data with cat (this merely prints data to stdout) + # and terminate. This was far from reliable (what if analyzer would change?). + # + # With the changed CLI, it probably can be emulated by running + # "report-cli -e analyze_LocalGDB $DIR" + # ...except that analyze_LocalGDB has no! + # Need to think about this... + # + #rlPhaseStartTest "report DIR" + # DIR=$(abrt-cli list -n | grep 'Directory' | head -n1 | awk '{ print $2 }') + # echo -e "1\n" | VISUAL="cat" EDITOR="cat" abrt-cli report $DIR > output.out 2>&1 + # + # rlAssertGrep "\-cmdline" output.out + # rlAssertGrep "\-kernel" output.out + #rlPhaseEnd + + rlPhaseStartTest "info DIR" + DIR=$(abrt-cli list | grep 'Directory' | head -n1 | awk '{ print $2 }') + rlRun "abrt-cli info $DIR" + rlRun "abrt-cli info -d $DIR > info.out" + rlPhaseEnd + + rlPhaseStartTest "list (after reporting)" + DIR=$(abrt-cli list | grep 'Directory' | head -n1 | awk '{ print $2 }') + + # this should ensure that ABRT will consider the problem as reported + rlRun "reporter-print -r -d $DIR -o /dev/null" + + rlRun "abrt-cli list | grep -i 'cmdline'" + rlRun "abrt-cli list | grep -i 'Package'" + + # this expects that reporter-print works and adds an URL to + # the output file to the problem's data + rlRun "abrt-cli list | grep -i 'file:///dev/null'" + rlPhaseEnd + + rlPhaseStartTest "list -n (after reporting)" # list not-reported + BYTESNUM=$(abrt-cli list -n | wc -c) + rlAssert0 "No not-reported problem" "$BYTESNUM" + rlPhaseEnd + + rlPhaseStartTest "info FAKEDIR" + rlRun "abrt-cli info FAKEDIR" 1 + rlRun "abrt-cli info -d FAKEDIR" 1 + rlPhaseEnd + + rlPhaseStartTest "rm FAKEDIR" + rlRun "abrt-cli rm FAKEDIR" 1 + rlPhaseEnd + + rlPhaseStartTest "rm DIR" + DIR_DELETE=$(abrt-cli list | grep 'Directory' | head -n1 | awk '{ print $2 }') + rlRun "abrt-cli rm $DIR_DELETE" + rlPhaseEnd + + rlPhaseStartCleanup + remove_custom_event + popd # TmpDir + rm -rf $TmpDir + rlPhaseEnd + rlJournalPrintText +rlJournalEnd diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..206f1bb --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,16 @@ +--- +# Tests that run in all contexts +- hosts: localhost + become: true + roles: + - role: standard-test-beakerlib + tags: + - classic + tests: + - cli-sanity + - cli-ng-sanity + required_packages: + - augeas # unsetting OpenGPGCheck in the config + - libreport-plugin-logger # cli-ng-sanity requires + - coreutils # tests require sleep, timeout + - bc # bc command in timeout