From 98c86c76e76e34360cdcc739ae490e73f79999fb Mon Sep 17 00:00:00 2001 From: Ondrej Mejzlik Date: Wed, 21 Aug 2024 11:56:46 +0200 Subject: [PATCH] add sanity test --- Sanity/sanity-test/main.fmf | 23 ++++++++++++++ Sanity/sanity-test/runtest.sh | 59 +++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 Sanity/sanity-test/main.fmf create mode 100755 Sanity/sanity-test/runtest.sh diff --git a/Sanity/sanity-test/main.fmf b/Sanity/sanity-test/main.fmf new file mode 100644 index 0000000..d9acfa6 --- /dev/null +++ b/Sanity/sanity-test/main.fmf @@ -0,0 +1,23 @@ +summary: 'Test for: (sanity-test)' +description: sanity-test +contact: Ondrej Mejzlik +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 diff --git a/Sanity/sanity-test/runtest.sh b/Sanity/sanity-test/runtest.sh new file mode 100755 index 0000000..dc53f83 --- /dev/null +++ b/Sanity/sanity-test/runtest.sh @@ -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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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