beakerlib-libraries - Man Page

libraries — mechanism for loading shared test code from libraries

Description

This file contains functions for bringing external code into the test namespace.

Functions

rlImport

Imports code provided by one or more libraries into the test namespace. The library search mechanism is based on Beaker test hierarchy system, i.e.:

/component/type/test-name/test-file

When test-file calls rlImport with 'foo/bar' parameter, the libraries are searched in following locations: these are the possible path prefixes

    - colon-separated paths from $BEAKERLIB_LIBRARY_PATH
    - /mnt/tests
    - /usr/share/beakerlib-libraries

the next component of the path is one of the following:

    - /foo/Library/bar
    - /foo/bar
    - /libs/foo/bar
    - /*/foo/Library/bar
    - /*/foo/bar
    - /libs/*/foo/Library/bar
    - /libs/*/foo/bar

the directory path is then constructed as prefix/path/lib.sh If the library is still not found an upwards directory traversal is used, and a check for presence of the library in the above mentioned possible paths is to be performed. This means this function needs to be called from the test hierarchy, not e.g. the /tmp directory.

Once library is found, it is sourced and a verifier function is called. The verifier function is cunstructed by composing the library prefix and LibraryLoaded. Library prefix must be defined in the library itself. It should be part of lib.sh header in format: '#   library-prefix = <PREFIX>'. If the verifier passes the library is ready to use. Also variable <PREFIX>LibraryDir is created and it points to the library folder.

Usage:

    rlImport --all
    rlImport LIBRARY [LIBRARY2...]
--all

Read $BEAKERLIB_DIR/metadata.yaml or ./Makefile, pickup the library requirements and import them all.

LIBRARY

Must have '[component/]path' or '.' format. Identifies the library to import. The dot (.) is a special case where the lib.sh from the current directory is used.

Returns 0 if the import of all libraries was successful. Returns non-zero if one or more library failed to import.

Authors

Info

2024-01-23 perl v5.38.2 User Contributed Perl Documentation