Add CI tests using the standard test interface

Adds tests according to the CI wiki [0] specifically the standard test interface in the spec [1].

[0]: https://fedoraproject.org/wiki/CI
[1]: https://fedoraproject.org/wiki/Changes/InvokingTests
This commit is contained in:
Andrei Stepanov 2017-10-06 10:38:34 +00:00
parent ef22e6ea33
commit 6743dfe08f
76 changed files with 3199 additions and 0 deletions

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts
# Description: Test for Can't remove crontab from expired accounts
# Author: Karel Volny <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2017 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts
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: Karel Volny <kvolny@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for Can't remove crontab from expired accounts" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts
Description: Test for Can't remove crontab from expired accounts
Author: Karel Volny <kvolny@redhat.com>

View File

@ -0,0 +1,63 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts
# Description: Test for Can't remove crontab from expired accounts
# Author: Karel Volny <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2017 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
TestUser="usertest"
ct_file="/var/spool/cron/$TestUser"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "useradd $TestUser" 0 "Adding the testing user"
rlPhaseEnd
rlPhaseStartTest
rlRun "echo '1 1 1 1 1 nonsense' | crontab -u $TestUser -" 0 "Setting up crontab for the testing user"
rlRun -s "crontab -u $TestUser -l" 0 "Checking the testing crontab"
rlAssertGrep "nonsense" $rlRun_LOG
rlRun "chage -E 1 $TestUser" 0 "Expiring the testing user account"
rlRun "crontab -u $TestUser -r" 0 "Removing the testing crontab"
rlAssertNotGrep "not allowed" $rlRun_LOG
rlRun -s "crontab -u $TestUser -l" 1 "Checking the testing crontab (should not exist)"
rlAssertGrep "no crontab for $TestUser" $rlRun_LOG
rlAssertNotGrep "not allowed" $rlRun_LOG
rlAssertNotExists "$ct_file"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "userdel $TestUser" 0 "Deleting the testing user"
rlRun "popd"
rlRun "rm -rf $TmpDir $ct_file" 0 "Removing tmp directory and possible cruft"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users
# Description: Test for Cron does uid lookups for non-existent users
# Author: Vaclav Danek <vdanek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users
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: Vaclav Danek <vdanek@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for Cron does uid lookups for non-existent users" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users
Description: Test for Cron does uid lookups for non-existent users
Author: Vaclav Danek <vdanek@redhat.com>
Bug summary: Cron does uid lookups for non-existent users

View File

@ -0,0 +1,53 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users
# Description: Test for Cron does uid lookups for non-existent users
# Author: Vaclav Danek <vdanek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "sleep 61 | crontab -" 0
rlRun -s "tail /var/log/cron" 0
rlAssertNotGrep "ORPHAN (no passwd entry)" $rlRun_LOG
rm -f $rlRun_LOG
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron
# Description: Test for MAILTO problem with anacron
# Author: Karel Volny <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2017 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/MAILTO-problem-with-anacron
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE anacrontab
.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: Karel Volny <kvolny@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for MAILTO problem with anacron" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron
Description: Test for MAILTO problem with anacron
Author: Karel Volny <kvolny@redhat.com>
Bug summary: MAILTO problem with anacron

View File

@ -0,0 +1,5 @@
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=testuser1
1 0 test echo "Hello anacron!"

View File

@ -0,0 +1,155 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron
# Description: Test for MAILTO problem with anacron
# Author: Karel Volny <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2017 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
TestDir=$PWD
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "useradd testuser1" 0 "Adding the testing user"
rlFileBackup --clean /var/spool/mail/root /var/log/cron
# stop cron not to interfere with our logs
rlServiceStop crond
rlPhaseEnd
# email should be sent to user specified via MAILTO (testuser1)
rlPhaseStartTest anacronmail
rlRun "truncate --size 0 /var/spool/mail/testuser1" 0 "Truncating mail queue for the user 'testuser1'"
rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log"
# DEBUG
echo "anacrontab:"
echo "***********"
cat ${TestDir}/anacrontab
rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job"
sleep 5
# DEBUG
echo "/var/spool/mail/testuser1:"
echo "**************************"
cat /var/spool/mail/testuser1
rlAssertGrep "anacron" "/var/spool/mail/testuser1"
rlAssertGrep "To: testuser1" "/var/spool/mail/testuser1"
# DEBUG
echo "/var/log/cron:"
echo "**************"
cat /var/log/cron
rlAssertGrep "\(produced output\)" /var/log/cron
rlAssertNotGrep "not mailing" /var/log/cron -i
rlPhaseEnd
# email should NOT be sent with empty MAILTO
rlPhaseStartTest noanacronmail-empty
rlRun "truncate --size 0 /var/spool/mail/root" 0 "Truncating mail queue for root"
rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log"
rlRun "sed -i -e 's/MAILTO=testuser1/MAILTO=/' ${TestDir}/anacrontab" 0 "Removing mailto user from anacrontab"
# DEBUG
echo "anacrontab:"
echo "***********"
cat ${TestDir}/anacrontab
rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job"
sleep 5
# DEBUG
echo "/var/spool/mail/root:"
echo "*********************"
cat /var/spool/mail/root
rlAssertNotGrep "anacron" "/var/spool/mail/root"
# DEBUG
echo "/var/log/cron:"
echo "**************"
cat /var/log/cron
rlAssertGrep "\(produced output\)" /var/log/cron
rlAssertGrep "not mailing" /var/log/cron -i
rlPhaseEnd
# email should be sent to nonexisting user double-doublequotes, as the string after '=' is treated literally
rlPhaseStartTest anacronmail-quotes
rlRun "truncate --size 0 /var/spool/mail/root" 0 "Truncating mail queue for root"
rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log"
rlRun "sed -i -e 's/MAILTO=/MAILTO=\"\"/' ${TestDir}/anacrontab" 0 "Setting mailto to double quotes in anacrontab"
# DEBUG
echo "anacrontab:"
echo "***********"
cat ${TestDir}/anacrontab
rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job"
sleep 5
# DEBUG
echo "/var/spool/mail/root:"
echo "*********************"
cat /var/spool/mail/root
rlAssertGrep "anacron" "/var/spool/mail/root"
#rlAssertGrep "To: \"\"" "/var/spool/mail/root"
# ^ this doesn't work in Beaker for some reason, check the quotes in 'Received: ... for "";'
rlAssertGrep "for \"\"" "/var/spool/mail/root"
# DEBUG
echo "/var/log/cron:"
echo "**************"
cat /var/log/cron
rlAssertGrep "\(produced output\)" /var/log/cron
rlAssertNotGrep "not mailing" /var/log/cron -i
rlPhaseEnd
# email should be sent to the user running anacron, when MAILTO is missing
rlPhaseStartTest anacronmail-missing
rlRun "truncate --size 0 /var/spool/mail/root" 0 "Truncating mail queue for root"
rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log"
rlRun "sed -i -e '/MAILTO/d' ${TestDir}/anacrontab" 0 "Removing mailto from anacrontab"
# DEBUG
echo "anacrontab:"
echo "***********"
cat ${TestDir}/anacrontab
rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job"
sleep 5
# DEBUG
echo "/var/spool/mail/root:"
echo "*********************"
cat /var/spool/mail/root
rlAssertGrep "anacron" "/var/spool/mail/root"
# DEBUG
echo "/var/log/cron:"
echo "**************"
cat /var/log/cron
rlAssertGrep "\(produced output\)" /var/log/cron
rlAssertNotGrep "not mailing" /var/log/cron -i
rlPhaseEnd
rlPhaseStartCleanup
rlRun "userdel testuser1"
rlServiceRestore crond
rlFileRestore
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/Regression/Regression/Make-crontab-a-PIE
# Description: What the test does
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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/Regression/Make-crontab-a-PIE
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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: What the test does" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie elfutils" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/Regression/Regression/Make-crontab-a-PIE
Description: What the test does
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -0,0 +1,56 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/Regression/Regression/Make-crontab-a-PIE
# Description: What the test does
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGES="cronie vixie-cron"
function myAssertRpms() {
rlRun "rpm -q $*" $((${#@}-1)) "One of required packages was found";
}
rlJournalStart
rlPhaseStartSetup
myAssertRpms $PACKAGES
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "eu-readelf -h /usr/bin/crontab | grep -E 'Type:[[:space:]]+DYN[[:space:]]+\(Shared object file\)'"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data
# Description: try some invalid configs for anacron to check config parser
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE configs
.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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: try some invalid configs for anacron to check config parser" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2
Description: try some invalid configs for anacron to check config parser
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -0,0 +1,16 @@
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=0
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly

View File

@ -0,0 +1,16 @@
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-8
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly

View File

@ -0,0 +1,18 @@
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
VAR=8
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-$VAR
#START_HOURS_RANGE=0
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly

View File

@ -0,0 +1,17 @@
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
%@$&=^^^^
# the jobs will be started during the following hours only
START_HOURS_RANGE=%@$&=^^^^
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly

View File

@ -0,0 +1,14 @@
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=%@$&=^^^^
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly

View File

@ -0,0 +1,66 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2
# Description: try some invalid configs for anacron to check config parser
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2014 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
assertRpms() {
rlRun "rpm -q $*" 0-$((${#@}-1)) "One of required packages was found";
RC=$?;
[[ $RC -lt ${#@} ]] && return 0;
return $RC;
}
PACKAGES="${PACKAGES:-cronie vixie-cron}"
rlJournalStart
rlPhaseStartSetup
assertRpms $PACKAGES
rlPhaseEnd
rlPhaseStartTest
for scenario in ./configs/*; do
[[ ! -f $scenario ]] && rlFail "$scenario isn't regular file";
## File name has 'special' format: scenario-X_Y where X is scenario number and Y is expected
## exit code. And of course there must be some issues related to RHEL 5 :-)
if rlIsRHEL 5; then
rlRun "anacron -f -u -d -t $(readlink -f $scenario)" 0 "Testing $(basename ${scenario%_[0-9]})";
else
if rlRun "anacron -T -t $scenario;" ${scenario##*_} "Verifying $(basename ${scenario%_[0-9]})"; then
rlRun "anacron -f -u -d -t $scenario" 0 "Testing $(basename ${scenario%_[0-9]})";
else
[[ $? -eq 139 ]] && cat $scenario;
fi
fi
done
rlPhaseEnd
rlPhaseStartCleanup
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data
# Description: Test for anacron segfaults with certain config data
# Author: Robin Hack <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE core.sh
.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: Robin Hack <rhack@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for anacron segfaults with certain config data" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 20m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data
Description: anacron segfaults with certain config data
Author: Robin Hack <rhack@redhat.com>

View File

@ -0,0 +1,3 @@
#!/bin/bash
echo "$1" > /tmp/core.lock

View File

@ -0,0 +1,76 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data
# Description: Test for anacron segfaults with certain config data
# Author: Robin Hack <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup "Set anacron"
rlAssertRpm $PACKAGE
TESTDIR="${PWD}"
rlFileBackup "/etc/anacrontab"
rlRun "echo 'START_HOURS_RANGE=0' > /etc/anacrontab"
# Prepare coredump handler
rlServiceStop crond
rlRun "chmod +x ${TESTDIR}/core.sh"
rlRun "cat /proc/sys/kernel/core_pattern > /tmp/core_pattern"
rlRun "echo \"|${TESTDIR}/core.sh %e\" > /proc/sys/kernel/core_pattern"
rlPhaseEnd
rlPhaseStartTest
rlRun "anacron"
rlRun "sleep 2" 0 "Wait for kernel"
# Anacron segfaults
rlAssertNotExists "/tmp/core.lock"
if [ -s "/tmp/core.lock" ]; then
rlAssertNotGrep "anacron" "/tmp/core.lock"
fi
rlPhaseEnd
rlPhaseStartCleanup
rlRun "cat /tmp/core_pattern > /proc/sys/kernel/core_pattern"
rm -f /tmp/core.lock
rm -f /tmp/core_pattern
killall anacron
rlFileRestore
rlServiceRestore crond
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/config-parsing-issue
# Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/config-parsing-issue
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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie-anacron" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/config-parsing-issue
Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like
Author: Jakub Prokes <jprokes@redhat.com>
Bug summary: cronie-anacron-1.4.4-14.el6.x86_64 doesn't like its own /etc/anacrontab syntax

View File

@ -0,0 +1,53 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/config-parsing-issue
# Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie-anacron"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "grep '^SHELL' /etc/anacrontab";
rlRun "grep '^PATH' /etc/anacrontab";
rlRun "grep '^MAILTO' /etc/anacrontab";
rlPhaseEnd
rlPhaseStartTest
rlRun "anacron -T"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down
# Description: Test for cron daemon fails to log that it is shutting down.
# Author: Robin Hack <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down
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: Robin Hack <rhack@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for cron daemon fails to log that it is shutting down." >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 20m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down
Description: Test for cron daemon fails to log that it is shutting down.
Author: Robin Hack <rhack@redhat.com>
Bug summary: cron daemon fails to log that it is shutting down.

View File

@ -0,0 +1,59 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down
# Description: Test for cron daemon fails to log that it is shutting down.
# Author: Robin Hack <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlServiceStop crond
rlPhaseEnd
rlPhaseStartTest
start_time=$(timedatectl | grep "Local time" | awk '{print$4" "$5}')
rlServiceStart crond
sleep 20
rlRun "journalctl --since \"$start_time\" | grep \"(CRON) INFO\"" 0 "cron startup"
rlServiceStop crond
# give dbus and cronie some time to shut down...
sleep 20
rlRun "journalctl --since \"$start_time\" | grep \"(CRON) INFO (Shutting down)\"" 0 "cron shutdown"
# DEBUG
journalctl _COMM=cron --since="$start_time"
rlPhaseEnd
rlPhaseStartCleanup
rlServiceRestore crond
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/crond-is-missing-RELRO-flags
# Description: Test for crond is missing RELRO flags
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 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/cronie/Regression/crond-is-missing-RELRO-flags
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)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Martin Cermak <mcermak@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for crond is missing RELRO flags" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie elfutils" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,5 @@
PURPOSE of /CoreOS/cronie/Regression/crond-is-missing-RELRO-flags
Description: Test for crond is missing RELRO flags
Author: Martin Cermak <mcermak@redhat.com>
Bug summary: crond is missing RELRO flags

View File

@ -0,0 +1,43 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/crond-is-missing-RELRO-flags
# Description: Test for crond is missing RELRO flags
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlPhaseEnd
rlPhaseStartTest
rlRun "eu-readelf -l /usr/sbin/crond | fgrep -q 'GNU_RELRO'" 0 "Binary was compiled with RELRO."
rlPhaseEnd
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error
# Description: Test for crond subtask abnormal termination removes pid
# Author: Robin Hack <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE crontab-job run-job.sh
.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: Robin Hack <rhack@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for crond subtask abnormal termination removes pid" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 20m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error
Description: Test for crond subtask abnormal termination removes pid
Author: Robin Hack <rhack@redhat.com>
Bug summary: crond subtask abnormal termination removes pid file in error

View File

@ -0,0 +1 @@
*/1 * * * * /tmp/run-job.sh

View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ -s /tmp/run-job.lock ]; then
exit 0
fi
echo $PPID > /tmp/run-job.lock
sleep 1234567
exit 0

View File

@ -0,0 +1,79 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error
# Description: Test for crond subtask abnormal termination removes pid
# Author: Robin Hack <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp ./run-job.sh /tmp/"
rlRun "chmod +x /tmp/run-job.sh"
rm -f /tmp/run-job.lock
rlServiceStop crond
rlServiceStart crond
rlRun "crontab -u root ./crontab-job"
rlRun "sleep 60" 0 "Wait for cron job to run"
rlPhaseEnd
rlPhaseStartTest
if [ -s /var/run/crond.pid ]; then
rlPass "Crond pid file exists";
else
rlFail "Cront pid file doesn't exists or is empty"
fi
# /tmp/run-job.lock contains PPID of my job
rlRun "kill -SIGTERM $(cat /tmp/run-job.lock)"
# Cut and pasta! Check file again!
# We love boiler plate code in our tests!
if [ -s /var/run/crond.pid ]; then
rlPass "Crond pid file exists";
else
rlFail "Cront pid file doesn't exists or is empty"
fi
rlPhaseEnd
rlPhaseStartCleanup
killall sleep
crontab -u root -r
rm -f /tmp/run-job.sh
rm -f /tmp/run-job.lock
rlServiceStop crond
rlServiceRestore crond
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/cronie-jobs-environment
# Description: testing EUID with jobs are executed and if LANG is correctly set
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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/cronie/Regression/cronie-jobs-environment
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE libfaketime-0.9.1.tar.gz crontab.temp cron_test.sh
.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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: testing EUID with jobs are executed and if LANG is correctly set" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/cronie-jobs-environment
Description: testing EUID with jobs are executed and if LANG is correctly set
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -0,0 +1,5 @@
#!/bin/bash
printf "LANG=$LANG\n" > /tmp/cronie-jobs-environment.log;
printf "EUID=$EUID\n" >> /tmp/cronie-jobs-environment.log;

View File

@ -0,0 +1,12 @@
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
CRON_CORRECT_MAIL_HEADER=1
* * * * * %TMPDIR/cron_test.sh

Binary file not shown.

View File

@ -0,0 +1,124 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/cronie-jobs-environment
# Description: testing EUID with jobs are executed and if LANG is correctly set
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
## Is nice to know when things going wrong
trap 'errorHandler ${LINENO}' ERR;
function errorHandler() {
local code="${?}";
local lineNO="$1";
case $code in
127)
rlFail "Command not found on line $lineNO"
;;
*)
rlFail "Unhandled error $code near line $lineNO";
;;
esac
}
function makeUser() {
local userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')";
while getent passwd $userName; do
userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')";
done
useradd -d $tmpDir $userName;
echo $userName;
}
PACKAGE="cronie"
declare -r LIBFAKETTIMEPACKAGE="libfaketime-0.9.1.tar.gz";
declare -r LIBFAKETIME="libfaketime.so.1";
rlJournalStart
rlPhaseStartSetup "Setup test environment"
rlAssertRpm $PACKAGE
rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory";
testDir="$(pwd)";
rlRun "chmod 755 $tmpDir" 0 "Setting permissions for tmp directory";
ls -lahdZ $tmpDir;
rlRun "pushd $tmpDir"
testUser="$(makeUser)";
rlRun "getent passwd $testUser" 0 "Test user $testUser created";
rlServiceStop crond;
rlPhaseEnd
rlPhaseStartSetup "Prepare libfaketime";
rlRun "cp ${testDir}/$LIBFAKETTIMEPACKAGE ./" 0 "Get library sources";
rlRun "tar -xvzf $LIBFAKETTIMEPACKAGE" 0 "Unpack library sources";
pushd ${LIBFAKETTIMEPACKAGE%.tar.gz};
rlRun "make &>/dev/null" 0 "Building library from sources";
rlRun "cp ./src/$LIBFAKETIME ../" 0 "Coping library to working directory";
popd;
LD_PRELOAD=./libfaketime.so.1 FAKETIME='1994-07-29 12:00:01' date +%G | { year="$(cat)"; [[ $year -eq 1994 ]]; };
rlAssert0 "Library preloading working well" $?;
rlPhaseEnd
rlPhaseStartSetup "Prepare tests";
rlRun "sed 's#%TMPDIR#$tmpDir#' $testDir/crontab.temp > crontab.source" #0 "Crontab prepared from template";
rlRun "crontab -u $testUser crontab.source" 0 "Set crontab for test user";
crontab -lu $testUser;
rlRun "cp $testDir/cron_test.sh ./" 0 "Copyed script for cron job";
rlRun "chmod a+x cron_test.sh" 0 "Permissions to executed set";
rlRun "[[ -e /var/spool/mail/$testUser ]] && printf '' > /var/spool/mail/$testUser" 0 "Clean up mails"
rlLog "Execute crond with faked time";
LD_PRELOAD=./libfaketime.so.1 FAKETIME='@1994-07-29 12:12:50' /usr/sbin/crond -n -x sch &
cronPID=$!;
pstree -Aph
rlRun "kill -0 $cronPID" 0 "crond is running";
rlLog "Security timeout for 30 sec to ensure all configs are loaded and crontab is succesfully processed";
sleep 30;
rlPhaseEnd
rlPhaseStartTest "cronie drops \$LANG and never passes it on to jobs run"
rlRun "[[ $(sed -n '/^LANG/s/LANG=//p' /tmp/cronie-jobs-environment.log) = $LANG ]]" 0 "LANG is set"
rlPhaseEnd
rlPhaseStartTest "cronie doesn't drop privileges before popen"
rlRun "[[ $(sed -n '/^EUID/s/EUID=//p' /tmp/cronie-jobs-environment.log) -eq $(id -u $testUser) ]]" 0 \
"Crontab is executed with correct EUID";
rlPhaseEnd
rlPhaseStartCleanup
rlRun "kill $cronPID" 0 "Terminating crond"
rlRun "crontab -ru $testUser" 0 "Crontab removed"
rlRun "popd"
rlRun "rm -r $tmpDir" 0 "Removing tmp directory"
rlRun "userdel -rf $testUser";
rlServiceRestore crond;
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user
# Description: Test for Cron does uid lookups for non-existent users
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user
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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for Cron does uid lookups for non-existent users" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user
Description: Test for Cron does uid lookups for non-existent users
Author: Jakub Prokes <jprokes@redhat.com>
Bug summary: Cron does uid lookups for non-existent users

View File

@ -0,0 +1,102 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k ft=beakerlib
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user
# Description: Test for Cron does uid lookups for non-existent users
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
declare -ri EXIT_FAILURE=1;
declare -ri EXIT_SUCCESS=0;
declare -r reportAllErrors=no;
function isTrue() {
local string="$@";
local oldOpt="shopt -p nocasematch";
local -i rc=1;
shopt -s nocasematch;
[[ -z "$string" ]] && return 1;
case $string in
yes) rc=0;;
true) rc=0;;
ano) rc=0;;
1) rc=0;;
jo) rc=0;;
yeah) rc=0;;
y) rc=0;;
a) rc=0;;
esac;
eval $oldOpt;
return $rc;
}
## Is nice to know when things going wrong
function errorHandler() {
local code="${?}";
local lineNO="$1";
case $code in
127)
rlFail "Command not found on line $lineNO"
;;
*)
isTrue $reportAllErrors && rlFail "Unhandled error $code near line $lineNO";
;;
esac
}
rlJournalStart
trap 'errorHandler ${LINENO}' ERR;
rlPhaseStart FAIL "Setup"
rlAssertRpm $PACKAGE;
rlRun "rlServiceStop 'crond'"
echo > /var/log/cron
rlRun "rlServiceStart 'crond'"
rlPhaseEnd
rlPhaseStartTest
rlRun "sleep 61 | crontab -" &
sleep 5
fileName="$(ls /var/spool/cron/ | grep 'tmp' | head -n 1)";
ls -lah /var/spool/cron/;
rlRun "[[ -n '$fileName' ]]" 0 "$fileName found";
rlRun "wait";
rlRun "grep 'ORPHAN' /var/log/cron | grep '$fileName'" 1 ;
tail -n 20 /var/log/cron;
rlPhaseEnd
rlPhaseStart WARN "Cleanup"
rlRun "rlServiceRestore 'crond'"
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
trap - ERR;
rlJournalEnd

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/crontab-has-wrong-permissions
# Description: What the test does
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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/cronie/Regression/crontab-has-wrong-permissions
export TESTVERSION=1.1
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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: What the test does" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/crontab-has-wrong-permissions
Description: What the test does
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -0,0 +1,56 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/crontab-has-wrong-permissions
# Description: What the test does
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGES="cronie vixie-cron"
function myAssertRpms() {
rlRun "rpm -q $*" $((${#@}-1)) "One of required packages was found";
}
rlJournalStart
rlPhaseStartSetup
myAssertRpms $PACKAGES
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "[[ $(stat /usr/bin/crontab -c \"%a\") -eq 4755 ]]"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/echos-OK-twice-in-init-script
# Description: Test for echos "OK" twice in init script
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 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/cronie/Regression/echos-OK-twice-in-init-script
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)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Martin Cermak <mcermak@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for echos \"OK\" twice in init script" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/echos-OK-twice-in-init-script
Description: Test for echos "OK" twice in init script
Author: Martin Cermak <mcermak@redhat.com>

View File

@ -0,0 +1,76 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/echos-OK-twice-in-init-script
# Description: Test for echos "OK" twice in init script
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TEMPDIR=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TEMPDIR"
rlFileBackup "/etc/rc.d/init.d/crond"
rlServiceStop crond
cat > /etc/rc.d/init.d/functions2 <<EOF1
success() {
echo OK >> $TEMPDIR/log.txt
}
EOF1
rlRun "cat /etc/rc.d/init.d/functions2"
sed -i "s/^\..*$/\0\n\. \/etc\/rc\.d\/init\.d\/functions2/" /etc/rc.d/init.d/crond
rlRun "grep ^\\\. /etc/rc.d/init.d/crond"
rlPhaseEnd
rlPhaseStartTest
rlAssertNotExists log.txt
rlServiceStart crond
rlAssertExists log.txt
rlRun "TIMES_PRINTED_OK=`grep OK log.txt | wc -l`"
rlRun "test $TIMES_PRINTED_OK -eq 1"
rlServiceStop crond
rlPhaseEnd
rlPhaseStartCleanup
rlBundleLogs TESTLOGS /etc/rc.d/init.d/functions2 /etc/rc.d/init.d/crond
rlRun "rm -f /etc/rc.d/init.d/functions2"
rlFileRestore
rlServiceRestore crond
rlRun "popd"
rlRun "rm -r $TEMPDIR" 0 "Removing tmp directory"
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalEnd

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/init-script-failure
# Description: Testing some init script failures
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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/cronie/Regression/init-script-failure
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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Testing some init script failures" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/init-script-failure
Description: Testing some init script failures
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -0,0 +1,73 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/init-script-failure
# Description: Testing some init script failures
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
function makeUser() {
local userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')";
while getent passwd $userName; do
userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')";
done
useradd -d $tmpDir $userName;
echo $userName;
}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlServiceStop crond
rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory";
testUser="$(makeUser)";
rlPhaseEnd
rlPhaseStartTest "Service restart needlessly reports failure"
rlRun -s "service crond restart"
rlAssertNotGrep "FAILED" $rlRun_LOG
rlPhaseEnd
if ! rpm -q systemd &>/dev/null; then
rlPhaseStartTest "Check service restart exit code"
su -l $testUser -c "service crond restart";
rlAssertEquals "Expected result of call initscript by unprivileged user is 4" $? 4
rlPhaseEnd
fi
rlPhaseStartCleanup
rm -f $rlRun_LOG
rm -rf $tmpDir;
userdel -rf $testUser;
rlServiceRestore crond
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Sanity/init-script-LSB
# Description: Init script should meet LSB specifications
# Author: Yulia Kopkova <ykopkova@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2009 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/cronie/Sanity/init-script-LSB
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: Petr Sklenar <psklenar@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Init script should meet LSB specifications" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Sanity/init-script-LSB
Description: Init script should meet LSB specifications
Author: Yulia Kopkova <ykopkova@redhat.com>

View File

@ -0,0 +1,186 @@
#!/bin/bash
# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Sanity/init-script-LSB
# Description: Init script should meet LSB specifications
# Author: Jan Scotka <jscotka@redhat.com>, Yulia Kopkova <ykopkova@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2009 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/share/rhts-library/rhtslib.sh
PACKAGE="cronie"
SERVICE="crond";
reportAllErrors=no;
function isTrue() {
local string="$@";
local oldOpt="shopt -p nocasematch";
local -i rc=1;
shopt -s nocasematch;
[[ -z "$string" ]] && return 1;
case $string in
yes) rc=0;;
true) rc=0;;
ano) rc=0;;
1) rc=0;;
jo) rc=0;;
yeah) rc=0;;
y) rc=0;;
a) rc=0;;
esac;
eval $oldOpt;
return $rc;
}
isTrue no && echo Yes || echo No;
## Is nice to know when things going wrong
function errorHandler() {
local code="${?}";
local lineNO="$1";
case $code in
127)
rlFail "Command not found on line $lineNO"
;;
*)
isTrue $reportAllErrors && rlFail "Unhandled error $code near line $lineNO";
;;
esac
}
function getUserName() {
local userName="qa_$(tr -dc "[:lower:]" < /dev/urandom | head -c 5)";
echo "$userName" >&2;
if getent passwd $userName &>/dev/null; then
getUserName;
return $?
fi
if [[ -n "$userName" ]]; then
echo "$userName";
return $EXIT_SUCCESS;
else
return $EXIT_FAILURE;
fi
}
rlJournalStart
trap 'errorHandler ${LINENO}' ERR;
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory";
testUser="$(getUserName || rlDie "Cannot get username")"
rlLog "${testUser}"
rlRun "useradd -d $tmpDir $testUser";
pushd $tmpDir;
rlServiceStop $SERVICE
rlPhaseEnd
rlPhaseStartTest "starts the service"
rlRun "service $SERVICE start" 0 " Service must start without problem"
rlRun "service $SERVICE status" 0 " Then Status command "
rlRun "service $SERVICE start" 0 " Already started service "
rlRun "service $SERVICE status" 0 " Again status command "
rlPhaseEnd
rlPhaseStartTest "restart the service"
firstPid=$(ps h -C $SERVICE -o pid);
rlRun "service $SERVICE restart" 0 " Restarting of service"
rlRun "service $SERVICE status" 0 " Status command "
secondPid=$(ps h -C $SERVICE -o pid);
rlRun "[[ -n $firstPid ]] && [[ -n $secondPid ]] && [[ $firstPid -ne $secondPid ]]" 0 \
"Pids are different after restart";
rlPhaseEnd
rlPhaseStartTest "stop the service"
rlRun "service $SERVICE stop" 0 " Stopping service "
rlRun "service $SERVICE status" 3 " Status of stopped service " || true
rlRun "service $SERVICE stop" 0 " Stopping service again "
rlRun "service $SERVICE status" 3 " Status of stopped service " || true
rlPhaseEnd
if ! rlIsRHEL ">=7"; then
rlPhaseStartTest "pid file"
rlServiceStart $SERVICE
rlAssertExists "/var/run/$SERVICE.pid" "Pid file /var/run/$SERVICE.pid must exist"
sleep 1
rlRun "kill -9 `pidof crond`" 0 "Kill $SERVICE"
sleep 10
rlRun "service $SERVICE status" 1 " Existing pid file, but service not started " || true;
sleep 1
rlRun "rm -fv /var/run/$SERVICE.pid" 0 "Remove .pid file"
rlPhaseEnd
rlPhaseStartTest "lock file"
rlAssertExists "/var/lock/subsys/$SERVICE" "Lock file /var/lock/subsys/$SERVICE must exist"
rlRun "service $SERVICE status" 2 " Existing lock file, but service not started " || true;
rlServiceStop $SERVICE
rlPhaseEnd
fi
rlPhaseStartTest "insufficient rights"
rlRun "service $SERVICE start " 0 " Starting service for restarting under nonpriv user "
rlRun "su $testUser -c 'service $SERVICE restart'" \
$(rpm -q systemd &>/dev/null && echo 1 || echo 4) \
"Insufficient rights, restarting service under nonprivileged user must fail";
rlPhaseEnd
rlPhaseStartTest "operations"
rlRun "service $SERVICE start" 0 " Service have to implement start function "
rlRun "service $SERVICE restart" 0 " Service have to implement restart function "
rlRun "service $SERVICE status" 0 " Service have to implement status function "
rlRun "service $SERVICE reload" 0 " Service have to implement reload function "
rlRun "service $SERVICE force-reload" 0 " Service have to implement force-reload function "
rlRun "service $SERVICE condrestart" 0 " Service have to implement condrestart function "
if ! rlIsRHEL ">=7"; then
rlRun "service $SERVICE try-restart" 0 " Service have to implement try-restart function "
fi
rlPhaseEnd
rlPhaseStartTest "nonexisting operations"
rlRun "service $SERVICE noexistop" 2 " Testing proper return code when nonexisting function";
rlRun "service $SERVICE stopex" 2 " Testing proper return code when nonexisting function";
rlRun "service $SERVICE foo" 2 " Testing proper return code when nonexisting function" || true
rlPhaseEnd
rlPhaseEnd
rlPhaseStartCleanup
rlServiceRestore $SERVICE
rlRun "getent passwd $testUser";
popd tmpDir;
rlRun "userdel -fr $testUser" 0 "Remove test user";
# rlRun "rm -rf $testDir";
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
trap - ERR;
rlJournalEnd

63
tests/ldap-users/Makefile Normal file
View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/ldap-users
# Description: Test for cronie not creating jobs for ldap users if ldap
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/ldap-users
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE data.ldif slapd.conf user1.cron
.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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for cronie not creating jobs for ldap users if ldap" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: cronie openldap" >> $(METADATA)
@echo "Requires: cronie authconfig openldap openldap-servers openldap-clients sssd sssd-ldap" >> $(METADATA)
@echo "RhtsRequires: library(authconfig/basic)" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

5
tests/ldap-users/PURPOSE Normal file
View File

@ -0,0 +1,5 @@
PURPOSE of /CoreOS/cronie/Regression/ldap-users
Description: Test for cronie not creating jobs for ldap users if ldap
Author: Jakub Prokes <jprokes@redhat.com>
Bug summary: cronie not creating jobs for ldap users if ldap server is temporarily down.

View File

@ -0,0 +1,26 @@
dn: dc=foo,dc=bar,dc=com
dc: foo
objectClass: top
objectClass: domain
dn: ou=people,dc=foo,dc=bar,dc=com
ou: people
objectClass: top
objectClass: organizationalUnit
dn: uid=user1,ou=people,dc=foo,dc=bar,dc=com
uid: user1
cn: user1
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {CRYPT}hebc0ErNA0uXY
shadowLastChange: 14460
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 1001
gidNumber: 1000
homeDirectory: /home/ldap/user1
gecos: user1

133
tests/ldap-users/runtest.sh Normal file
View File

@ -0,0 +1,133 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/ldap-users
# Description: Test for cronie not creating jobs for ldap users if ldap
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
rlJournalStart
rlPhaseStart FAIL "General Setup"
rlAssertRpm $PACKAGE
rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "testDir=\"$(pwd)\""
rlRun "pushd $tmpDir"
rlRun "rlImport --all"
rlServiceStart "crond"
rlFileBackup /var/log/cron
echo > /var/log/cron
/bin/kill -HUP $(cat /var/run/syslogd.pid)
rlRun "getent passwd user1" 2
rlPhaseEnd
rlPhaseStart FAIL "LDAP Server Setup"
rlServiceStop "slapd"
rlFileBackup --clean "/etc/openldap"
rlFileBackup --clean "/var/run/openldap"
rlFileBackup --clean "/var/lib/ldap"
rlRun "rm -rf /etc/openldap/slapd.d/* /var/lib/ldap/* /var/run/openldap/*" 0 "Cleaning LDAP directories"
rlRun "slapadd -l ${testDir}/data.ldif -f ${testDir}/slapd.conf" 0 "Importing testing user into LDAP"
rlRun "chown ldap:ldap /var/run/openldap/*" 0 "Fixing permissions on '/var/run/openldap/*'"
rlRun "restorecon -Rv /etc/" 0 "Fixing SELinux contexts"
rlRun "slaptest -f ${testDir}/slapd.conf -F /etc/openldap/slapd.d" 0 "Importing LDAP configuration"
rlRun "chown -R ldap:ldap /etc/openldap/slapd.d" 0 "Fixing permissions on '/etc/openldap/slapd.d'"
rlServiceStart "slapd"
rlPhaseEnd
rlPhaseStart FAIL "LDAP auth setup"
rlServiceStop "sssd"
rlRun "authconfig_setup"
rlRun "authconfig --savebackup=CoreOS_cronie_Regression_ldap-users"
rlRun "authconfig --enableldap --enableldapauth --ldapserver=ldap://127.0.0.1/ \
--ldapbasedn=dc=foo,dc=bar,dc=com --update"
rlRun "getent passwd user1"
rlRun "mkdir -p /home/ldap/user1"
rlRun "chown user1 /home/ldap/user1"
rlPhaseEnd
rlPhaseStartTest
rlRun "su user1 -c 'crontab ${testDir}/user1.cron'" 0 "Creating user cronjob" && \
cat ${testDir}/user1.cron;
rlFileBackup /etc/crontab
rlRun "rlServiceStop slapd"
rlRun "service sssd stop"
rlRun "rm -rf /var/lib/sss/db/*"
rlRun "service sssd start"
rlRun "getent passwd user1" 2
rlRun "echo \"* * * * * user1 /bin/echo foo > /tmp/cron.out\" > /etc/crontab" 0 \
"Create record in system crontab"
cat /etc/crontab
rlRun "service crond restart"
rlRun "rlServiceStart slapd"
rlRun "service sssd stop"
rlRun "rm -rf /var/lib/sss/db/*"
rlRun "service sssd start"
waitCounter=60;
echo "Waiting for LDAP"
while ! getent passwd user1; do
sleep 1;
echo -n .
[[ waitCounter -le 0 ]] && break;
waitCounter=$((waitCounter-1));
done
echo;
rlRun "getent passwd user1"
rm -f /home/ldap/user1/cron.out
echo "Waiting for cronjob execution"
sleep 65;
if rlRun "[[ -f /home/ldap/user1/cron.out ]]" 0 "User cronjob executed successfully"; then
rlAssertGrep "foo" /home/ldap/user1/cron.out;
fi
if rlRun "[[ -f /tmp/cron.out ]]" 0 "Crontab cronjob executed successfully"; then
rlAssertGrep "foo" /tmp/cron.out;
fi
rlRun "service crond stop"
cat /var/log/cron
rlPhaseEnd
rlPhaseStart WARN "Cleanup"
rlRun "service crond restart"
rlRun "crontab -r -u user1"
rlRun "rlServiceStop slapd"
rlRun "authconfig --disableldap --disableldapauth --update"
rlRun "authconfig --restorebackup=CoreOS_cronie_Regression_ldap-users"
rlRun "authconfig_cleanup"
rlRun "popd"
rlRun "rm -r $tmpDir" 0 "Removing tmp directory"
rlRun "rm -r /home/ldap/user1"
rlRun "rm -r /home/ldap"
rlFileRestore
rlServiceRestore slapd
rlServiceRestore sssd
/bin/kill -HUP $(cat /var/run/syslogd.pid)
rlServiceRestore crond
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,32 @@
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
allow bind_v2
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
database bdb
suffix "dc=foo,dc=bar,dc=com"
rootdn "cn=admin,dc=foo,dc=bar,dc=com"
# Password is 'x'.
rootpw {SSHA}GPhzu7pTYP4I+nGeujpBkODiPxX0v8n8
directory /var/run/openldap/
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub
index entryCSN,entryUUID eq
access to attrs=shadowLastChange,userPassword
by self write
by * auth
access to *
by * read

View File

@ -0,0 +1,10 @@
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
* * * * * /bin/echo foo > $HOME/cron.out

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/only-one-running-instance-in-time
# Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time.
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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/cronie/Regression/only-one-running-instance-in-time
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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time." >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/only-one-running-instance-in-time
Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time.
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -0,0 +1,52 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/only-one-running-instance-in-time
# Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time.
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup
rlServiceStart crond
rlPhaseEnd
rlPhaseStartTest
rlRun "kill -0 $(cat /var/run/crond.pid)" 0 "Service crond is running";
rlRun "/usr/sbin/crond" 1 "Executing another instance fail";
rlAssertEquals "There is stil one instance of crond" $(ps h -C crond -o pid | wc -l) 1;
rlPhaseEnd
rlPhaseStartCleanup
rlServiceRestore crond
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/run-with-syslog-flag
# Description: Test for cronie has a bug when run with syslog flag
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/cronie/Regression/run-with-syslog-flag
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: Jakub Prokes <jprokes@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for cronie has a bug when run with syslog flag" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie rsyslog" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/run-with-syslog-flag
Description: Test for cronie has a bug when run with syslog flag
Author: Jakub Prokes <jprokes@redhat.com>
Bug summary: cronie has a bug when run with syslog flag

View File

@ -0,0 +1,81 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/run-with-syslog-flag
# Description: Test for cronie has a bug when run with syslog flag
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# 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 2 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cronie"
declare -r sysConfig="/etc/sysconfig/crond";
declare -r cronJobFile=/etc/cron.d/testjob
rlJournalStart
rlPhaseStart FAIL "Setup"
## nasty hack for journalctl
export PAGER=""
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlServiceStart rsyslog
rlPhaseEnd
rlPhaseStartTest
rlFileBackup ${sysConfig};
crondOpts="$(sed -n '/^\s*CRONDARGS/s/^\s*CRONDARGS\s*=//p' ${sysConfig})";
rlLog "Old CRONDARGS=\"${crondOpts}\"";
if echo "$crondOpts" | grep '"'; then
## strip trailing quotes
crondOpts="$(echo "$crondOpts" | sed 's/\(^"\)\|\("$\)//g')";
fi
crondOpts="$crondOpts -s -m off";
rlLog "New CRONDARGS=\"${crondOpts}\"";
echo "CRONDARGS=\"${crondOpts}\"" > ${sysConfig};
phrase="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32)";
echo "* * * * * root /bin/echo $phrase" > ${cronJobFile};
cp /var/log/cron ./oldLog;
[[ -f ./oldLog ]] || touch ./oldLog;
rlServiceStop crond;
sleep 1
rlServiceStart crond;
sleep 65;
rlRun "diff ./oldLog /var/log/cron |grep -v '/bin/echo' \
| grep '$phrase'" 0 "Output is logged correctly." \
|| rlLog "$(tail -n 5 /var/log/cron)"
rlPhaseEnd
rlPhaseStart WARN "Cleanup"
rlRun "rm ${cronJobFile}";
rlFileRestore;
rlRun "rlServiceRestore crond";
rlServiceRestore rsyslog
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
#avoid systemd failing to start crond due start-limit
sleep 10
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

62
tests/tests.yml Normal file
View File

@ -0,0 +1,62 @@
---
# Tests to run in a classic environment
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- anacron-segfaults-with-certain-config-data
- anacron-segfaults-with-certain-config-data-2
- Can-t-remove-crontab-from-expired-accounts
- Cron-does-uid-lookups-for-non-existent-users
- cron-daemon-fails-to-log-that-it-is-shutting-down
- crond-is-missing-RELRO-flags
- crond-subtask-abnormal-termination-removes-pid-file-in-error
- config-parsing-issue
- cronie-jobs-environment
- crontab-can-invoke-lookup-for-nonexisted-user
- crontab-has-wrong-permissions
# - echos-OK-twice-in-init-script Does not work on Fedora-26
- init-script-failure
# - init-scripts-LSB Does not work on Fedora-26
# - ldap-users Does not work on Fedora-26
# - MAILTO-problem-with-anacron Does not work on Fedora-26
- Make-crontab-a-PIE
- only-one-running-instance-in-time
- run-with-syslog-flag
- usr-bin-crontab-has-wrong-permissions
required_packages:
- authconfig # ldap-users needs this package
- findutils # beakerlib needs find command
- elfutils # crond-is-missing-RELRO-flags needs eu-readelf tool
- gcc # cronie-jobs-environment needs gcc command
- openldap # ldap-users needs this package
- openldap-servers # ldap-users needs this package
- openldap-clients # ldap-users needs this package
- procps-ng # multiple tests need ps and pidof commands
- psmisc # multiple tests need killall command
- rsyslog # run-with-syslog-flag requires this package
- sendmail # MAILTO-problem-with-anacron needs sendmail command
- sssd # ldap-users needs this package
- sssd-ldap # ldap-users needs this package
# Tests to run in a container environment
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- container
tests:
- Can-t-remove-crontab-from-expired-accounts
- Make-crontab-a-PIE
- config-parsing-issue
- crond-is-missing-RELRO-flags
- crontab-has-wrong-permissions
- usr-bin-crontab-has-wrong-permissions
required_packages:
- cronie # everything needs cronie package
- findutils # beakerlib needs find command
- procps-ng # multiple tests need ps and pidof commands
- psmisc # multiple tests need killall command
- elfutils # multiple tests need eu-readelf tool

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions
# Description: Test for /usr/bin/crontab has wrong permissions
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 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/cronie/Regression/usr-bin-crontab-has-wrong-permissions
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)
chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Martin Cermak <mcermak@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for /usr/bin/crontab has wrong permissions" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: cronie" >> $(METADATA)
@echo "Requires: cronie" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,5 @@
PURPOSE of /CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions
Description: Test for /usr/bin/crontab has wrong permissions
Author: Martin Cermak <mcermak@redhat.com>
Bug summary: /usr/bin/crontab has wrong permissions

View File

@ -0,0 +1,44 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions
# Description: Test for /usr/bin/crontab has wrong permissions
# Author: Martin Cermak <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2011 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="cronie"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlPhaseEnd
rlPhaseStartTest
rlRun "test `stat -c %a /usr/bin/crontab` -eq 4755"
rlPhaseEnd
rlJournalEnd
rlJournalPrintText