Rechercher une page de manuel
beakerlib-beakerlib
Langue: en
Version: 2010-05-12 (fedora - 01/12/10)
Section: 1 (Commandes utilisateur)
NAME
BeakerLib - a shell-level integration testing libraryDESCRIPTION
BeakerLib is a shell-level integration testing library, providing convenience functions which simplify writing, running and analysis of integration and blackbox tests.The essential features include:
- *
- Journal - uniform logging mechanism (logs & results saved in flexible XML format, easy to compare results & generate reports)
- *
- Phases - logical grouping of test actions, clear separation of setup / test / cleanup (preventing false fails)
- *
- Asserts - common checks affecting the overall results of the individual phases (checking for exit codes, file existence & content...)
- *
- Helpers - convenience functions for common operations such as managing services, backup & restore
The main script sets the "BEAKERLIB" variable and sources other scripts where the actual functions are defined. You should source it at the beginning of your test with:
. /usr/lib/beakerlib/beakerlib.sh
See the EXAMPLES section for quick start inspiration.
EXAMPLES
Simple
A minimal BeakerLib test can look like this:. /usr/lib/beakerlib/beakerlib.sh rlJournalStart rlPhaseStartTest rlAssertRpm "setup" rlAssertExists "/etc/passwd" rlAssertGrep "root" "/etc/passwd" rlPhaseEnd rlJournalEnd
Phases
Here comes a bit more interesting example of a test which sets all the recommended variables and makes use of the phases:# Include the BeakerLib environment . /usr/lib/beakerlib/beakerlib.sh # Set the full test name TEST="/examples/beakerlib/Sanity/phases" # Package being tested PACKAGE="coreutils" rlJournalStart # Setup phase: Prepare test directory rlPhaseStartSetup rlAssertRpm $PACKAGE rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" rlRun "pushd $TmpDir" rlPhaseEnd # Test phase: Testing touch, ls and rm commands rlPhaseStartTest rlRun "touch foo" 0 "Creating the foo test file" rlAssertExists "foo" rlRun "ls -l foo" 0 "Listing the foo test file" rlRun "rm foo" 0 "Removing the foo test file" rlAssertNotExists "foo" rlRun "ls -l foo" 2 "Listing foo should now report an error" rlPhaseEnd # Cleanup phase: Remove test directory rlPhaseStartCleanup rlRun "popd" rlRun "rm -r $TmpDir" 0 "Removing tmp directory" rlPhaseEnd rlJournalEnd # Print the test report rlJournalPrintText
The ouput of the rlJournalPrintText command would produce an output similar to the following:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ LOG ] :: TEST PROTOCOL :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ LOG ] :: Test run ID : debugging :: [ LOG ] :: Package : coreutils :: [ LOG ] :: Installed: : coreutils-7.6-9.fc12.i686 :: [ LOG ] :: Test started : 2010-02-08 14:55:44 :: [ LOG ] :: Test finished : 2010-02-08 14:55:50 :: [ LOG ] :: Test name : /examples/beakerlib/Sanity/phases :: [ LOG ] :: Distro: : Fedora release 12 (Constantine) :: [ LOG ] :: Hostname : localhost :: [ LOG ] :: Architecture : i686 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ LOG ] :: Test description :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: PURPOSE of /examples/beakerlib/Sanity/phases Description: Testing BeakerLib phases Author: Petr Splichal <psplicha@redhat.com> This example shows how the phases work in the BeakerLib on a trivial smoke test for the "touch", "ls" and "rm" commands from the coreutils package. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ LOG ] :: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ PASS ] :: Checking for the presence of coreutils rpm :: [ PASS ] :: Creating tmp directory :: [ PASS ] :: Running 'pushd /tmp/tmp.IcluQu5GVS' :: [ LOG ] :: Duration: 0s :: [ LOG ] :: Assertions: 3 good, 0 bad :: [ PASS ] :: RESULT: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ LOG ] :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ PASS ] :: Creating the foo test file :: [ PASS ] :: File foo should exist :: [ PASS ] :: Listing the foo test file :: [ PASS ] :: Removing the foo test file :: [ PASS ] :: File foo should not exist :: [ PASS ] :: Listing foo should now report an error :: [ LOG ] :: Duration: 1s :: [ LOG ] :: Assertions: 6 good, 0 bad :: [ PASS ] :: RESULT: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ LOG ] :: Cleanup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ PASS ] :: Running 'popd' :: [ PASS ] :: Removing tmp directory :: [ LOG ] :: Duration: 1s :: [ LOG ] :: Assertions: 2 good, 0 bad :: [ PASS ] :: RESULT: Cleanup
Note that the detailed test description is read from a separate file PURPOSE placed in the same directory as the test itself.
LINKS
- Project Page
- https://fedorahosted.org/beakerlib/
- Manual
- https://fedorahosted.org/beakerlib/wiki/Manual
- Reporting bugs
- TODO
AUTHORS
- *
- Petr Muller <pmuller@redhat.com>
- *
- Ondrej Hudlicky <ohudlick@redhat.com>
- *
- Jan Hutar <jhutar@redhat.com>
- *
- Petr Splichal <psplicha@redhat.com>
- *
- Ales Zelinka <azelinka@redhat.com>
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre