add sanity test

This commit is contained in:
Ondrej Mejzlik 2024-08-21 11:56:46 +02:00
commit 98c86c76e7
2 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,23 @@
summary: 'Test for: (sanity-test)'
description: sanity-test
contact: Ondrej Mejzlik <omejzlik@redhat.com>
test: ./runtest.sh
framework: beakerlib
duration: 5m
enabled: true
tag:
- rhel-buildroot
- NoRHEL7
- Tier1
tier: '1'
adjust:
- enabled: false
when: distro < rhel-8
continue: false
- enabled: false
when: distro = rhel-alt-7
continue: false
component:
- libfaketime
recommend:
- libfaketime

59
Sanity/sanity-test/runtest.sh Executable file
View file

@ -0,0 +1,59 @@
#!/usr/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/libfaketime/sanity-test
# Description: Test for sanity-test
# Author: Ondrej Mejzlik <omejzlik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2024 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/share/beakerlib/beakerlib.sh || exit 1
PACKAGE=${PACKAGE:-libfaketime}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE || rlDie "Package $PACKAGE not installed"
rlLog "Arch: $(arch), PC name: $(hostname), $(hostname -A) User: $(whoami)"
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir" 0 "Going into tmp directory $TmpDir"
rlPhaseEnd
rlGetTestState && {
rlPhaseStartTest
rlRun "faketime -h" 0 "Check help message"
rlRun "faketime '2008-12-24 08:15:42' /bin/date | grep 'Wed Dec 24 08:15:42 AM'" 0 "Test functionality 1"
rlRun "faketime -m '2008-12-24 08:15:42' /bin/date | grep 'Wed Dec 24 08:15:42 AM'" 0 "Test -m option"
FTIME=$(faketime -f '+2y x10,0' /bin/bash -c 'date +%Y')
CTIME=$(($(date +%Y) + 2 ))
rlLog "$FTIME=$CTIME"
rlRun "test $FTIME -eq $CTIME" 0 "Test advanced specification"
rlRun "faketime -v" 0 "Version information"
rlPhaseEnd
}
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd