log4cplus/Sanity/basic/test.sh
2024-06-26 10:47:49 +02:00

32 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
TestLOG="log"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm log4cplus
rlIsRHELLike && rlRun "dnf install -y $(rlGetRecommended) --enablerepo=rhel-CRB --enablerepo=rhel-buildroot"
TestDir=$(pwd)
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd $tmp"
rlRun "cp -r $TestDir/log4cplus_test ./"
cd log4cplus_test
rlRun "g++ -o log4cplus_test main.cpp -llog4cplus" 0 "Compiling"
rlPhaseEnd
rlPhaseStartTest
rlAssertExists log4cplus_test
rlRun "./log4cplus_test &> $TestLOG" 0 "Running test"
rlAssertExists log
rlAssertGrep "INFO main - This is an informational message" $TestLOG
rlAssertGrep "WARN main - This is a warning message" $TestLOG
rlAssertGrep "ERROR main - This is an error message" $TestLOG
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd